更新徽章推送通知的应用程序,同时在后台 [英] Update badge with push notification while app in background

查看:196
本文介绍了更新徽章推送通知的应用程序,同时在后台的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有推送通知工作,并管理应用程序时,被带到前台更新图标徽章计数。

I have got push notification working and managed to update icon badge count when app is brought to foreground.

我有点困惑这虽然......在iPhone收到通知,并出现激活我的应用程序弹出消息,徽章才刚刚开始应用后,我更新。

I am a bit confused about this though...the iPhone receives the notification and the pop up message appears to activate my app, and the badge only updates after me starting the app.

这不健全的权利在用户体验方面。我的理解是,徽章计数应告知需要什么行动,通过增加的计数的用户,但这个美国能源部不会发生,直到后期,当应用程序是活的。

This does not sound right in terms of user experience. My understanding is that the badge count should notify the user of what needs action, through incremented count, but this doe not happen until a later stage when the app is live.

那么,有没有办法告诉应用程序时收到推送通知,并同时在后台更新它的徽章计数?

So is there a way to tell the app to update its badge count when it receives push notifications and whilst being in the background?

请注意,我的应用程序不使用的位置和我有 UIRemoteNotificationTypeBadge 的通知注册请求。

Note that my app does not use location and that I have UIRemoteNotificationTypeBadge in the notification registration request.

干杯
AF

推荐答案

由于推送通知是由iOS的处理,而不是你的应用程序,你不能改变在接收到推送通知应用程序徽章。

Since push notification are handled by iOS and not your app you can't change the application badge on receiving a push notification.

但你可以在推送通知的有效载荷发送证件号码,但你将不得不做计算服务器端。

But you can send the badge number in the payload of the push notification, but the you will have to do the calculation server side.

您应该阅读:<一href=\"http://developer.apple.com/library/mac/#documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/ApplePushService/ApplePushService.html\"相对=nofollow>本地和推送通知编程指南,尤其是<一个href=\"http://developer.apple.com/library/mac/#documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/ApplePushService/ApplePushService.html#//apple_ref/doc/uid/TP40008194-CH100-SW1\"相对=nofollow>的通知载荷。

You should read :Local and Push Notification Programming Guide and especially the The Notification Payload.

有效载荷可能是这样的:

The payload could look like this:

{
    "aps" : {
        "alert" : "You got your emails.",
        "badge" : 9
    }
}

现在的应用程序图标徽章将显示9。

Now the app application badge icon will show 9.

这篇关于更新徽章推送通知的应用程序,同时在后台的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆