0

我在我的应用程序中为 phonegap 使用 sharekit 插件。这个插件允许我设置电子邮件的正文和主题。但是,它没有设置“to”/recipient 字段的选项。我不知道Objective C。你能帮我实现这个功能吗?给我一个关于我需要在哪些文件中添加/更改的指南。

这是我正在使用的插件的链接

https://github.com/phonegap/phonegap-plugins/tree/master/iOS/ShareKitPlugin

谢谢

4

1 回答 1

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

于 2013-05-23T08:52:47.517 回答