Firebase 云消息传递无服务器密钥

Firebase Cloud Messaging No Server Key

我已从 Firebase 中导入的 Google 项目中删除名为 "Server key (auto created by Google Service)" 的 api 密钥。

现在项目设置-云消息中的现场服务器键为空。我也无法发送通知,我从服务器收到未经授权的 401 错误。

我能做什么?

尝试替换:

con.setRequestProperty("Authorization: key", "<YOUR API KEY>");

与:

con.setRequestProperty("Authorization", "key=<YOUR API KEY>");

我已经解决了! Google 支持人员给我写了一个解决此问题的方法。

1) 在您的 Firebase 项目中创建示例 Android 应用程序。 2) 下载 google-services.json 3) 回到你的 Firebase Project Settings > Cloud Messaging 选项卡,刷新页面,然后你应该能够在那里看到你的服务器密钥。

完成此步骤后,您可以删除创建的 Android 应用程序。密钥在云消息选项卡中可见。