Search code examples
iosobjective-cfirebaseapple-push-notificationsfirebase-notifications

Firebase Notifications triggers wrong delegate on iOS 10


I am using Firebase to set up push notifications on iOS 10. My app is receiving remote messages while in the foreground, but not in the background. Background messages are only received on opening the app.

Somehow all push notifications are received through applicationReceivedRemoteMessage:, Firebase's data message delegate, while in fact I never send a data payload.

I exactly implemented AppDelegate as mentioned in the tutorial on Firebase's website, I set the APNS tokens myself and the certificates are all in the right place. Also, my payload is sent with priority 'high' and content-available.

Anyone got an idea why iOS 10's native remote message handler (userNotificationCenter:willPresentNotification:withCompletionHandler:) is never called instead?

Thanks a lot! (Have been debugging this for two days straight now...)


Solution

  • I just ran into this same problem.

    I resolved it by adding the following text to sender:

    "notification":{"body":""}}
    

    Don't set the Firebase delegate and just handle it in the old method

    didReceiveRemoteNotification