change Badge and push notification in iPhone SDK

2019-05-04 15:28发布

问题:

I tried the push notification tutorial . It's working fine but problem is badge. When I click on the view, app is appear and the close it. it still red badge in app icon. How to remove it ?

Another question is

when I click the view, it will appear home screen. I want to show other view when coming from push notification.

回答1:

This will reset the application badge number. If you set that value to zero, it will hide the badge.

[UIApplication sharedApplication].applicationIconBadgeNumber = iCount;

To handle your push notification with a separate view, you need to handle the following message in your application delegate:

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

You can access the userInfo dictionary to get additional information about the push notification that resulted in the message callback.