0
    -(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.

SRS Infosystems
  • 167
  • 2
  • 16
  • Please check out [this answer](http://stackoverflow.com/a/23917593/1310204). Perhaps you need to add the `priority = 5;` to your aps payload JSON. – Nikolay Mamaev Jan 05 '15 at 12:45
  • Thanks Nikolay but I'm getting silent push notifications properly when app is running in foreground, my problem is when app is in background then not calling delegate method for push notification and no any log is printing on console. – SRS Infosystems Jan 05 '15 at 12:59
  • When testing app in background, do you have a passcode lock on? – Mike Taverne Jan 05 '15 at 14:37
  • Thanks Mike Taverne, Yes my device's passcode lock is on but not getting any logs on console. – SRS Infosystems Jan 06 '15 at 06:28

0 Answers0