I'm testing push notifications with content-available=1, and they don't seem to be delivered to the app in the background unless on Wi-Fi.
I have a simple log statement at the beginning of the push notification handler:
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
fetchCompletionHandler:(void (^) (UIBackgroundFetchResult))completionHandler {
NSLog(@"Notification received: %@", userInfo);
completionHandler(UIBackgroundFetchResultNewData);
}
Here is my test:
On Wi-Fi, the console log shows the notification. If I go to Settings and turn off Wi-Fi, switching to 4G, notifications no longer appear in the log (although they do slide in at the top of the screen, so I know they are being delivered).
There are no crash logs, and the notification is logged if I manually tap on it. Furthermore, this problem does NOT occur if I am debugging the app in Xcode. (i.e., if I am debugging in Xcode, the app will receive the notification in the background on 4G). Has anyone else experienced this behavior? Or am I doing something wrong?
EDIT: To be specific: according to my tests, if the following conditions are true, then the remote notification delegate method above will not be called:
However if condition 2 is removed (i.e., the phone is connected to Wi-Fi), then the handler will be called.
Based on feedback from a commenter here and repeated testing on multiple devices, this appears to be a bug (or intended behavior) on iOS.