Share sheet suggestions

Following this article I'm trying to implement share sheet suggestions in my messaging app.


I have declared 'INSendMessageIntent' support in my Share extension's 'info.plist'.


It's even showing up in the target under 'Supported Intents'.


But every time I'm donating a 'INSendMessageIntent' it fails saying 'INSendMessageIntent' is not supported.


Error Domain=IntentsErrorDomain Code=1901 "Donating intent 'INSendMessageIntent' is not supported by this extension. Please make sure that you declare the intents that your app supports by including the NSUserActivityTypes key in its Info.plist or your app contains an Intents extension that supports this intent."


// 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.
    }
})

Accepted Reply

You should add NSUserActivityTypes entry to your app's Info.plist. Declare it as array and add your intents to it. That works for me.

Replies

You should add NSUserActivityTypes entry to your app's Info.plist. Declare it as array and add your intents to it. That works for me.