相关疑难解决方法(0)

firebase云消息传递请求包含无效参数

使用Firebase云消息管理员发送消息时出错API.

错误信息如下

引起:com.google.api.client.http.HttpResponseException:400 Bad Request {"error":{"code":400,"message":"Request包含无效参数.","errors":[{"消息":"请求包含无效参数.","domain":"global","reason":"badRequest"}],"status":"INVALID_ARGUMENT"}}

让我把我的管理配置放在这里..

FileInputStream serviceAccount = new FileInputStream("My service accout file.json");

FirebaseOptions options = new FirebaseOptions.Builder().setCredentials(GoogleCredentials.fromStream(serviceAccount))
                    .setDatabaseUrl("https://deliveryeat-1aa42.firebaseio.com").build();

FirebaseApp.initializeApp(options);
Run Code Online (Sandbox Code Playgroud)

消息发送代码如下

// This registration token comes from the client FCM SDKs.
String registrationToken = "YOUR_REGISTRATION_TOKEN";

// See documentation on defining a message payload.
Message message = Message.builder().putData("score", "850").putData("time", "2:45").setToken(registrationToken).build();

// Send a message to the device corresponding to the provided
// registration token.
String response = FirebaseMessaging.getInstance().sendAsync(message).get();
// Response is a message ID string. …
Run Code Online (Sandbox Code Playgroud)

firebase google-cloud-messaging firebase-cloud-messaging

8
推荐指数
4
解决办法
8892
查看次数

FCM - 使用 expo 向 iOS 设备发送通知(React native)

我无法向使用Expo.io创建的 iOS 应用程序发送推送通知。

没有关于如何做到这一点的明确文档,所以这里是我的试验和我所做的事情:

带有 APN 密钥的 firebase 项目

在以编程方式调用此端点之前,我尝试使用 POSTMAN 让它工作(就像我在 Android 上用了不到 1 小时所做的那样)

这就是我所说的:

方法:POST

网址: https: //fcm.googleapis.com/fcm/send

身体 :

{
  "to": "token (read about it at the end of the post",
  "priority": "high",
  "data": {
    "experienceId": "@expoAccount/projectSlug",
    "title": "Hello there",
    "message": "General kenobi",
    "content_available": true
  },
    "content_available": true
}
Run Code Online (Sandbox Code Playgroud)

我已经测试了很多不同的身体结构(带/不带“content_available”键或带“通知”对象......因为所有身体结构都与 迄今为止读过的所有 问题 或文档不同 …

push-notification ios firebase-cloud-messaging expo

5
推荐指数
1
解决办法
7371
查看次数