iOS Remote Notifications not working when "content-available": 1
Solution 1
Check out this answer on SO: Silent Push Notification in iOS 7 does not work
Seems like there is a bug that requires another field to be present for the remote notification to be valid.
Solution 2
I have tested on iOS 7.0.6 to send a slient push with the payload:
{"aps":{"content-available":1}}
and worked fine, here is my userInfo object on Xcode:
2014-05-09 11:04:23.737 SilentPushTest[316:60b] PAyload {
aps = {
"content-available" = 1;
};
}
You can test sending push easily with this app:
https://bitbucket.org/jesuslg123/pushmebaby
Just need to add your app certificate with the name apns.cert and compile it.
user1285413
Updated on June 04, 2022Comments
-
user1285413 about 2 years
I can receive Push Notifications in my iOS app without problems, but if I try to send a Silent Notification adding "content-available": 1, I will not receive any notifications no matter the state of my app (even if it is running in the foreground)
I have checked the Remote Notifications checkbox. (or added remote-notification in .plist) and I have implemented application:didReceiveRemoteNotification:fetchCompletionHandler but didReceiveRemoteNotification only is called if I send a normal push notification and the app is running in the foregound
Any idea??
-
Sharme about 10 yearsCan you please post your didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult result))handler in the app delegate ?
-
Jesuslg123 almost 10 yearsDon't forget to enable on "Capabilities" the "Background Modes" and active the "Remote notifications" inside.
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler { [logHelper addLogWithText:[NSString stringWithFormat:@"PAyload %@", userInfo.description]]; }
I'm not sure how to properly format the code on the comment... @S_O -
Sharme almost 10 yearsOh yeah sure. Thank you