【问题标题】:How to launch specific screen on tap of local notification in react native如何在本地通知中点击本地通知启动特定屏幕
【发布时间】:2021-03-31 11:09:29
【问题描述】:

我目前在 react-native 中使用 this 库来安排本地通知,当我从通知中心或应用程序顶部点击通知时,我想将用户重定向到特定屏幕。目前 react-native-push-notification 库使用已弃用的旧 UILocalNotification 类。

下面是我配置本地通知的代码。

onNotification 是当用户从 iOS 的通知中心启动应用时触发的回调方法,类似地 onAction 适用于 Android。

/**
 * To configure for local notifications
*/
 export function localNotificationConfigure() {
   PushNotification.configure({
   onNotification: async function (notification) {
     console.log('notification.data', notification.userInteraction);
    notification.finish(PushNotificationIOS.FetchResult.NoData);
   },
  onAction: async function (notification) {
    console.log('notification', notification.userInteraction);
   },
  permissions: {
   alert: true,
   badge: true,
   sound: true,
  },
  popInitialNotification: true,
   requestPermissions: Platform.OS === 'ios',
  });
 }

有什么方法可以实现这一点。是否因为使用 UILocalNotification 的 lib 已被弃用,我无法在代码中恢复操作。任何帮助表示赞赏。

【问题讨论】:

    标签: android ios react-native uilocalnotification react-native-push-notification


    【解决方案1】:

    这个link 帮助我实现了我想要的功能。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-09-10
      • 1970-01-01
      • 2020-02-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-09-14
      相关资源
      最近更新 更多