react-native-push-notification / ios

React Native Push Notification API for iOS.
MIT License
748 stars 285 forks source link

Deep linking with a local notification #200

Closed joebernard closed 4 years ago

joebernard commented 4 years ago

Is it possible to specify a deep link within a local notification scheduled with scheduleLocalNotification?

When the user taps my local notification, I'd like it to use a custom URL that is handled by my router. I have this working with universal links in iOS and remote push notifications but don't see a way to specify URLs with this API for local push notifications.

Naturalclar commented 4 years ago

You can add an event listener for your app so that when user performs an specific action, you would link them to certain page.

  useEffect(() => {
    PushNotificationIOS.addEventListener('notification', onRemoteNotification);
  });

  const onRemoteNotification = (notification) => {
    const actionIdentifier = notification.getActionIdentifier();

    if (actionIdentifier === 'open') {
      // Perform routing based on action
      routeToPage()
    }
  };