简体   繁体   English

通过推送重置应用程序图标上的徽章

[英]Reset badge on app icon from push

I use parse to send pushes to iOS and Android users. 我使用解析将推送发送给iOS和Android用户。 For some reason after Parse interface update the default setting "Increment the app badge?" 出于某种原因,在Parse界面更新默认设置后,“增加应用程序徽章吗?” was enabled and all iOS users now see red badge with "1". 已启用,并且所有iOS用户现在都看到带有“ 1”的红色徽章。

In my current app version. 在我当前的应用版本中。 I don't have any code in my app that deletes badges. 我的应用程序中没有删除徽章的任何代码。 How can i reset this badge for my users? 如何为用户重置此徽章? Maybe i can send some push to set it number to equal 0? 也许我可以发送一些推送将其设置为等于0?

Instead of choose text you should click on JSON 而不是选择text您应该单击JSON

Something like that: 像这样:

在此处输入图片说明

For each notification, compose a JSON dictionary object (as defined by RFC 4627). 对于每个通知,组成一个JSON字典对象(如RFC 4627所定义)。 This dictionary must contain another dictionary identified by the key aps. 该词典必须包含另一个由键aps标识的词典。 The aps dictionary can contain one or more properties that specify the following user notification types: aps词典可以包含一个或多个指定以下用户通知类型的属性:

An alert message to display to the user A number to badge the app icon with A sound to play 向用户显示警报消息带有应用声音的编号以标记应用程序图标

From here: https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/ApplePushService.html 从这里: https : //developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/ApplePushService.html

Also you could use "content-available" : 1 to create a silent Push Notification, that the users will receive the push but won't notify then, so you can just send this push to erase the badge 您也可以使用"content-available" : 1创建一个静默的推送通知,用户将收到该推送但不会通知,因此您可以发送此推送以删除徽章

func applicationDidBecomeActive(application: UIApplication) {
  let inst = PFInstallation.currentInstallation()
  if inst.badge != 0{
    inst.badge = 0
    inst.saveEventually()
  }
}

If you want to do that without updating the app you can send Push through Parse website and set badge : 0 . 如果您想这样做而不更新应用程序,则可以通过“解析”网站发送“推送”并设置badge : 0

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

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