我们使用Urban Airship将推送消息发送到我们的 Android 应用程序。
在此过程中,我们需要使用Firebase Console -> Cloud Messaging中提供的“服务器密钥”来配置Airship。
正如那里所建议的,我们正在尝试从 GCM 迁移到 FCM。
问题是“ Firebase Cloud Messaging API (V1) ”配置中缺少“服务器密钥” 。它在“ Cloud Messaging API(旧版) ”配置中仍然可用,但建议迁移。
按照 FCM 配置中的链接对解决此问题没有太大帮助。
android ios firebase google-cloud-messaging google-cloud-platform
我正在尝试通过Postman使用Firebase Cloud Messaging发送测试通知。我正在对此网址进行POST
https://fcm.googleapis.com/v1/projects/[my project name]/messages:send
Run Code Online (Sandbox Code Playgroud)
邮递员中的“授权”选项卡设置为“无身份验证”,“我的标题”选项卡如下所示
Content-Type: application/json
Authorization: Bearer [server key]
Run Code Online (Sandbox Code Playgroud)
[服务器密钥]是Firebase项目“设置”区域中“云消息”标签中的新生成的服务器密钥。我不断收到此错误作为回应。
"error": {
"code": 401,
"message": "Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.",
"status": "UNAUTHENTICATED"
}
Run Code Online (Sandbox Code Playgroud)
根据我能找到的所有信息,我使用了正确的令牌,但Google似乎不同意。我应该发送什么作为Authorization标头来克服此错误?