将FCM令牌链接到设备的最佳方法? [英] Best way to link a FCM token to a device?

查看:168
本文介绍了将FCM令牌链接到设备的最佳方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在制作一台服务器,根据发生的情况(温度和/或湿度变化,门打开等等),使用FCM向客户端发送消息。但是,如果令牌可以改变,我怎么能跟踪设备发送消息到正确的(使用登录系统的W / O)?

我想把数据库中的标记链接到sim iccid,这是正确的吗?

启动Android O, ANDROID_ID 现在将会是设备中每个用户的每个应用不同原始答案:

如果您正在寻找可持续使用的 可以使用 ANDROID_ID


字符串ANDROID_ID



64位数字(作为十六进制字符串)在用户首次设置设备时随机生成,并且在用户设备的整个生命周期内保持不变。如果在设备上执行了工厂重置,则该值可能会发生变化。

lockquote

注意:当设备具有多个用户(在运行Android 4.2或更高版本的某些设备上可用),每个用户显示为完全独立的设备,因此 ANDROID_ID 值对每个用户都是唯一的。

常量值:android_id


然而,仍然有一些因素需要考虑,取决于您的使用情况。我建议您阅读唯一标识符的最佳实践文档。

FCM明智的是,它通常与用户相关联,因此通常与用户详细信息配对。


I'm making a server that sends messages using FCM to clients depending on what happens (temperature and/or humidity change, a door is opened, etc.).

But if the token can change, how can I keep track of the device to send messages to the correct one (w/o using a login system)?

I was thinking to link the token to the sim iccid in a database, is this correct?

解决方案

Update 05/18/2017:

Starting Android O, ANDROID_ID will now be different per app per user in the device.


Original Answer:

If you're looking for a long lasting (possibly permanent) ID that you can use, I guess you can make use of ANDROID_ID:

String ANDROID_ID

A 64-bit number (as a hex string) that is randomly generated when the user first sets up the device and should remain constant for the lifetime of the user's device. The value may change if a factory reset is performed on the device.

Note: When a device has multiple users (available on certain devices running Android 4.2 or higher), each user appears as a completely separate device, so the ANDROID_ID value is unique to each user.

Constant Value: "android_id"

However, there are still some factors that you should consider depending on your use-case. I recommend going through the Best Practices for Unique Identifiers documentation.

FCM wise, it is usually associated with a user, hence it is commonly paired with the user details.

这篇关于将FCM令牌链接到设备的最佳方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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