customerio / customerio-expo-plugin

MIT License
12 stars 9 forks source link

Deeplink not working when the app is running #150

Open umangloria opened 1 week ago

umangloria commented 1 week ago

The issue: Deeplink/Universal Link is not working from push notifications if the app is not in killed state.

What is working: UniversalLink/Deeplink is working fine when the app is in killed state. that is when the app is not in running state and if user tap on the notification, it is opening the app and navigating the user to the respective screen.

Expected behaviour: Taping on push notification should open the app and move user to the respective screen according to the url when the app is opened and when the app is closed.

Configuration: this is what we have currently in app.config.js inside plugins:

[
      'customerio-expo-plugin',
      {
        android: {
          googleServicesFile: isProduction
            ? './google-services.json'
            : './googleService/staging/google-services.json',
        },
        ios: {
          useFrameworks: 'static',
          handleDeeplinkInKilledState: true,
          showPushAppInForeground: true,
          pushNotification: {
            useRichPush: true,
            env: {
              siteId: XXX',
              apiKey: 'XXX',
              region: 'US',
            },
          },
        },
      },
    ]

versions:

 "customerio-expo-plugin": "^1.0.0-beta.15",
    "customerio-reactnative": "^3.7.1",
    "expo": "^51.0.37",
ami-aman commented 1 week ago

Hi @umangloria

I am sorry to hear that you’re facing issues.

Could you please confirm if:

Regarding deep links, they can be set up directly from your JS/TS code. When configured properly, the deep links should be handled by your navigation library itself, such as @react-navigation. The showPushAppInForeground configuration provides a workaround to handle deep links when the app is in a killed state, which is due to lifecycle differences.

However, in most cases, your navigation library should be able to manage the deep link navigation based on the configurations you have set.

Please feel free to reach out if you have any other questions.

umangloria commented 1 week ago

Hi @ami-aman , Here are the things which is what could help with the issue, Also, I only tried this issue in iOS, I am not sure about android though:

  1. React-navigation configurations is perfectly fine as the navigation works perfectly fine when clicking on the url from other apps and taping on the push notification when the app is in killed state so that ensures that our linking setup with react-navigation is proper.
  2. showPushAppInForeground is already true as you can see in the above snippet. and it is only responsible to display push notifications when the app is not in killed state.
  3. https://docs.customer.io/sdk/expo/getting-started/#configure-the-plugin Here we have property ios.handleDeeplinkInKilledState which enables the notification deeplink handling when the app is in killed state but there is no property like handleDeeplinkInActiveState which should enable deeplink handing from push notifications when the app is not in killed state!!
  4. We are not using expo-notifications or any other package that can result in conflict to handle the push notifications, Is it the correct approach or we do need expo-notifications to handle push notification deep links when the app is in FG.?
ami-aman commented 1 week ago

Thanks for your response, @umangloria ! Appreciate it !

To clarify, the configuration showPushAppInForeground, when set to true, handles push notifications sent by Customer.io and ensures they are shown when the app is in the foreground. It’s unrelated to handling deep links in a killed state.

You’re correct in saying that ios.handleDeeplinkInKilledState is responsible for handling push notifications with deep links when the app is in a killed state. We do not have a property to handle deep links in an active state, as that’s managed by app's navigation handler. Also, using expo-notifications depends on your app's requirements and is not required for handling deep links when the app is in the foreground or killed state.

I appreciate you sharing the configurations you’ve set in app.config.js. To help us assist you further, we recommend sharing a code snippet with your navigation logic. Please ensure you remove any sensitive information like siteId or keys before sharing. You can also send the code directly to win@customer.io and reference this issue so our team can connect internally.

umangloria commented 1 week ago

@ami-aman , Sent you the linking configuration code in the mail, However I think that the issue might be when the app is active and user get's the push, that PN is visible to user after we added this flag: showPushAppInForeground Similarly, I think that to send the URL from the PN I think that there should be some code added from Customer.io side ? I am not sure but just thinking about possible solutions,

ami-aman commented 1 week ago

Thank you, @umangloria, for sharing the details. Our team will review it and get back to you with an update on this issue.

umangloria commented 5 days ago

@ami-aman Any update on the same ?