Hi All. This is my App.js
import React from 'react';
import { AppState, View, StatusBar } from 'react-native';
import { ScreenHost } from './src/app/screen-host';
import { AppHost } from './src/debug/app-host';
import { settings } from './src/constants/settings';
import { services } from './src/services/services';
import {
Notifications,
} from 'expo';
export default class App extends React.Component {
state = {
notification: {},
};
componentDidMount() {
// Handle notifications that are received or selected while the app
// is open. If the app was closed and then opened by tapping the
// notification (rather than just tapping the app icon to open it),
// this function will fire on the next tick after the app starts
// with the notification data.
this._notificationSubscription = Notifications.addListener(this._handleNotification);
}
_handleNotification = (notification) => {
this.setState({notification: notification});
alert(notification.data.conv_id);
};
render() {
if (settings.useDebugLayout) {
return (
<AppHost>
<AppMain />
</AppHost>
);
} else {
return (
<AppMain />
);
}
}
}
class AppMain extends React.Component {
render() {
return (
<View style={{ flex: 1 }}>
<StatusBar barStyle="light-content" />
<ScreenHost />
</View>
);
}
}
This is working fine when the APP is in foreground or when APP is minimized, but when app is closed, and the notification comes, it shows the loading screen and the push notification data is lost. I am using
"expo": "^27.0.0",
"moment": "^2.22.2",
"react": "16.3.1",
"react-moment": "^0.7.0",
"moment-timezone": "^0.5.17",
"react-native": "https://github.com/expo/react-native/archive/sdk-27.0.0.tar.gz",
"react-native-swipeable": "^0.6.0",
"react-navigation": "1.5.11"