GCM上iOS通知的规范ID [英] Canonical IDs for iOS notifications over GCM

查看:112
本文介绍了GCM上iOS通知的规范ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一台服务器在iOS和Android上向我们的用户发送通知。 Android工作正常。



问题是,当用户卸载并重新安装我们的应用程序。然后,应用程序通过其APNS ID(仍然相同)从GCM请求新的推送ID,并向我们发送新的ID。现在我们有2条记录发送通知。它看起来像GCM只是以简单的N:1关系将其生成的ID映射到APNS ID。

如果我们在Android中有相同的情况,现在我们发送通知给GCM,它会在第一个响应中发送规范ID,所以我们可以对此做出反应不发送第二个通知。但与iOS不同。响应看起来像一个正常的,完整的,成功的请求。



我们是否错过了某些东西,或者没有GCM实现iOS的规范ID?我找不到任何有关此问题的信息。

解决方案

注册令牌是每个设备的每个安装。
每当您卸载并重新安装应用程序(iOS或Android)时,GCM都会为您提供新的注册令牌。

它与规范ID 。如果您获得Canonical ID,则需要使用新返回的Canonical ID替换服务器中的旧注册令牌,因为最终旧注册令牌将停止工作。



因此,如果您在卸载并重新安装iOS应用程序(或Android应用程序)时收到新的注册令牌,则可以简单地将新返回的令牌与旧应用程序进行比较。如果新的令牌与旧的令牌不同,那么你可以用服务器中的新令牌替换旧的令牌,这样就不需要在服务器中维护2个令牌。


We have a server to send notifications to our users on iOS and Android. Android works fine.

The problem is, when an user uninstalls and reinstalls our app. The app then requests a new push ID from GCM with its APNS ID(which is still the same) and sends us the new ID. Now we have 2 records to send notifications to. It looks like GCM just maps its generated ID to APNS ID in a simple N:1 relation.

If we had the same situation in Android and we now send our notifications to GCM, it would send the canonical ID in the first response, so we can react to that to not send a second notification. But with iOS it does not. The response looks like a normal, complete, successful request.

Did we miss something or didn't GCM implement canonical ids for iOS? I couldn't find any information regarding this problem.

解决方案

A registration token is per device per installation. Every time you uninstall and reinstall your app (either iOS or android), GCM will give you a new registration token.

It is a similar concept to Canonical IDs. If you get a Canonical ID, then you need to replace your old registration token in your server with the newly returned Canonical ID, as eventually the old registration token will stop working.

So, if you get a new registration token back when you uninstall and reinstall your iOS app (or Android app), you can simply compare the newly returned token with the old one. If the new token is different from the old token, then you can just replace the old one with the new one in your server so that you dont need to maintain 2 tokens in your server.

这篇关于GCM上iOS通知的规范ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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