gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-03 14:59:46 25 4
gpt4 key购买 nike

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

错误信息如下

Caused by: com.google.api.client.http.HttpResponseException: 400 Bad Request { "error": { "code": 400, "message": "Request contains an invalid argument.", "errors": [ { "message": "Request contains an invalid argument.", "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);

消息发送代码如下
// 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.
System.out.println("Successfully sent message: " + response);

我正在使用的 maven 依赖项如下
<dependency>
<groupId>com.google.firebase</groupId>
<artifactId>firebase-admin</artifactId>
<version>5.9.0</version>
</dependency>

那么有人可以帮助我吗?我做错了什么?

最佳答案

我怀疑你的 registrationToken格式无效。它应该是 152 个字符。

要确认这一点,请尝试使用 setTopic("test") 构建您的消息而不是 setToken(registrationToken) .

关于firebase 云消息传递请求包含无效参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49124441/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com