【发布时间】:2012-06-17 07:21:03
【问题描述】:
我的应用使用推送通知。当我将应用程序安装到我的设备时,应用程序图标会显示推送通知徽章。徽章编号保持不变,不会随新通知更新。
有没有什么方法可以在安装应用后且仅在我的应用收到实际推送通知时不显示徽章?
【问题讨论】:
标签: iphone ios push-notification
我的应用使用推送通知。当我将应用程序安装到我的设备时,应用程序图标会显示推送通知徽章。徽章编号保持不变,不会随新通知更新。
有没有什么方法可以在安装应用后且仅在我的应用收到实际推送通知时不显示徽章?
【问题讨论】:
标签: iphone ios push-notification
func applicationDidBecomeActive(_ application: UIApplication) {
// 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.
application.applicationIconBadgeNumber = 0
}
【讨论】:
由于安装后没有调用你的应用程序,你不能这样做。
您也许可以在application:didFinishLaunchingWithOptions: 方法中做到这一点。
在这里您可以检查您的应用程序是否更新或清除图标徽章。
【讨论】: