react本机firebase-Xcode iOS发布版本与调试版本不一样
我有一个React原生应用程序,它使用React原生firebase在应用程序处于后台时显示通知。由于当应用程序位于后台时,我似乎无法让Redux操作分派,因此我将通知信息(即当应用程序位于前台时,我需要获取的资源id)存储在一个名为react本机firebase-Xcode iOS发布版本与调试版本不一样,xcode,firebase,react-native,react-native-firebase,Xcode,Firebase,React Native,React Native Firebase,我有一个React原生应用程序,它使用React原生firebase在应用程序处于后台时显示通知。由于当应用程序位于后台时,我似乎无法让Redux操作分派,因此我将通知信息(即当应用程序位于前台时,我需要获取的资源id)存储在一个名为NotificationStopProcess的数组中。然后,我使用AppState确定应用程序是否在前台,如果在前台,则处理notificationsToProcess数组中的项目,即调度redux操作以从API获取数据并更新应用程序中的redux存储 现在,问题
NotificationStopProcess
的数组中。然后,我使用AppState
确定应用程序是否在前台,如果在前台,则处理notificationsToProcess
数组中的项目,即调度redux操作以从API获取数据并更新应用程序中的redux存储
现在,问题是,在XCode中,当我使用'Debug'的构建配置并将其推送到我的iPhone上时,这段代码工作正常-接收并显示通知,启动onnotificationdisplated
事件侦听器,更新notificationsToProcess
数组-然后当应用程序位于前台时,行动已经完成,一切都很好。但是,当我在Xcode中更改模式以使用“Release”的构建配置时,Firebase侦听器不再工作。我是否需要为firebase通知侦听器设置其他内容,以便在iOS设备上的Xcode中使用“发布”构建配置
以下是我的代码中的相关片段:
class InitFirebaseListeners extends React.Component {
notificationsToProcess = [];
state = {
appState: AppState.currentState,
}
componentWillMount() {
AppState.addEventListener('change', this.handleAppStateChange);
this.startFirebaseListeners();
}
handleAppStateChange = (nextAppState) => {
const { appState } = this.state;
if (
appState.match(/inactive|background/)
&& nextAppState === 'active'
) {
const { myReduxAction } = this.props;
while (let msgId = this.notificationsToProcess.shift()) {
myReduxAction(msgId);
}
}
this.setState({ appState: nextAppState });
};
startFirebaseListeners = async () => {
this.notificationDisplayedListener = firebase.notifications().onNotificationDisplayed((notification) => {
const { _data: { type, message: messageId } } = notification;
this.notificationsToProcess.push(messageId);
});
}
render() {
return null;
}
}
我几乎有同样的问题。。。问题是我将React-Native更新为最新版本,但我的React-Native fireabse是v.4.x.x。更新到v.5.x.x后,修复了我的问题:)我几乎遇到了同样的问题。。。问题是我将React-Native更新为最新版本,但我的React-Native fireabse是v.4.x.x。更新到v.5.x.x后,修复了我的问题:)