react-native-sdk
react-native-sdk copied to clipboard
Function urlHandler doesn't run in Android
I am using the function urlHandler to manage the deepLinks and the universal links when opening a push notification with a link.
Iterable code: const config = new IterableConfig(); config.autoPushRegistration = true; config.urlHandler = url => { handleOpenURL({ url }); return true; }; let result = false; try { result = await Iterable.initialize(ITERABLE_API_KEY, config); } catch (e) { crashlytics().recordError(e as Error, 'Iterable not Initialized'); }
The deeplinks are working correctly for Android and iOs, I tried with "@iterable/react-native-sdk": "^1.3.6" and 1.3.3
When I open a push notification with a deeplink, It works perfectly in iOs, but when I try to test in Android, the function in urlHandler never is called.
You know if is a bug in the library, or a configuration additional is required, I modified the AndroidManifest file according to the documentation.
@huds79 , thank you for reaching out, Have you set the context in generated Android project as shown here?
//Application class in Android project
import com.iterable.iterableapi.IterableApi;
...
IterableApi.setContext(this);
@Ayyanchira thank you for your answer
Yes, I follow the instructions on the Installing Iterable's React Native SDK page, I have those lines in the MainApplication file.

Is it a custom link? By default, IterableSDK supports https links. However, if it is a custom link, it must be specified in allowedProtocols.
Also feel free to have your Iterable Admin create a support ticket so we can look at templates and get a deeper look why this is happening.
I am using with deeplinks with this form:
appname://list/
The deeplinks are working when I open from a page or external app.
I tried with: config.allowedProtocols = ['http', 'https', 'appname'];
I tried with: config.allowedProtocols = ['http', 'https', 'custom'];
too with the same result
Was a solution to this ever found? I'm currently experiencing the same issue as well. It seems the handleUrlCalled
event is never called on Android. I see the event pass on iOS, but not on Android. The event listener for handleUrlCalled
seems to get created, but the event is never fired when clicking the push notification.
I'm having the same issue with my project, none of the URLs I'm providing in the OpenURL field is triggering anything (urlHandler, Linking.addEventListener, Linking.getInitialURL()). I've tried with different protocols: https and my own one from my app (defined in the AndroidManifest)... Everything is working well with my iOS app, I get the whole string provided in the openURL field.
Any solutions found? Thanks
@huds79 @nicopir @nprz :
Could you guys try react-native-sdk version 1.3.12 and see if it is still reproducible?
We tried on the same version and it is working fine.
What we did is added a separate Intent filter to handle custom deep link like this: sampleopenapp://openlink/ in our manifest
<activity
android:name=".MainActivity"
android:screenOrientation="portrait"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize|smallestScreenSize|uiMode"
android:launchMode="singleTask"
android:windowSoftInputMode="adjustResize"
android:exported="true">
And also don't forget to add this custom link protocol when initialising IterableConfig as below as we did in our case:
const config = new IterableConfig(); config.allowedProtocols = ["https", "sampleopenapp"] // This will allow to detect custom link when you click on a push notification and open the app