Я реализую push-уведомление с использованием response-native-firebase.Итак, я тестирую облачные сообщения.Я мог бы получить уведомление, когда экран выключен и в фоновом режиме.Но я не смог получить уведомление при запуске приложения.Есть ли проблемы в моем коде или мне нужно добавить код?
async createNotificationListeners() {
this.notificationListener = firebase.notifications.onNotification((notification) => {
const { title, body } = notification;
this.showAlert(title, body);
});
this.notificationOpenedListener = firebase.notifications().onNotificationOpened((notificationOpen) => {
const { title, body } = notificationOpen.notification;
this.showAlert(title, body);
});
const notificationOpen = await firebase.notifications().getInitialNotification();
if (notificationOpen) {
const { title, body } = notificationOpen.notification;
this.showAlert(title, body);
}
this.messageListener = firebase.messaging().onMessage((message) => {
//process data message
console.log(JSON.stringify(message));
});
}
componentWillUnmount() {
this.notificationListener();
this.notificationOpenedListener();
}