Ios 更新图标的徽章并在单击图标时获得通知消息

Ios 更新图标的徽章并在单击图标时获得通知消息,ios,objective-c,xcode,Ios,Objective C,Xcode,每次推送通知到达时,我都会尝试更新图标徽章,当我单击图标时,我希望获得通知消息 对于badge,我尝试在“ApplicationIDReceivereMoteNotifications”中使用本地通知: 那 [UIApplication sharedApplication].ApplicationOnBadgeNumber+=1 它们都不起作用 要通过点击图标来获取通知信息就更难了 提前感谢这在我的项目中效果很好: - (void)applicationDidBecomeActive:(UIAp

每次推送通知到达时,我都会尝试更新图标徽章,当我单击图标时,我希望获得通知消息

对于badge,我尝试在“ApplicationIDReceivereMoteNotifications”中使用本地通知:

[UIApplication sharedApplication].ApplicationOnBadgeNumber+=1

它们都不起作用

要通过点击图标来获取通知信息就更难了


提前感谢

这在我的项目中效果很好:

- (void)applicationDidBecomeActive:(UIApplication *)application
{
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
    self.isBackground = NO;
    [[NSNotificationCenter defaultCenter] postNotificationName:AppChangeState object:@(self.isBackground)];
    [[NSNotificationCenter defaultCenter] postNotification:[NSNotification notificationWithName:DID_BECOME_ACTIVE
                                                                                         object:nil
                                                                                       userInfo:nil]];

    [UIApplication sharedApplication].applicationIconBadgeNumber = 0;
}
你在什么地方放了一个“addObserver”?
- (void)applicationDidBecomeActive:(UIApplication *)application
{
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
    self.isBackground = NO;
    [[NSNotificationCenter defaultCenter] postNotificationName:AppChangeState object:@(self.isBackground)];
    [[NSNotificationCenter defaultCenter] postNotification:[NSNotification notificationWithName:DID_BECOME_ACTIVE
                                                                                         object:nil
                                                                                       userInfo:nil]];

    [UIApplication sharedApplication].applicationIconBadgeNumber = 0;
}