The application icon does not update when a push notification arrives

I examined the issue of Updating the application icon at midnight using the options: the application is not running or in the background, the icon number may decrease and changing the icon icon of the application when receiving a notification and the icon of the notification icon is not reported and Update the icon icon when the application is closed , and much another, but I have the same problem as when the application is in the background, and the push notification arrives, the application icon icon is not updated.

I checked all the possibilities for this. My code is:

-(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
{

    UIApplicationState appState = UIApplicationStateActive;
    if ([application respondsToSelector:@selector(applicationState)]) {
        appState = application.applicationState;
    }

    for (id key in userInfo) {
        NSLog(@"key: %@, value: %@", key, [userInfo objectForKey:key]);
    }

    NSLog(@"remote notification: %@",[userInfo description]);

    [UIApplication sharedApplication].applicationIconBadgeNumber = [[[userInfo valueForKey:@"aps"] valueForKey:@"badge"] integerValue];

    UIApplicationState state = [application applicationState];


    if (state == UIApplicationStateActive)
    {
        NSString *message = [[userInfo valueForKey:@"aps"] valueForKey:@"alert"];
        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@""
                                                            message:message
                                                           delegate:self
                                                  cancelButtonTitle:@"OK"
                                                  otherButtonTitles:nil];
        [alertView show];

    }
 }

, , , . , , . , ios7.1: , , NSLog, . , , push-. , .

+4
2

, . , , . didReceiveRemoteNotification appDelegate , .

iOS, push- . , @rahulPatel. , BADGE_COUNT , INTEGER, , iOS, . :

$badges=(int)$cntmsg;

$body['aps'] = array(
                'alert' => $message,
                'sound' => 'default',
                'badge' => $badges
                //'msg_id'=> $msg_id
            );

, count msg as (int), . .

+11

. push- , .

.

{
    "aps" :  
    {
        "alert" : "Your notification message to show",
        "badge" : BADGE_COUNT ,
        "sound" : "sound.caf"
    }
}
+2

Source: https://habr.com/ru/post/1542458/


All Articles