重置或清除iOS应用徽章,无需任何应用互动,例如打开应用或推送通知

时间:2017-12-28 06:17:00

标签: ios objective-c swift

在没有任何应用互动的情况下重置/清除应用徽章的任何可能性,例如打开应用或任何推送/本地通知。我的需求是,我想在每天开始重置我的应用徽章,甚至不打开应用或任何通知。

2 个答案:

答案 0 :(得分:0)

您可以安排当天结束的本地通知,徽章数量等于0.请查看Updating iOS badge without push notifications

答案 1 :(得分:0)

我在this solution的帮助下解决了这个问题。工作代码是:

UILocalNotification* localNotification = [[UILocalNotification alloc] init];
NSCalendarUnit unitDay = NSCalendarUnitDay;
localNotification.repeatInterval = unitDay;
localNotification.fireDate = fireDate;
localNotification.applicationIconBadgeNumber = -1;
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];

本地通知没有alertBody,因此本地通知不会预先显示。 如果需要显示alertBody,请添加localNotification.alertBody = @"Your notification alertBody";

感谢您的回答。