我正在尝试使用音频视频通话功能制作一个应用程序。我使用了React-native-callkeep来通知接收者有关通话的信息。通话流程如下:当呼叫者点击呼叫启动按钮时,接收者将收到FCM推送通知,其中包含加入房间的数据
我想在接收器应用处于killed状态时唤醒接收器屏幕。为此,我使用react-native-callkeep。我调用displayIncomingCall()函数来唤醒屏幕,当应用处于killed状态时,它在IOS中工作正常,但在Android中不工作。
//function to call the incoming call screen
export const Display = async (uuid, handle, localizedCallerName) => {
RNCallKeep.displayIncomingCall(uuid, handle, localizedCallerName);
};
// inside index.js
messaging().setBackgroundMessageHandler(async (data) => {
if (data.data?.description == "audio" || data.data?.description == "video") {
Platform.OS == "android"
? Display(
"11edc52b-2918-4d71-9058-f7285e29d894",
"Shadowz Calling",
data?.data?.sent_by_name
)
: Display(
"11edc52b-2918-4d71-9058-f7285e29d894",
"Shadowz Calling",
data?.data?.sent_by_name,
"number",
"false"
);
}
});
1条答案
按热度按时间wwodge7n1#
触发
BackgroundMessageHandler
需要发送data typefirebase通知,不能通过firebase控制台发送,需要向https://fcm.googleapis.com/fcm/send
API发送POST请求,示例代码如下。你也可以用postman来测试。
阅读更多关于FCM通知类型-https://www.javatpoint.com/firebase-types-of-message