I am trying to achieve silent push notification.I need to save the silent push notification data in my database in app so that I can show the unseen notification and its count to users when the users uses the app. I am using Xcode 6.1 and targeting iOS 7 and later devices. Currently, I am using development certificates for push notification. I have checked remote notification in the background modes of target project capabilities, also the info-list's background mode has "App downloads content in response to push notifications" in required background modes.
In my AppDelegate.m
, I am able to register remote notification and also get the device token. Now when I send push notification, my delegate method gets called when app is in foreground but when app is in background/not running, it doesn't get called though I receive the push notification in banner.
I have implemented this method in AppDelegate.m
-(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler{
NSLog(@"Received push notification");
}
The payload I am sending looks like this:
{
aps: {
content-available: 1
}
}
I tried adding priority, sound etc. But nothing helped me. Can someone help me to figure out how to save silent push notification data in app when app is in running in the background or not running? Kindly help me to resolve this issue.