We have implemented Carplay in our voip based project and in this we have implemented Incoming call and chat notification feature for Carplay. For Carplay we implemented siri. Siri Object donated Successfully in Notification service Extension when notification didreceive method called. Donation Code :-
func donateIncomingMessageIntent(sender: String, senderId: String, message: String, messageId: String, userInfo: [AnyHashable: Any],destination:String) { // Create proper name components clearAllinteraction() var nameComponents = PersonNameComponents() nameComponents.givenName = sender //unknown let senderPerson = INPerson( personHandle: INPersonHandle(value: senderId, type: .unknown), nameComponents: nameComponents, displayName: sender, image: nil, contactIdentifier: senderId, customIdentifier: "sender_\(senderId)" ) let recipientPerson = INPerson( personHandle: INPersonHandle(value: "me@example.com", type: .emailAddress), nameComponents: nil, displayName: "Me", image: nil, contactIdentifier: "me_id", customIdentifier: "user_id" ) let inMessage = INMessage( identifier: messageId, conversationIdentifier: "conversation_\(senderId)", content: message, dateSent: Date(), sender: senderPerson, recipients: [recipientPerson], groupName: nil, messageType: .text ) let intent = INSearchForMessagesIntent( recipients: [recipientPerson], senders: [senderPerson], searchTerms: [message], attributes: .unread, dateTime: nil, identifiers: [messageId], notificationIdentifiers: [messageId], groupNames: ["Messages"] ) let interaction = INInteraction(intent: intent, response: nil) interaction.identifier = "message_\(messageId)" interaction.direction = .incoming // Add direction DispatchQueue.global(qos: .userInitiated).async { interaction.donate { error in if let error = error { print("❌ Failed to donate INSearchForMessagesIntent: \(error.localizedDescription)") } else { print("✅ Donated INSearchForMessagesIntent successfully!") let intentData: [String: Any] = [ "senderName": sender, "senderId": senderId, "message": message, "messageId": messageId, "timestamp": Date().timeIntervalSince1970, "conversationId": "conversation_\(senderId)", // Add conversationId "destination":destination ] let defaults = UserDefaults(suiteName: "group.com.chatapp") // 🔁 Use your App Group ID defaults?.removeObject(forKey: "lastCarPlayIntentData") defaults?.set(intentData, forKey: "lastCarPlayIntentData") defaults?.synchronize() } } } }
Here SenderID is like 3000@abc,2000@abc etc. In siri ,When we handle INSearchForMessagesIntent at that time all data getting from Userdefaults because without Userdefaults INSearchForMessagesIntent value nil.
Even we enabled announcement using .allowAnnouncement. We also tried to save same sender in contact Book because sometime siri search contact and not found then may be raise this type of issue.
So we need code level support for read incoming message in carplay when notification comes.
Thank you.