【问题标题】:Reset or clear iOS app badge without any app interactions like open the app or push notification重置或清除 iOS 应用程序徽章,无需任何应用程序交互,例如打开应用程序或推送通知
【发布时间】:2017-12-28 06:16:59
【问题描述】:

无需任何应用交互(例如打开应用或任何推送/本地通知)即可重置/清除应用徽章。我的需要是,我想每天开始重置我的应用程序徽章,甚至不打开应用程序或收到任何通知。

【问题讨论】:

    标签: ios objective-c swift


    【解决方案1】:

    您可以在一天结束时安排本地通知,徽章计数等于 0。查看Updating iOS badge without push notifications

    【讨论】:

      【解决方案2】:

      我在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";

      感谢您的回答。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2011-07-19
        • 2012-06-17
        • 2018-08-21
        • 2016-06-09
        • 1970-01-01
        • 1970-01-01
        • 2012-05-11
        • 2021-11-17
        相关资源
        最近更新 更多