0

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

KENdi
  • 7,576
  • 2
  • 16
  • 31
Gianluca
  • 143
  • 1
  • 10
  • Can you change priority and check? And also please make sure that by mistake you are not sending content-availble true which results in silent push notification – Sivajee Battina Jul 10 '17 at 14:41
  • i tried priority normal and also without the tag priority – Gianluca Jul 10 '17 at 14:51
  • solution's here https://stackoverflow.com/questions/38520645/google-firebase-remote-notifications-not-popping-up-when-app-is-running-in-backg?rq=1 – Gianluca Jul 10 '17 at 15:30

2 Answers2

2

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.

Nirmalsinh Rathod
  • 5,079
  • 4
  • 26
  • 56
0

Check in capabilities You turned on Remote Notification in Background Modes.

JeeVan TiWari
  • 325
  • 2
  • 15