我正在使用 NSSharingService 在邮件应用程序中打开一个电子邮件撰写窗口:
NSSharingService* sharingService = [NSSharingService sharingServiceNamed:NSSharingServiceNameComposeEmail];
[sharingService setRecipients:@[@"[email protected] /cdn-cgi/l/email-protection"]];
[sharingService setSubject:@"Test"];
sharingService.delegate = self;
它可以很好地打开撰写电子邮件窗口,当我输入一些文本并实际发送电子邮件时,我什至会收到对委托的回调:
- (void)sharingService:(NSSharingService *)sharingService didShareItems:(NSArray *)items {
NSLog(@"sharingService didShareItems - %@", sharingService.messageBody);
}
问题是它返回的messageBody总是nil。我期望它包含已发送的电子邮件的文本。我检查了 NSSharingService 的头文件:
/* These read-only properties allow for querying of the shared content:
*/
// Message body as string
@property (readonly, copy) NSString *messageBody NS_AVAILABLE_MAC(10_9);
// URL to access the post on Facebook, Twitter, Sina Weibo, etc. (also known as permalink)
@property (readonly, copy) NSURL *permanentLink NS_AVAILABLE_MAC(10_9);
// Account name used for sending on Twitter or Sina Weibo
@property (readonly, copy) NSString *accountName NS_AVAILABLE_MAC(10_9);
// NSArray of NSURL objects representing the file that were shared
@property (readonly, copy) NSArray *attachmentFileURLs NS_AVAILABLE_MAC(10_9);
知道为什么这可能行不通吗?如果我使用的话似乎工作正常NSSharingServiceNameComposeMessage
而不是电子邮件,但那是为了发送 iMessages。