gpt4 book ai didi

Android Azure 通知中心取消注册

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:31:24 24 4
gpt4 key购买 nike

我在从 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 取消注册。

Why you should rarely unregister

You should only need to unregister in rare cases, such as if you wantan app to stop receiving messages, or if you suspect that theregistration ID has been compromised. In general, once an app has aregistration ID, you shouldn't need to change it.

In particular, you should never unregister your app as a mechanism forlogout or for switching between users, for the following reasons:

  • A registration ID isn't associated with a particular logged in user.If you unregister and then re-register, GCM may return the same ID ora different ID—there's no guarantee either way.

  • Unregistration may take up to 5 minutes to propagate.

  • After unregistration, re-registration may again take up to 5 minutes to propagate. During this time messages may be rejected dueto the state of beingunregistered, and after all this, messages may still go to the wronguser.

更多信息请点击:http://developer.android.com/google/gcm/gcm.html#unreg-why

由于您使用的是 Azure 通知中心,因此您只需从那里删除注册,而不是从 GCM 中删除。

关于Android Azure 通知中心取消注册,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29229878/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com