0

I'm working on and iOS and Android application with react-native and Amplify. The entire setup for push notifications is done. I can send a campaign to all or to a specific device - and I receive the notifications on both iOS and Android.

Also, I have deep linking enabled in my application. On iOS, I can type a url with my custom scheme and it will ask me to open it in the app and navigate to the correct route. On Android, I use adb shell am start -a android.intent.action.VIEW -d "*://*/do-something" com.* (dummy); also works.

However, when I send a Direct Message in Pinpoint using a deep link, all it does is open the app and the deep link is not openend (https://i.stack.imgur.com/JxPn1.png). Even using Go to url, the app is openend and not the url I specified. The data from Pinpoint however is received (https://i.stack.imgur.com/qg4py.png)


I use the following packages:

@aws-amplify/pushnotification": "^1.0.8",
"aws-amplify": "^1.0.10",
"react-native": "0.56.0",

What is the setup that is required to make sure the actions from my notification are being processed in my application? I can't seem to find any documentation on Pinpoint actions and react-native.

sndr
  • 1
  • 3

1 Answers1

0

UPDATE: on android you can access the data via notification.data['pinpoint.url'] so just data is an object and the keys are using dots. Weird solution.

ORIGINAL ANSWER:

had the same issue an hour after you posted it.

There is an onNotification method on the PushNotification library of amplify. It triggers when a notification arrives. On iOS is the notification of type PushNotificationIOS and on Android a normal object (not sure here still investigating).

On iOS you can access the data via notification.getData().data.pinpoint

sample code:

    PushNotification.onNotification((notification) => {
        if (Platform.OS === 'ios') {
          if (notification.getData().data.pinpoint.deeplink) {
            alert(notification.getData().data.pinpoint.deeplink);
          }
          notification.finish(PushNotificationIOS.FetchResult.NoData)
        } 
        else {
          if (notification.data && notification.data['pinpoint.deeplink']) {
            alert(notification.data['pinpoint.deeplink']);
          }
        }
    }

remember to import all necessary stuff.

Hopefully this helps.

Cheers,

Ben

  • That method is always triggered when a notification arrives, even when the app is running in the background. I only want the deeplink to be triggered when you _open_ the notification, not when it arrives. I tried using the `onNotification` method and used `Linking. openURL(deeplink)` (dummy code), but when I send the notification in Pinpoint, the app does open (when the notification is received) and goes to the page. So, I'm still confused and looking for the handler when you "open" or "click on" the notification, not when you're only just receiving one. – sndr Sep 21 '18 at 07:11