多个 FCM 发件人:以编程方式在移动应用程序上加载发件人 ID 和服务器密钥
Multiple FCM Senders: Programmatically load Sender ID and Server Key on Mobile App
-
apple-push-notifications
-
firebase
-
google-cloud-messaging
-
google-play-services
-
firebase-cloud-messaging
作为我们解决方案的一部分,我们在每个客户站点部署了一个 FCM "app server"。每个客户站点都需要生成自己的发件人 ID 和服务器 ID 以用于我们的应用程序。
默认的 FCM 实现将发件人 ID 和服务器密钥放在一个 plist (iOS) / json (Android) 中,它在编译时集成到应用程序代码中.然而,由于我们有多个当前客户并且将有新客户,我们的移动应用程序需要能够对客户应用程序服务器进行服务调用,检索发件人 ID 和服务器密钥,并在运行时将它们加载到 FCM。
我们看过一些关于getToken的文档来完成向多个发件人注册,但我们只需要向1个发件人注册并完全绕过plist/json。
问题:我们如何以编程方式加载发件人 ID 和服务器密钥而不是使用 GoogleService-Info.plist (iOS) / google -services.json (Android).
有关更多上下文,这是我们最近针对同一工作流程的相关 。
places the Sender ID and Server Key in a plist (iOS) / json (Android) which is integrated into the app code at compile-time
您的客户端应用程序中没有任何地方包含服务器密钥。顾名思义,Server Key 保存在 App Server 端。您从 Firebase 控制台获得的 json/plist 文件中包含的唯一发件人 ID 是您项目的发件人 ID。 FCM 不使用 google-services.json 文件中的任何类型的 API 密钥(请参阅我的回答 )。
How can we programmatically load Sender ID and Server Key instead of using GoogleService-Info.plist (iOS) / google-services.json (Android).
注册新服务器时,您只需要发件人ID。然后只需调用 getToken(authorizedEntity, scope)
。这可能是可能的,通过实现一个函数,该函数从您的应用程序服务器端获取有效发件人列表,然后在客户端有一个副本,如果包含一个新的发件人,请让您的应用程序 authorize 它是一个有效的发件人。
apple-push-notifications
firebase
google-cloud-messaging
google-play-services
firebase-cloud-messaging
作为我们解决方案的一部分,我们在每个客户站点部署了一个 FCM "app server"。每个客户站点都需要生成自己的发件人 ID 和服务器 ID 以用于我们的应用程序。
默认的 FCM 实现将发件人 ID 和服务器密钥放在一个 plist (iOS) / json (Android) 中,它在编译时集成到应用程序代码中.然而,由于我们有多个当前客户并且将有新客户,我们的移动应用程序需要能够对客户应用程序服务器进行服务调用,检索发件人 ID 和服务器密钥,并在运行时将它们加载到 FCM。
我们看过一些关于getToken的文档来完成向多个发件人注册,但我们只需要向1个发件人注册并完全绕过plist/json。
问题:我们如何以编程方式加载发件人 ID 和服务器密钥而不是使用 GoogleService-Info.plist (iOS) / google -services.json (Android).
有关更多上下文,这是我们最近针对同一工作流程的相关
places the Sender ID and Server Key in a plist (iOS) / json (Android) which is integrated into the app code at compile-time
您的客户端应用程序中没有任何地方包含服务器密钥。顾名思义,Server Key 保存在 App Server 端。您从 Firebase 控制台获得的 json/plist 文件中包含的唯一发件人 ID 是您项目的发件人 ID。 FCM 不使用 google-services.json 文件中的任何类型的 API 密钥(请参阅我的回答
How can we programmatically load Sender ID and Server Key instead of using GoogleService-Info.plist (iOS) / google-services.json (Android).
注册新服务器时,您只需要发件人ID。然后只需调用 getToken(authorizedEntity, scope)
。这可能是可能的,通过实现一个函数,该函数从您的应用程序服务器端获取有效发件人列表,然后在客户端有一个副本,如果包含一个新的发件人,请让您的应用程序 authorize 它是一个有效的发件人。