I am banging my head. I am implementing push notification. Everything is working fine (push is received, badge is updated) but under iOS 13.3 the method application(_:didReceiveRemoteNotification:fetchCompletionHandler:) is not called when the app is in the background. If the app is in the foreground or using an iOS 12 device the method is called. I register for push notification in the following way (yes, it is still Objective C)
[[UNUserNotificationCenter currentNotificationCenter] requestAuthorizationWithOptions:(UNAuthorizationOptionBadge | UNAuthorizationOptionSound | UNAuthorizationOptionAlert) completionHandler:^(BOOL granted, NSError * _Nullable error) {
if (granted) {
dispatch_async(dispatch_get_main_queue(), ^{
[[UIApplication sharedApplication] registerForRemoteNotifications];
});
}
}];
The payload is set to the following:
{"aps": {
"badge": 10,
"alert": "test",
"content-available": 1
}}
I tried adding "Remote notifications" and "Background processing" as app capabilities in all variations (only "Remote notifications"/"Background processing", without any of those capabilities, enabling both) without any change. I set the delegate for the UNUserNotificationCenter but again without success. I set the headers accordingly:
curl -v \
-H 'apns-priority: 4' \
-H 'apns-topic: xx.xxxxx.xxxx' \
-H 'apns-push-type: alert' \
-H 'Content-Type: application/json; charset=utf-8' \
-d '{"aps": {"badge": 10,"alert": "test", "content-available":1}}' \
--http2 \
--cert pushcert.pem \
https://api.sandbox.push.apple.com/3/device/1234567890
From the docs it states that this method is called even when the app is in background:
Use this method to process incoming remote notifications for your app. Unlike the application:didReceiveRemoteNotification: method, which is called only when your app is running in the foreground, the system calls this method when your app is running in the foreground or background.
I tried with and without background modes (Remote Notification, Background processing, Background fetch) but without success. If I use an iOS 12 device, the method is called.
My goal is to process some of the information in the payload (there might be additional information).
What am I missing here for iOS 13 (13.3 to be exact)?