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

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

问题描述

我正在开发一个 phonegap 应用程序并遵循了这个 实现 PushPlugin 的教程.但是,它说每次触发 deviceready 事件时都要注册应用程序.这意味着它会在 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?

推荐答案

在我们的应用程序中,我们发现这是一个很好的做法,原因如下:

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天全站免登陆