Iterable / react-native-sdk

MIT License
36 stars 32 forks source link

IOS push notification url handler doesn't work when app is opened both the foreground and background #490

Closed k3nlu closed 1 year ago

k3nlu commented 1 year ago

Hello,

Deep linking with push notifications works fine when the app is closed. However, when the app is open and is in the foreground or background deep linking with push notifications doesn't work. It seems like the config.urlHandler doesn't work when the app is opened.

I'm currently using version 1.3.12 of the sdk and noticed on IOS.

Ayyanchira commented 1 year ago

Hi @k3nlu , were you able to find a fix? we are currently investigating urlHandler, customAction handler and deeplinking issues we have been getting for quite some time now. Is this issue no more relevant?

1280103995 commented 7 months ago

Hi @k3nlu , were you able to find a fix? we are currently investigating urlHandler, customAction handler and deeplinking issues we have been getting for quite some time now. Is this issue no more relevant?

Hi Ayyanchira, any update? In the morning of June 2021, when I first integrated iterable, deep links were working normally.

The version I'm currently using is:

"@iterable/react-native-sdk": "1.3.17",
"react-native": "0.71.17",

Now, i have consulted the documentation no less than 5 times, and now on both iOS and Android, deep linking is not working.

Ayyanchira commented 7 months ago

Hi @1280103995 ,

Can you provide more details of the implementation:

  1. How are the deep links are configured? A code snippet will be helpful.
  2. How is IterableConfig used and passed to IterableApi?
  3. urlHandler and customActionHandler not working - persists just for push notification? Or is it also affecting other deeplink situations like InApp clicks?
  4. Is/Are there other marketing SDKs installed that could potentially interface the notifications?

If you are willing to share photo or video of the problem, that can also help.

1280103995 commented 7 months ago

Hi @1280103995 ,

Can you provide more details of the implementation:

  1. How are the deep links are configured? A code snippet will be helpful.
  2. How is IterableConfig used and passed to IterableApi?
  3. urlHandler and customActionHandler not working - persists just for push notification? Or is it also affecting other deeplink situations like InApp clicks?
  4. Is/Are there other marketing SDKs installed that could potentially interface the notifications?

If you are willing to share photo or video of the problem, that can also help.

Update: now working fine on iOS.

JS code

    const config = new IterableConfig();
    config.allowedProtocols = ['https'];
    config.inAppHandler = (message) => {
      return IterableInAppShowResponse.show;
    };
    config.urlHandler = (url, context) => {
       if (url) {
            //navigation
           return true;
       }
       return false;
    });
    config.customActionHandler = (action, context) => {
       if (action.type) {
           //navigation
           return true;
       }
       return false;
    });
Iterable.initialize(AppConfig.ITERABLE_API_KEY, config).then(()=>{
      Linking.getInitialURL().then(url => {
        if (url != null) {
          Iterable.handleAppLink(url);
        }
      });
      Linking.addEventListener('url', event => {
        if (event.url != null) {
          Iterable.handleAppLink(event.url);
        }
      });
    });

build.gradle for root

dependencies {
        classpath("com.android.tools.build:gradle:7.3.1")
        classpath("com.facebook.react:react-native-gradle-plugin")
        classpath("com.google.gms:google-services:4.3.14")
}

build.gradle for app

apply plugin: "com.android.application"
apply plugin: "com.facebook.react"
apply plugin: 'com.google.gms.google-services'

AndroidManifest.xml

<activity
            android:name=".MainActivity"
            android:label="@string/app_name"
            android:configChanges="................"
            android:launchMode="singleTask"
            android:screenOrientation="portrait"
            android:windowSoftInputMode="adjustResize"
            android:exported="true">
           <intent-filter android:autoVerify="true">
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
                <data
                    android:scheme="https"
                    android:host="links.mydomain.co"
                    android:pathPrefix="/a/" />
            </intent-filter>
</activity>

IterableApi.setContext(this); in MainApplication

Test Link:

  1. https://links.mydomain.co/a/collections/wifi-plans
  2. https://links.mydomain.co/a/nav:MyPlan