android - Cordova 的 device.uuid 值可以用于发送 Firebase 推送通知吗?

标签 android ios firebase cordova firebase-cloud-messaging

我正在尝试使用 cordova 构建一个包装应用程序并使用 PHP 作为服务器后端。

我正在使用 cordova-plugin-fcm 来处理推送通知。

如果我错了,请纠正我,每个设备(android 和 ios)都有自己的 id,用于发送通知。

如何获取该 ID 并将其发送到 PHP 路由,以便我可以将其与登录用户绑定(bind)并发送通知?

//FCMPlugin.onTokenRefresh( onTokenRefreshCallback(token) );
//Note that this callback will be fired everytime a new token is generated, including the first time.
FCMPlugin.onTokenRefresh(function(token){
    alert( token );
});

在上面的示例中,token 是要发送到 PHP 以发送通知的 id?

device.uuid可以用于发送通知吗?

我已经设置了 Firebase 配置,并且项目已设置 google-services.jsonGoogleService-Info.plist

谢谢

最佳答案

Firebase Cloud Messaging 将其消息定位到特定设备上的特定应用。每个特定的应用安装均由 Firebase 的实例 ID 进行标识,也称为设备注册 token 或 FCM token 。

Firebase 文档 accessing the registration token对此是这样说的:

On initial startup of your app, the FCM SDK generates a registration token for the client app instance. If you want to target single devices or create device groups, you'll need to access this token by extending FirebaseMessagingService and overriding onNewToken.

快速阅读 Cordova documentation on device.uuid ,这似乎只是识别设备,而不是设备上的应用程序。由于 FCM 消息传送到每个设备上的特定应用,因此您似乎不太可能使用设备的 UUID 作为替代。

即使 UUID 对于每台设备上的每个应用都是唯一的,它也不会是直接替代品,因为 FCM 仅适用于其自己的注册 token 。至少您需要保留 device.uuid 值与其相应 FCM token 的映射。

关于android - Cordova 的 device.uuid 值可以用于发送 Firebase 推送通知吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57905825/

相关文章:

android - 如何在一个 Activity 中停止音乐并在下一个 Activity 中开始另一音乐?

ios - 有什么方法可以在 appdelegate 中为项目中的所有 UIImage 属性使用 `UIImageRenderingModeAlwaysOriginal`

ios - Swift - 在 VC 中登录,允许任何人输入而不验证用户名和密码匹配或保存

java - 使用 Wi-Fi 将我的本地 PC 连接到 ANDROID 设备

android - 移除 EditText 的焦点边框

android - 如何在 Android 中正确使用外键,使用 SQLite 和 OrmLite

ios - 如何使用顶级布局指南设置布局约束?

ios - NSURLSession 后台下载不工作

firebase - Vue.js:带有来自身份验证的 firebase 日期的 vue-moment 的控制台警告 - 更新日期

android - Firebase 分析和同意对话框