简体   繁体   English

如何在安装应用时删除推送通知徽章

[英]how to remove push notification badge while installing an app

my app uses push notification. 我的应用使用推送通知。 When I install the app to my device the app icon shows a push notification badge. 当我将应用程序安装到我的设备时,应用程序图标会显示推送通知徽章。 The badge number remains the same and doesn't update with new notifications. 徽章编号保持不变,不会使用新通知进行更新。

Is there any way not to show the badge just after installing the app and only when my app receives an actual 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


}

Since there is not call made to you app after installing you can not do this. 由于安装后没有给你app打电话,你不能这样做。

You might be able to do it in the application:didFinishLaunchingWithOptions: method. 您可以在application:didFinishLaunchingWithOptions:执行此操作application:didFinishLaunchingWithOptions:方法。 Here you could make a check if you apps is update or something and clear the icon badge. 在这里,您可以检查应用程序是否更新或其他内容并清除图标徽章。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM