每次应用程序启动时,在GCM上注册设备是正确的方法? [英] Register a device on GCM every time the app start is the right approach?

查看:236
本文介绍了每次应用程序启动时,在GCM上注册设备是正确的方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个phonegap应用程式,并遵循这个教程来实现PushPlugin。但是,它说,要注册的应用程序每次触发设备的事件。这意味着它会在GCM上注册设备,即使它之前已注册。

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?

推荐答案

在我们的应用程序中,我们发现这是一个很好的做法,有几个原因: / p>

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


  1. 注册设备的API会返回代表该设备的令牌。从我可以看到,GCM不保证令牌将无限期保持有效。因此注册失败可能导致您的设备令牌过期。

  1. 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.

这篇关于每次应用程序启动时,在GCM上注册设备是正确的方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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