我正在使用react-native和aws-amplify。当应用程序被终止或未运行时,我无法获取推送通知数据。当应用程序处于运行状态时,我正在获取推送通知数据背景或前景。
componentDidMount() {
PushNotification.onNotification((notification) => {
console.log('in app notification', notification);
notification.finish(PushNotificationIOS.FetchResult.NoData);
});
// get the registration token
PushNotification.onRegister((token) => {
console.log('in app registration', token);
});
// get the notification data when notification is opened
PushNotification.onNotificationOpened((notification) => {
console.log('the notification is opened', notification);
});
}