简体   繁体   English

应用更新时设置图标徽章

[英]Set icon badge when app updated

My app contains a number of embedded exercises that are shown to the user during app usage. 我的应用程序包含许多在应用程序使用过程中显示给用户的嵌入式练习。 I plan to release regular updates of my app that contain additional exercises. 我计划发布包含其他练习的我的应用程序的定期更新。 After each (standard appstore app) update I would like to add a badge to the app icon showing the number of new exercises (=diff between old nbr and new update nbr exercises). 每次更新(标准appstore应用程序)后,我想向应用程序图标添加徽章,以显示新练习的数量(=旧nbr和新的nbr练习之间的差异)。

I would like to add the badge without the user needing to start the app, immediatly and automatically after the update. 我想添加徽章,而无需用户在更新后立即自动启动应用程序。

How can this be done? 如何才能做到这一点? When ios updates your app, does it run for a brief period? 当ios更新您的应用程序时,它会运行一小段时间吗? In that case the logic could be implemented at that point.... 在那种情况下,逻辑可以在那时实现。

Sounds like you're going to want to use a remote notification (aka Push) thats scheduled after you release an update. 听起来您将要使用发布更新后安排的远程通知(也称为“推送”)。 Apple Push Notifications 苹果推送通知

The issue with this is the user might not update automatically (or refuse an update). 问题是用户可能不会自动更新(或拒绝更新)。 So maybe you can have a push that says "We just released an update with X new exercises!", rather than implying they already have the data. 因此,也许您可​​以说“我们刚刚发布了包含X个新练习的更新!”,而不是暗示他们已经有了数据。

Try this 尝试这个

  [[UIApplication sharedApplication] setApplicationIconBadgeNumber:1];

To do this through local notification you have to set the value in applicationIconBadgeNumber 要通过本地通知执行此操作,您必须在applicationIconBadgeNumber中设置值

UILocalNotification *localNotification = [[UILocalNotification alloc] init];

localNotification.applicationIconBadgeNumber = 1;// set here the value of badge

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

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