首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在手机gap中使用messageUI.framework?

如何在手机gap中使用messageUI.framework?
EN

Stack Overflow用户
提问于 2013-12-23 23:06:25
回答 1查看 393关注 0票数 0

嗨,我正在开发一个IOS phonegap应用程序。这里我需要从应用程序发送电子邮件,因此我使用messageUI.framework,但我不知道如何实现它。

这是我的html发送电子邮件按钮与java脚本功能。

代码语言:javascript
复制
<input id="EMAIL" type="submit" onClick='gomail()' data-theme="b" value="Send E-mail"  data-mini="false">

function gomail()
       {
       alert("mail");
       }

这是我的MainControllerView.h

代码语言:javascript
复制
#import <Cordova/CDVViewController.h>
#import <MessageUI/MessageUI.h>

    @interface MainViewController : CDVViewController <MFMailComposeViewControllerDelegate>
   // how to invoke html button event here .... 

    @end

这是我的MainControllerView.m

代码语言:javascript
复制
- (IBAction)send:(id)sender {


    MFMailComposeViewController *mailComposer;
    mailComposer = [[MFMailComposeViewController alloc] init];
    mailComposer.mailComposeDelegate=self;

    NSArray *emailAddresses;
    emailAddresses=[[NSArray alloc]initWithObjects:@"test@gmail.com", nil];

    NSString *sendSubject = [[NSString alloc]initWithFormat:@"%@",self.latitude.text];
    NSString *sendMessage = [[NSString alloc]initWithFormat:@"%@",self.longitude.text];

    [mailComposer setToRecipients:emailAddresses];
    [mailComposer setSubject:sendSubject];
    [mailComposer setMessageBody:sendMessage isHTML: NO];
    [self presentModalViewController:mailComposer animated:YES];

}

- (void) mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error
{

    [self dismissModalViewControllerAnimated:YES];

}

这是发送电子邮件的代码。

如何从html链接到MainControllerView.h和MainControllerView.m?

请告诉我它们之间的联系。

请给我一个从原生应用程序返回html5应用程序的方法。

提前感谢

EN

回答 1

Stack Overflow用户

发布于 2013-12-24 01:21:30

我的建议是使用一个PhoneGap插件来帮助你完成这个任务,你可以找到一个基于EmailComposerWithAttachments插件的forked here。它可以处理您正在寻找的所有内容,如果您也决定使用该路径,它还可以轻松添加附件。

编辑:添加插件安装信息

添加插件

  1. 使用终端(适用于mac)导航到项目文件夹以下phonegap plugin add https://github.com/whodeee/email-composer
  2. That中的
  3. 类型会将插件添加到项目中
  4. 要使用插件,请使用此javascript方法window.plugins.emailComposer.showEmailComposerWithCallback(callback,subject,body,toRecipients,ccRecipients,bccRecipients,isHtml,attachments,attachmentsData);调用它

上面的github链接中引用了该方法

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/20746125

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档