I have an app that receives PN from a backend using Firebase Cloud Messaging. Basically, all I what to do is store some data of the PN with CoreData. I’m using application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) to do it. I tested the feature in foreground and background, opening the app with the PN and with the app icon. Everything works fine. But the problem is in this two cases:
- When the app is killed, a PN arrives, and the user taps on the push notification.
- When the app is killed, a PN arrives, and the user taps on the app icon.
I saw that sometimes, didReceiveRemoteNotifications is fired. Sometimes, it doesn’t. I read that this method is not called when the app is killed but I’m experiencing a different behaviour.
Also, I read that the way to handle push notifications in killed state is with VoIP apps or with UNNotificationServiceExtension. My app is not a VoIP app… Anyone knows if UNNotificationServiceExtension can resolve my problem?
This is the payload fired by the backend:
const message = {
apns: {
payload: {
aps : {
'content-available' : 1,
alert: {
title : "Game Request",
body : "Bob wants to play poker",
}
},
},
},
data: {
shortText: 'test',
chasisNumber: '23',
alertType: 'some alert type',
alertId: '1234',
alertTypeId: '1234',
userId: '1234',
text: 'some text',
title: 'some title',
deleted: 'false',
creationDate: '2011-11-02T02:50:12.208Z',
receivedDate: '2011-11-02T02:50:12.208Z',
actionType: 'some action type',
ticketId: '1234',
status: 'some status'
},
tokens: [androidToken, iosToken]
};