注销新的谷歌云消息传递 [英] Unregister on new Google Cloud Messaging

查看:151
本文介绍了注销新的谷歌云消息传递的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是新的谷歌云消息

I'm using the new google cloud messaging

(GoogleCloudMessaging gcm =
           GoogleCloudMessaging.getInstance (context);)

我下面这个例子,这是非常好的,完美的作品:

I am following this example, which is very good and works perfectly:

<一个href="https://github.com/commonsguy/cw-omnibus/tree/master/Push/GCMClient2">https://github.com/commonsguy/cw-omnibus/tree/master/Push/GCMClient2

通过这个例子,我可以在GCM注册,但我没能成功地注销。

With this example I can register in the GCM, but I tried unsuccessfully to unregister.

在文档中表示应使用以下意图:

in the documentation indicates that you should use the following intent:

com.google.android.c2dm.intent.UNREGISTER

和使用它,如下所示:

 Intent unregIntent = new Intent ("com.google.android.c2dm.intent.UNREGISTER");
     unregIntent.putExtra ("app", PendingIntent.getBroadcast (this, 0, new Intent (), 0));
     StartService (unregIntent);

不工作...

not working ...

正如我所说的,登记工作正常,但不知道怎么注销。

As I said, the register works fine, but do not know how to unregister.

我必须做多意图是什么?我究竟做错了什么?

I have to do more than the intent? What am I doing wrong?

我AP preciate任何帮助

I appreciate any help

感谢和问候

推荐答案

如果您使用的是新的 GoogleCloudMessaging 类,则不需要使用 com.google.android.c2dm.intent.UNREGISTER 意图。只需使用<一个href="http://developer.android.com/reference/com/google/android/gms/gcm/GoogleCloudMessaging.html#unregister%28%29">GoogleCloudMessaging.unregister().

If you are using the new GoogleCloudMessaging class, you don't need to use the com.google.android.c2dm.intent.UNREGISTER intent. Simply use GoogleCloudMessaging.unregister().

公共无效取消注册()

注销申请。调用注销()停止从服务器的任何消息。这是一个阻塞调用,你不应该从UI线程调用它。你很少(如果有的话)需要调用此方法。它不仅是在资源价格昂贵,但它无效您的注册ID,它应该永远不会改变不必要的。更好的方法是简单地让服务器停止发送消息。仅使用,如果你希望你的应用程序注销停止使用GCM永久,或者你有一个令人信服的理由来回收您的注册ID。   引发   IOException异常,如果我们无法连接到服务器注销。

Unregister the application. Calling unregister() stops any messages from the server. This is a blocking call—you shouldn't call it from the UI thread. You should rarely (if ever) need to call this method. Not only is it expensive in terms of resources, but it invalidates your registration ID, which should never change unnecessarily. A better approach is to simply have your server stop sending messages. Only use unregister if you want your application to stop using GCM permanently, or you have a compelling reason to recycle your registration ID. Throws IOException if we can't connect to server to unregister.

这篇关于注销新的谷歌云消息传递的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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