0

当我尝试从 Xcode 构建时,我收到以下错误(来自 EmailComposer phonegap 插件)。我不熟悉 Obj-C,所以我不确定这是否是我犯的错误的结果,或者是因为插件已过时。我正在使用最新版本的 Phonegap (3?) & Xcode 4.6.3。

  • EmailComposer.m:132:6:“释放”不可用:在自动引用计数模式下不可用
  • EmailComposer.m:132:6:ARC 禁止发送明确的“释放”消息
  • EmailComposer.m:175:21:将 Objective-C 指针类型“NSString *”转换为 C 指针类型“CFStringRef”(又名“const struct __CFString *”)需要桥接转换
  • EmailComposer.m:179:11:将 C 指针类型“CFStringRef”(又名“const struct __CFString *”)转换为 Objective-C 指针类型“NSString *”需要桥接转换
4

1 回答 1

0

试试这样。。

我将以下插件文件与 cordova-2.7.0 和 xcode 4.6 一起使用。这对我来说可以。

取一个插件文件名作为 EmailComposer 并将以下代码复制到 EmailComposer.h 文件中

#import <MessageUI/MFMailComposeViewController.h>
#import <Cordova/CDVPlugin.h>
@interface EmailComposer : CDVPlugin < MFMailComposeViewControllerDelegate > {    
}

- (void) showEmailComposer:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options;

- (void) openApplication:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options;

@end

并将以下代码复制到 EmailComposer.m 文件中

#import "EmailComposer.h"
@implementation EmailComposer

- (void) openApplication:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options{
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@",[arguments objectAtIndex:1]]]];
}

- (void) showEmailComposer:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options
{   
// NSUInteger argc = [arguments count];

NSString* toRecipientsString = [arguments objectAtIndex:1];//[options valueForKey:@"toRecipienthellos"];
NSString* ccRecipientsString = [options valueForKey:@"ccRecipients"];
NSString* bccRecipientsString = [options valueForKey:@"bccRecipients"];
NSString* subject = [options valueForKey:@"subject"];
NSString* body = [options valueForKey:@"body"];
NSString* isHTML = [options valueForKey:@"bIsHTML"];

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

// Set subject
if(subject != nil)
    [picker setSubject:subject];
// set body
if(body != nil)
{
    if(isHTML != nil && [isHTML boolValue])
    {
        [picker setMessageBody:body isHTML:YES];
    }
    else
    {
        [picker setMessageBody:body isHTML:NO];
    }
}

// Set recipients
if(toRecipientsString != nil)
{
    [picker setToRecipients:[ toRecipientsString componentsSeparatedByString:@","]];
}
if(ccRecipientsString != nil)
{
    [picker setCcRecipients:[ ccRecipientsString componentsSeparatedByString:@","]]; 
}
if(bccRecipientsString != nil)
{
    [picker setBccRecipients:[ bccRecipientsString componentsSeparatedByString:@","]];
}

if (picker != nil) {    
    [self.viewController presentModalViewController:picker animated:YES];
}
[picker release];
}

// Dismisses the email composition interface when users tap Cancel or Send. Proceeds to update the message field with the result of the operation.

- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error 
{   
// Notifies users about errors associated with the interface
int webviewResult = 0;

switch (result)
{
    case MFMailComposeResultCancelled:
        webviewResult = 0;
        break;
    case MFMailComposeResultSaved:
        webviewResult = 1;
        break;
    case MFMailComposeResultSent:
        webviewResult =2;
        break;
    case MFMailComposeResultFailed:
        webviewResult = 3;
        break;
    default:
        webviewResult = 4;
        break;
}

[self.viewController dismissModalViewControllerAnimated:YES];

NSString* jsString = [[NSString alloc] initWithFormat:@"window.plugins.emailComposer._didFinishWithResult(%d);",webviewResult];
[self writeJavascript:jsString];
[jsString release];

 }

 @end
于 2013-09-11T05:57:06.820 回答