【发布时间】:2021-08-27 19:32:08
【问题描述】:
我正在使用react-native-firebase 库。
在 iOS 上,我可以在前台、后台以及应用程序处于退出状态时接收通知。处理程序也适用于所有场景,除了一个。
我唯一的问题是:当应用程序处于退出状态时,setBackgroundMessageHandler 没有被调用,即使我收到了通知。我也尝试发送纯数据消息,但结果是一样的。
我什至可以在消息的 apns 部分中使用 content-available: 1 在无头状态下调用应用程序。
但是setBackgroundMessageHandler 仍然没有被调用。这是我的index.js 页面:
messaging().setBackgroundMessageHandler(async remoteMessage => {
console.log('HEADLESS BACKGROUND: ' + ' | ' + JSON.stringify(remoteMessage));
});
function HeadlessCheck({ isHeadless }) {
if (isHeadless) {
console.log("Headless");
// App has been launched in the background by iOS, ignore
return null;
}
return <App />;
}
AppRegistry.registerComponent(appName, () => HeadlessCheck);
【问题讨论】:
标签: firebase react-native firebase-cloud-messaging react-native-ios react-native-firebase