【发布时间】:2021-08-31 12:55:45
【问题描述】:
我正在尝试从我的 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 执行相同的代码,但在从扩展程序调用时不工作。
【问题讨论】:
-
canPerform 的结果是什么?恐怕 NSSharingService 不允许使用 NSExtension 实例(这是来自 dissasembly ShareKit.framework)
-
canPerform 返回失败。我不知道如何检查错误信息。我尝试使用也不会被调用的委托
-
阅读答案
标签: swift macos nssharingservice