Reputation: 644
The issue is, iOS notifications only work properly (when app is active, inactive and terminated) if one sets the notification
field (empty or not). However for Android, one is required to not set the notification
field and only the data
field (otherwise if the app is inactive or terminated the notifications are automatically handled by the system and one can't manipulate them as in download a picture etc.).
How can i display notifications for both in a way that they appear on all states (active, inactive and terminated) and i can manipulate them before the will be displayed ?
I manipulate the notifications with these methods:
// Android
onMessageReceived(message: RemoteMessage)
// iOS
didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void)
Upvotes: 1
Views: 82
Reputation: 115
Save and check the device type (android/ios) of the token before sending your request to Firebase from your backend. Compose body of the request accordingly. e.g. with notification
field for the iOS tokens, and with data
field for the Android tokens.
Upvotes: 2