【发布时间】:2020-04-20 14:28:18
【问题描述】:
在此article 之后,我正在尝试在我的消息传递应用程序中实施共享表建议。
我已在我的 Share 扩展程序的 info.plist 中声明支持 INSendMessageIntent。
它甚至出现在 'Supported Intents' 下的目标中。
但每次我捐赠 INSendMessageIntent 时,都会显示不支持 INSendMessageIntent。
Error Domain=IntentsErrorDomain Code=1901 "此扩展不支持捐赠意图 'INSendMessageIntent'。请确保通过在 Info.plist 中包含 NSUserActivityTypes 键来声明您的应用支持的意图,或者您的应用包含支持此意图的意图扩展。”
// Create an INSendMessageIntent to donate an intent for a conversation with Juan Chavez.
let groupName = INSpeakableString(spokenPhrase: "Juan Chavez")
let sendMessageIntent = INSendMessageIntent(recipients: nil,
content: nil,
speakableGroupName: groupName,
conversationIdentifier: "sampleConversationIdentifier",
serviceName: nil,
sender: nil)
// Add the user's avatar to the intent.
let image = INImage(named: "Juan Chavez")
sendMessageIntent.setImage(image, forParameterNamed: \.speakableGroupName)
// Donate the intent.
let interaction = INInteraction(intent: sendMessageIntent, response: nil)
interaction.donate(completion: { error in
if error != nil {
// Add error handling here.
} else {
// Do something, e.g. send the content to a contact.
}
})
【问题讨论】:
-
我看到了同样的错误信息,但是 - let interaction = INInteraction(intent: addAttendeeIntent, response: nil) interaction.donate { (error) in if error != nil { if let error =错误为 NSError? { print("发生错误:(error)") } } else { print("添加参加者意图成功") } }
标签: ios swift ios-app-extension share-extension