我试图从我的FinderSync扩展发送一封电子邮件(打开默认的邮件客户端应用程序)。
let service = NSSharingService(named: NSSharingService.Name.composeEmail)
if(service != nil)
{
service!.recipients = ["test@gmail.com"]
service!.subject = "Test Mail"
if service!.canPerform(withItems: ["Test Mail body"])
{
service!.perform(withItems: ["Test Mail body"])
}
else
{
//fail for me
}
}相同的代码在启动主应用程序时从AppDelegate/ViewController执行,但在从扩展调用时不工作。
发布于 2021-08-31 13:33:10
FinderSync是不允许使用NSSharingService的NSExtension
/* @class SHKSharingService (ShareKit.framework) */
-(char)canPerformWithItems:(NSArray *)items {
if (([[SHKSharingService class] isShareKitPlugInService] || ([items count] > 0x1388)) {
return NO;
}isShareKitPlugInService被定义为
[[NSBundle mainBundle] infoDictionary][@"NSExtension"]https://stackoverflow.com/questions/68999076
复制相似问题