我在我的应用程序中使用了phonekit的sharekit插件。这个插件允许我设置电子邮件的正文和主题。但是,它没有设置'到'/收件人字段的选项。我不知道目标C.你可以通过给我一个关于我需要添加/更改哪些文件的指南来帮助我实现这个功能。
这是我正在使用的插件的链接
https://github.com/phonegap/phonegap-plugins/tree/master/iOS/ShareKitPlugin
由于
答案 0 :(得分:0)
这个问题有回应:
https://stackoverflow.com/a/7648354/1272540
所以在ShareKitPlugin.m中添加:
- (void)shareToMail:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options {
[SHK setRootViewController:self.viewController];
SHKItem *item;
NSString *subject = [arguments objectAtIndex:1];
NSString *body = [arguments objectAtIndex:2];
item = [SHKItem text:body];
item.title = subject;
// **start of added code
NSString *recipient = [arguments objectAtIndex:3];
[item setCustomValue:recipient forKey:@"toField"];
// **end of added code
[SHKMail shareItem:item];
}
,这在SHKMail.m中:
[mailController setSubject:self.item.title];
[mailController setMessageBody:body isHTML:YES];
// **start of added code
NSString *recipient = [self.item customValueForKey:@"toField"];
NSLog(@"recipient: %@", recipient);
if (recipient != nil) {
NSArray *recipients = [[NSArray alloc] initWithObjects:recipient, nil];
[mailController setToRecipients:recipients];
[recipient release];
[recipients release];
}
// **end of added code
[[SHK currentHelper] showViewController:mailController];
并在ShareKitPlugin.js中:
ShareKitPlugin.prototype.shareToMail = function( subject, message , recipient)
{
if(typeof recipient === undefined){
recipient = '';
}
cordova.exec(null, null, "ShareKitPlugin", "shareToMail", [subject, message , recipient] );
};
此代码来自gitHub:https://github.com/ideashower/ShareKit/issues/281