Reputation: 41
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)
I have a Firebase server and I sent a push notification from Postman.
I added apns-push-type, apns-priority, apns-topic (Apple Background push doc)
content-available
.{
"aps" : {
"content-available" : 1
},
"to":"my fcm token",
"notification" : {
"title" : "Alarm",
"body" : "Testing"
}
}
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)
Upvotes: 2
Views: 1029
Reputation: 41
For iOS 16.7 - just simple restart device fix this problem for me.
For iOS 18.1 - I had Background App Refresh disabled on my phone.
After I enabled it in Settings -> General -> Background App Refresh - everything worked fine
Upvotes: 0
Reputation: 111
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
Upvotes: 1