每次推送通知到达时,我都会尝试更新图标徽章,当我点击图标时我想收到通知消息。
对于徽章,我尝试在" applicationDidReceiveRemoteNotifications"中使用本地通知:
UILocalNotification * setBadge = [[UILocalNotification alloc] init];
UIApplication * app = [UIApplication sharedApplication];
setBadge.timeZone = [NSTimeZone defaultTimeZone];
// Update the badge of app when a notif appears
setBadge.applicationIconBadgeNumber += 1;
setBadge.fireDate = [NSDate dateWithTimeIntervalSinceNow:2];
[app scheduleLocalNotification:setBadge];
那个
[UIApplication sharedApplication] .applicationIconBadgeNumber + = 1;
它们都不起作用。
通过点击图标来获取通知消息更难
提前致谢
答案 0 :(得分:0)
这在我的项目中运作良好:
- (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;
}