注销新的谷歌云消息传递消息、谷歌云

由网友(奧特曼ゝ)分享简介:我使用的是新的谷歌云消息I'm using the new google cloud messaging (GoogleCloudMessaging gcm =GoogleCloudMessaging.getInstance (context);)我下面这个例子,这是非常好的,完美的作品:I am followi...

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

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:

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 意图。只需使用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.

阅读全文

相关推荐

最新文章