I'm trying to get my app to show up as a messaging option in the Contacts app, as described in WWDC 2016 session 240: https://developer.apple.com/videos/play/wwdc2016/240/?time=1072
What I'm aiming for is something like WhatsApp, which was discussed in the WWDC session. The code presented doesn't duplicate WhatsApp's Contact integration though. It only integrates my app with contacts specifically named as recipients in my INSendMessageIntent.
The code to create and donate an interaction looks like
let activity = NSUserActivity(activityType: "com.example.message")
activity.title = "Send CB Test Message"
activity.expirationDate = Date.distantFuture
let recipient = INPerson( /* recipient with an email address in my Contacts database */ )
let sender = INPerson( /* me */ )
let intent = INSendMessageIntent(recipients: [recipient], content: nil, groupName: nil, serviceName: "CB Test Chat", sender: sender)
let response = INSendMessageIntentResponse(code: .success, userActivity: activity)
let interaction = INInteraction(intent: intent, response: response)
interaction.direction = .outgoing
interaction.donate { (error) in
print("Donated")
if let error = error {
print("Donate error: \(error)")
}
}This succeeds and my app shows up in the recipient's contact card. Fine.
But I notice that WhatsApp options appear on all contact cards, including people who don't have WhatsApp accounts. How does that work? I tried passing an empty array or nil as the recipient list, but that had no effect. In fact, if I create a new contact with bogus information, WhatsApp still appears as a phone and video option.
How does that work? I had thought maybe WhatsApp was scanning my contacts and donating an interaction for everyone. But it's not even running, and I still see them as an option for newly created contact entries.