-(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary
*)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
{
NSLog(@"Push info= %@",userInfo);
if([userInfo[@"aps"][@"content-available"] intValue] == 1)
{
NSLog(@"silent push notification received");
NSString *strQuery = [NSString stringWithFormat:@"UPDATE staff_list SET is_update =
'YES'"];
[[DatabaseManager sharedInstance] updateDatabaseForQuery:strQuery];
completionHandler(UIBackgroundFetchResultNewData);
return;
}
else
{
completionHandler(UIBackgroundFetchResultNoData);
return;
}
}
My payload for silent push notification is {
aps = {
"content-available" = 1;
sound = "";
};
}
Also unabled background mode for remote notification.
This will work perfect when app is running in foreground but when I press home button then app is running in background and after that not executing any method when receiving a new silent push notification.
Please help me I have stuck with this since last 3 days.
Thanks in advance.