我在从 Azure 取消注册通知中心时遇到问题。
我正在使用方法unregister()
像这样 :
gcm = GoogleCloudMessaging.getInstance(getApplicationContext());
String connectionString = "xxx";
hub = new NotificationHub("xxx", connectionString, getApplicationContext());
try {
gcm.unregister();
hub.unregister();
Log.d("GCM","Unregister");
} catch (IOException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
};
我在此代码中没有遇到任何异常,但我仍然收到推送通知。任何帮助将不胜感激。提前致谢。
您不应该从 GCM 取消注册。
为什么你不应该注销
您只需要在极少数情况下取消注册,例如您想要
停止接收消息的应用程序,或者如果您怀疑
注册 ID 已被泄露。一般来说,一旦应用程序拥有
注册ID,您不需要更改它。
特别是,您永远不应该取消注册您的应用程序作为一种机制
出于以下原因注销或在用户之间切换:
更多信息请点击这里:http://developer.android.com/google/gcm/gcm.html#unreg-why http://developer.android.com/google/gcm/gcm.html#unreg-why
由于您使用的是 Azure 通知中心,因此您只需从那里删除注册,而不是从 GCM 中删除。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)