当应用被终止或未运行时,无法获取推送通知数据

时间:2019-05-06 11:48:44

标签: react-native push-notification aws-amplify

我正在使用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);
   });
 }

0 个答案:

没有答案