didReceiveRemoteNotification not called on background (Firebase, Postman, iOS)

437 Views Asked by At

Problem: `didReceiveRemoteNotification` is not called.

I do get notifications when my app is in background. (real device).

I just want to have didReceiveRemoteNotification called whenever notification arrives in background and no user interaction has been made (no tapping).
(My device is iOS 16.3 and Xcode is 14.1)

What I did

I have a Firebase server and I sent a push notification from Postman.

My header

enter image description here I added apns-push-type, apns-priority, apns-topic (Apple Background push doc)

My Body

  • I also tried true and "true" for content-available.
{
    "aps" : {
      "content-available" : 1
      },
    "to":"my fcm token",
    "notification" : {
        "title" : "Alarm",
        "body" : "Testing"
        }
}

Other settings

I did FirebaseApp.configure(), Messaging.messaging().delegate = self, UIApplication.shared.registerForRemoteNotifications(), Messaging.messaging().apnsToken = deviceToken.
I also added Push Notifications and Background Modes (Remote notifications, Background fetch)

1

There are 1 best solutions below

4
VinodA On

Assuming you are using the

application(_:didReceiveRemoteNotification:fetchCompletionHandler:)

Did you try changing the content-available to true or "true" instead of using 1? Refer:didReceiveRemoteNotification not called Swift