Reputation: 143
There's a problem with my app and I don't know why: notification with Firebase doesn't work when the app is in the background, but they are fired once the app goes in the foreground. The problem is not how to handle them, but why when the app is in foreground notification popup are fired, but when are in the background not.
{
"notification" : {
"title" : "...",
"body" : "...",
"icon" : "...",
"sound" : "default"
},
"to": "...",
"priority" : "high",
"data" : {
...
}
}
This is a sample of the notification I tried to fire with the postman. Any ideas? Thanks
Upvotes: 0
Views: 440
Reputation: 335
Check in capabilities You turned on Remote Notification in Background Modes.
Upvotes: 0
Reputation: 5186
1) Check your certificate and bundle identifier in Firebase.
2) Make sure you send Device Token to Firebase.
- (void)application:(UIApplication *)application
didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
// For Development
[FIRInstanceID instanceID] setAPNSToken:deviceToken type:FIRInstanceIDAPNSTokenTypeSandbox];
// For Production
[FIRInstanceID instanceID] setAPNSToken:deviceToken type: FIRInstanceIDAPNSTokenTypeProd];
}
You can checkout this Link for more information.
Upvotes: 2