每次应用程序开始是正确的做法注册的设备上GCM?应用程序、做法、正确、设备

2023-09-07 14:47:13 作者:烂人不该拥有爱人

我开发一个PhoneGap的应用程序,并遵循这个教程实施PushPlugin。然而,它说,每一个deviceready事件触发时注册的应用程序。这意味着,它会注册在GCM的设备,即使它会一直pviously注册$ P $。

I am developing a phonegap app and followed this tutorial to implement PushPlugin. However, it says to register the app every time deviceready event is triggered. This means that it'll register the device on GCM even if it'd been previously registered.

这让我有点不舒服,因为它似乎并没有成为一个很好的做法,因为该设备已经被注册了,所以,我决定来这里问。这是一个好的做法呢?如果不是,为什么?难道这有一些长期并发症?

This made me a little bit uncomfortable as it doesn't seem to be a good practice, since the device was already registered, so, I decided to come here to ask. Is this a good practice? If not, why? Do this have some long term complication?

推荐答案

在我们的应用中,我们发现这是有几个原因的好做法:

In our application we have found this to be a good practice for several reasons:

有关注册设备的API返回重新presents该设备的令牌。从我能看到的,GCM不保证该令牌将继续无限期有效。因此,未注册可能会导致您的设备令牌过期。

The API for registering the device returns a token that represents that device. From what I could see, GCM does not guarantee that the token will remain valid indefinitely. Thus failure to register could lead to expiration of your device token.

与GCM注册,使得该服务知道你的设备处于活动状态。从我们观察到的,最近与GCM注册的设备似乎收到推送通知最快的。也就是说,给定2设备,一个最近注册的(设备A),以及已登记的最后数天前(设备B)另外,设备A总是会收到推送通知更快 - 通常分设备B之前这只是我们观察。

Registering with GCM, makes the service aware that your device is active. From what we observed, devices recently registered with GCM seemed to receive push notifications fastest. That is, given 2 devices, one recently registered (Device A), and the other that had last registered several days ago (Device B), Device A would always receive push notifications faster - often minutes before Device B. This is simply what we observed.