简体   繁体   English

具有多个帐户的Android应用的GCM注册ID的唯一性是什么?

[英]How unique is a GCM registration ID for an Android app with multiple accounts?

Let's say, for example, a device has an app with 2 accounts signed in (a typical use case of having multiple gmail accounts on the same device) . 举例来说,假设某台设备的应用程序登录了2个帐户(典型的用例是,同一设备上有多个gmail帐户) Let's say we have a Personal account and a Work account. 假设我们有一个个人帐户和一个工作帐户。

When a user signs into the app, the app requests for a GCM registration ID from the GCM servers, and then the app sends this GCM registration ID to the App Servers. 当用户登录应用时,该应用会向GCM服务器请求GCM注册ID,然后该应用会将此GCM注册ID发送到App服务器。 The app server will store this GCM registration ID in its database. 应用服务器会将这个GCM注册ID存储在其数据库中。 This repeats every time someone signs into the app. 每当有人登录该应用程序时,都会重复此操作。

How uniquely will the GCM registration IDs be generated by the GCM servers? GCM服务器将如何唯一地生成GCM注册ID?

deviceA, appX, accountHome = regIdAX
deviceA, appX, accountWork = regIdAX

or 要么

deviceA, appX, accountHome = regIdAXHome
deviceA, appX, accountWork = regIdAXWork

The correct formula is 正确的公式是

deviceA, appX, regIdX(no matter how many accounts internally found)
deviceA, appY, regIdY
deviceB, appX, regIdX1

It's per device per app and not related to any app internal work. 它是每个应用程序的每个设备,与任何应用程序的内部工作无关。

A GCM ID is unique to one application running on one device. GCM ID对于在一台设备上运行的一个应用程序是唯一的。 It does not matter which user is signed into that application, if any. 哪个用户登录到该应用程序(如果有)无关紧要。

Similar questions/answers here: 这里有类似的问题/答案:

The regid (token) is 140 char long so i think it is pretty unique... I cant exacly tell how differ on same device different account as i have 2 device 2 account. regid(令牌)的长度为140个字符,所以我认为它非常独特...我无法确切地说出在同一设备上不同的帐户,因为我有2个设备2帐户。 I think the regid made by some hashing algoritm, because im registered/unregistered some times but always got the same regid on same device. 我认为某些哈希算法会产生regid,因为im有时已注册/未注册,但总是在同一设备上获得相同的regid。 A read somewhere that Google will invalidate the regid after 6 month. 6个月后,谷歌将使该注册无效。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM