多个FCM发件人:以编程方式在移动应用程序上加载发件人ID和服务器密钥 [英] Multiple FCM Senders: Programmatically load Sender ID and Server Key on Mobile App

本文介绍了多个FCM发件人:以编程方式在移动应用程序上加载发件人ID和服务器密钥的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

作为我们解决方案的一部分,我们在每个客户站点部署FCM应用服务器。每个客户站点都需要生成自己的发件人ID和服务器ID,以便与我们的应用程序一起使用。

默认的FCM实现将发件人ID和服务器密钥置于plist(iOS )/ json(Android),它在编译时集成到应用程序代码中。但是,由于我们有多个当前客户,并且会有新客户,我们的移动应用程序需要能够向客户应用程序服务器发出服务调用,检索发件人ID和服务器密钥,并在运行时将其加载到FCM中。



我们已经看到一些关于 getToken 来完成注册与多个发件人,但我们只需要注册1个发件人,完全绕过plist / json。
$ b

问题:我们如何以编程方式加载发件人ID和服务器密钥,而不是使用GoogleService-Info.plist(iOS)/ google- services.json(Android)。



更多的上下文,这里是我们最近的相关有关安全性的问题


您的客户端应用程序中没有包含服务器密钥的地方。就像名字所暗示的那样,服务器密钥保存在应用服务器端。从Firebase控制台获取的json / plist文件中包含的唯一发件人ID是项目的发件人ID。 FCM不使用google-services.json文件中的任何类型的API密钥(请参阅我的答案此处) 。
$ b


我们如何以编程方式加载发件人ID和服务器密钥,而不是使用GoogleService-Info.plist(iOS)/ google- services.json(Android)。


注册一个新的服务器时,您只需要发件人ID。然后简单地调用 getToken(authorizedEntity,scope)。这是可能的,通过实现一个函数,从你的应用服务器端获得一个有效的发送者列表,然后在客户端有一个副本,如果有一个新的发送者包括,让你的应用授权它是一个有效的发件人。


As part of our solution, we deploy an FCM "app server" at each of our customer sites. Each customer site need to generate their own sender id and server id for use with our app.

The default FCM implementation places the Sender ID and Server Key in a plist (iOS) / json (Android) which is integrated into the app code at compile-time. However since we have multiple current customers and will have new customers, our mobile app needs to be able to make a service call to the customer App Server, retrieve the Sender ID and Server Key, and load those into FCM at runtime.

We've seen some documentation around getToken to accomplish registering with multiple senders, but we only need to register with 1 sender and completely bypass the plist/json.

Question: How can we programmatically load Sender ID and Server Key instead of using GoogleService-Info.plist (iOS) / google-services.json (Android).

For more context, here is our recent related question about security for the same workflow.

解决方案

places the Sender ID and Server Key in a plist (iOS) / json (Android) which is integrated into the app code at compile-time

There is nowhere in your client app that the Server Key is included. Like the name implies, the Server Key is kept on the App Server side. The only Sender ID that is included in the json/plist file you get from the Firebase Console is the Sender ID for your project. FCM doesn't use any kind of API key that is in the google-services.json file (see my answer here).

How can we programmatically load Sender ID and Server Key instead of using GoogleService-Info.plist (iOS) / google-services.json (Android).

When registering a new server, you would only need the Sender ID. Then simply call getToken(authorizedEntity, scope). This could be possible, by implementing a function that gets a list of valid senders from your App Server side and then have a copy on the client side, if there is a new Sender included, have your app authorize it as a valid sender.

这篇关于多个FCM发件人:以编程方式在移动应用程序上加载发件人ID和服务器密钥的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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