Reputation: 1179
Although this was asked in several places I haven't seen one answer that helped me.
I am trying to get a push notification and tried the following functions:
-(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
-(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
The issue:
I am only able to receive the remote notification if the app is in foreground. If it's in background, nothing gets invoked.
I am using iOS8.
The following background modes are checked: "Background fetch","Remote notification"
Can anyone help me with that?
Upvotes: 1
Views: 200
Reputation: 13551
Its pretty deep in the documenation, but in your JSON payload, you need to set the 'content-available' to 1.
If your payload doesn't have an "alert" or "content-available" then you won't get a notification in your app delegate.
Upvotes: 1