React native 在React Native中放置推送通知组件的位置
我正在用React Native制作简单的新闻通知应用程序。当出现特定条件消息时,它只向用户发送推送通知 我首先制作了UI和基本功能。因此,有一些组件可以登录、注册和添加条件组件等,并且运行良好 最后,我想对我的应用程序应用React native 在React Native中放置推送通知组件的位置,react-native,push-notification,react-native-router-flux,React Native,Push Notification,React Native Router Flux,我正在用React Native制作简单的新闻通知应用程序。当出现特定条件消息时,它只向用户发送推送通知 我首先制作了UI和基本功能。因此,有一些组件可以登录、注册和添加条件组件等,并且运行良好 最后,我想对我的应用程序应用推送通知,因此我使用Firebase云消息(FCM)。幸运的是,它工作得很好。当我使用一些数据(密钥头、令牌等)请求post时,应用程序成功接收推送通知 但问题是,当我测试将通知推送到我的应用程序时,我只是遵循示例源代码。所以我不知道如何将它应用到我的exist应用程序中 该
推送通知
,因此我使用Firebase云消息(FCM)。幸运的是,它工作得很好。当我使用一些数据(密钥头、令牌等)请求post时,应用程序成功接收推送通知
但问题是,当我测试将通知推送到我的应用程序时,我只是遵循示例源代码。所以我不知道如何将它应用到我的exist应用程序中
该应用程序看起来像
export default class App extends Component {
render() {
return (
<Provider store={configureStore()}>
<MenuContext>
<Router>
<Scene key="root">
<Scene key="login" hideNavBar component={LoginComponent} initial/>
<Scene key="register" hideNavBar component={RegisterComponent}/>
<Scene key="resetPassword" hideNavBar component={ResetPasswordComponent}/>
<Scene key="main" tabs
tabBarStyle={{ top: 72, height: 76, backgroundColor: API.SECOND_COLOR, borderColor: API.BORDER_COLOR, borderBottomWidth: 1}}
tabBarSelectedItemStyle={{ marginBottom: -1, height: 76, borderBottomWidth: 4, borderBottomColor: API.FIRST_COLOR }}
>
<Scene key="newsConditionsList" title="First Tab" iconName="alarm" icon={TabIcon}>
<Scene key="scarlet" component={TabComponent1} hideNavBar initial/>
</Scene>
<Scene key="news" title="Second Tab" iconName="chat" icon={TabIcon}>
<Scene key="scarlet2" component={TabComponent2} hideNavBar initial/>
</Scene>
<Scene key="settings" title="Third Tab" iconName="settings" icon={TabIcon}>
<Scene key="scarlet3" component={TabComponent3} hideNavBar initial/>
</Scene>
</Scene>
<Scene key="addCondition" title="Add Todo" component={AddConditionComponent} hideNavBar/>
<Scene key="room" title="In Room" component={RoomComponent} hideNavBar/>
</Scene>
</Router>
</MenuContext>
</Provider>
);
}
}
无论您将PushController
组件放置在何处,只要它保持安装状态即可。事实上,您根本不需要特殊组件,但您可以拥有它:)
所以简单的答案可以放在你的应用程序中。例如
<View>
<PushController />
<Provider store={configureStore()}>
...
</Provider>
</View>
...
唯一重要的是,在应用程序启动时,通过FCM
调用执行设备的正确注册。但当我将它们放入视图时,它会显示空白屏幕。
<View>
<PushController />
<Provider store={configureStore()}>
...
</Provider>
</View>