嗨,我正在开发一个IOS phonegap应用程序。这里我需要从应用程序发送电子邮件,因此我使用messageUI.framework,但我不知道如何实现它。
这是我的html发送电子邮件按钮与java脚本功能。
<input id="EMAIL" type="submit" onClick='gomail()' data-theme="b" value="Send E-mail" data-mini="false">
function gomail()
{
alert("mail");
}这是我的MainControllerView.h
#import <Cordova/CDVViewController.h>
#import <MessageUI/MessageUI.h>
@interface MainViewController : CDVViewController <MFMailComposeViewControllerDelegate>
// how to invoke html button event here ....
@end这是我的MainControllerView.m
- (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应用程序的方法。
提前感谢
发布于 2013-12-24 01:21:30
我的建议是使用一个PhoneGap插件来帮助你完成这个任务,你可以找到一个基于EmailComposerWithAttachments插件的forked here。它可以处理您正在寻找的所有内容,如果您也决定使用该路径,它还可以轻松添加附件。
编辑:添加插件安装信息
添加插件
phonegap plugin add https://github.com/whodeee/email-composerwindow.plugins.emailComposer.showEmailComposerWithCallback(callback,subject,body,toRecipients,ccRecipients,bccRecipients,isHtml,attachments,attachmentsData);调用它上面的github链接中引用了该方法
https://stackoverflow.com/questions/20746125
复制相似问题