【发布时间】:2019-12-08 05:36:39
【问题描述】:
我已经安装了react-native-firebase v6.2,但是现在我找不到一个很好的帮助来实现云消息传递。
谁能帮助如何在没有通知模块的情况下使用云消息传递?
由于通知模块已从 v6 中删除,我决定只使用云消息传递,但我不知道该怎么做。
远程通知的权限和请求正常。 这是我发送给自己的代码,但它不适用于 android,请提供任何帮助
const sendNotification = async ()=> {
try {
const firebaseAPIKey = "QEOEKDjjIS1E6ZDKSKJXAxdkIGk3qTb4FXCMs";
const notifyMessage = {
registration_ids: ["fheeeEaBwK0HM:eoOELDL6BUEdNUhRvJsjBv3x9dPLybZqqBoqJ_wzcE5_pbl-e1nnIsLhbzJd5-_R4MNhVYtuCLXWjWSguLfKTOqXR0gEfhgukdIw-AexChDjy8tI6u7f04i5xtOkaAJgU"],
notification: {
"title": "Muhammad Wafa",
"body": "Hi dear this is a simple message.",
"vibrate": 1,
"sound": 1,
"show_in_foreground": true,
"priority": "high",
"content_available": true
}
}
let headers = new Headers({
"Content-Type": "application/json",
"Authorization": `key=${firebaseAPIKey}`
});
let response = await fetch("https://fcm.googleapis.com/fcm/send", {method: "POST", headers, body: JSON.stringify(notifyMessage)});
console.log('response', response);
} catch (err) {
console.log('Error in : sendNotification', err);
}
}
【问题讨论】:
-
你找到解决办法了吗?
标签: javascript firebase react-native firebase-cloud-messaging react-native-firebase