android-对于已卸载的registration_id,没有NoRegistered消息
作者:互联网
我使用以下方法获得了注册ID:
String regid = (GoogleCloudMessaging.getInstance(this)).register("My_Sender_ID");
并将其存储在我服务器上的数据库中.稍后,当卸载应用程序时,我尝试发送一条消息,我希望收到一条NotRegistered错误消息,查看该错误消息是从数据库中删除相应的ID.
但是问题在于,它仍然会像其他成功案例一样返回me_message_id.我想测试更多时间,等待了一个小时,现在我得到了正确的消息.
[error] => NotRegistered
那么,这种延迟是预期的吗?
谢谢
解决方法:
是的,这种延迟是预期的.
卸载应用后,第一次尝试发送消息时,GCM服务器尝试将其发送到设备,并发现您的应用已不再在该设备上注册GCM.
在卸载后第二次尝试发送消息时,您收到NotRegistered错误,因为这次GCM服务器知道该注册ID不再被注册.
您无需等待一个小时即可尝试再次发送.
Note: When users uninstall an application, it is not automatically
unregistered on GCM. It is only unregistered when the GCM server tries
to send a message to the device and the device answers that the
application is uninstalled or it does not have a broadcast receiver
configured to receive com.google.android.c2dm.intent.RECEIVE intents.
At that point, your server should mark the device as unregistered (the
server will receive a NotRegistered error).
(引自here)
标签:push-notification,google-cloud-messaging,android 来源: https://codeday.me/bug/20191123/2065788.html