Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import React, { Component } from "react";
- import OneSignal from 'react-native-onesignal';
- import NavigationService from './utils/NavigationService';
- import Routes from "./routes";
- import "./Config/ReactotronConfig";
- console.disableYellowBox = true;
- class App extends Component {
- constructor(props) {
- super(props);
- OneSignal.init('312312321321-213123-4d96-b473-756ytrgh567');
- OneSignal.addEventListener('received', this.onReceived);
- OneSignal.addEventListener('opened', this.onOpened);
- OneSignal.addEventListener('ids', this.onIds);
- OneSignal.inFocusDisplaying(2);
- OneSignal.requestPermissions({
- alert: true,
- badge: true,
- sound: true
- });
- }
- componentWillUnmount() {
- this.isUnmounted = true;
- OneSignal.removeEventListener('received', this.onReceived);
- OneSignal.removeEventListener('opened', this.onOpened);
- OneSignal.removeEventListener('ids', this.onIds);
- }
- onReceived(notification) {
- console.log("Notification received: ", notification);
- }
- onOpened = (openResult) => { // AQUI QUERO NAVEGAR PARA OUTRA TELA EM VEZ DA TELA INICIAL
- this.isNotification = true;
- let data = openResult.notification.payload.additionalData;
- // ScreenName é o nome da tela que você definiu no StackNavigator
- // this.props.navigation.navigate('ScreenName', data);
- NavigationService.navigate('ScreenName', data);
- }
- onRegistered(notifData) {
- console.log("O dispositivo foi registrado para notificações push!", notifData);
- }
- onIds(device) {
- try {
- AsyncStorage.setItem("@SC:deviceInfo", JSON.stringify(device));
- } catch (error) {
- console.log(error);
- }
- }
- render(){
- return(
- <Routes ref={navigatorRef => {
- NavigationService.setTopLevelNavigator(navigatorRef);
- }} />
- );
- }
- }
- export default App;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement