如何从Firebase获取所有设备令牌? [英] How to get all of device tokens from Firebase?

查看:274
本文介绍了如何从Firebase获取所有设备令牌?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从Firebase获取设备令牌(FCM注册令牌)?

我正在使用firebase和使用node.js的服务器制作移动应用程序。

我想从服务器发送推送通知消息,但我不知道如何获取设备令牌。


  1. 如何从外部服务器获取设备令牌?我现在正在使用Firebase管理软件SDK。


  2. 设备标记是否仅在应用程序连接到fcm服务器时生成?

  3. b $ b
  4. 当用户第一次运行应用程序并注册FCM服务器时,我应该将令牌保存到另一个数据库吗?


解决方案


1。如何从外部服务器获取设备令牌?现在我正在使用Firebase管理程序SDK。


目前没有任何API可以检索应用程序的所有注册令牌从服务器端。开发人员有责任将注册令牌发送并存储到从客户端应用程序生成的应用服务器中。


2。只有当应用程序连接到FCM服务器时才会生成设备标记 /firebase.google.com/docs/cloud-messaging/android/client#sample-registerrel =nofollow noreferrer> documentation 几乎涵盖了这一点(另见我的回答 $ b


在您的应用程序初次启动时,FCM SDK为客户端应用程序实例生成一个注册令牌。

它在技术上并没有连接到FCM服务器。它连接到FirebaseInstanceID服务(通过SDK),然后生成注册令牌。


3。我应该在用户第一次运行应用程序并注册FCM服务器时将令牌保存到另一个数据库吗?


1,你应该将它保存在可以轻松访问的地方发送消息。


How to get device tokens (FCM registration tokens) from Firebase?

I'm making mobile app using firebase and its server using node.js.

I want to send push notification message from server, but I don't know how to get devices token.

  1. How to get device tokens from external server? I'm using Firebase admin SDK now.

  2. Is the device token only generated when the app is connected fcm server?

  3. Should I save token to another database when user first run the app and register FCM server?

解决方案

1. How to get device tokens from external server? I'm using Firebase admin SDK now.

There is currently no API to retrieve all the Registration tokens for your app from the Server side. It's the developer's (you) responsibility to send and store the Registration token to your App Server, which is generated from the Client App side.

2. Is the device token only generated when the app is connected FCM server?

The documentation pretty much covered this (see also my answer here):

On initial startup of your app, the FCM SDK generates a registration token for the client app instance.

It doesn't technically get connected to the FCM Servers. It connects to the FirebaseInstanceID service (via the SDK), which in turn generates the Registration Token.

3. Should I save token to another database when user first run the app and register FCM server?

As I mentioned in #1, you should save it where you can easily access it to send a message.

这篇关于如何从Firebase获取所有设备令牌?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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