Quantcast
Channel: Active questions tagged react-native+ios - Stack Overflow
Viewing all articles
Browse latest Browse all 16552

How to get initial link for iOS using react native firebase dynamic links?

$
0
0

I am using react-native-firebase:: 5.6.0, I am having issue while getting initial link for iOS device. On android it's working fine. I am using "Firebase Dynamic Links" to redirect user inside login screen of my app if in case he is not logged in inside app, otherwise just opening app if he is already logged in. It's working for android app but having an issue with ios app. I have used two function one is the get dynamic link if app is closed "getInitialLink" and another one is to check when app is opened "onLink".

This is function I am using after closing splash screen, only called once when opening app from closing state.

firebase.links().getInitialLink().then((url) => {
    if (url && url === 'https://mycustomdomain.co.in') {
        navigationToScreen(AUTH, INITIAL_SCREEN);
    } else {
        // INITIALIZE APP HERE
    }
});

If app already opened I am getting dynamic link url value inside this function::

this.unsubscribeHandleOpenAppDynamicLinks = firebase.links().onLink(async (url) => {
    let isLoggedIn = await AsyncStorage.getItem(LocalStorageKeys.IS_LOGGEDIN);
    if (url) {
        if ( isLoggedIn !== 'yes'&& url === 'https://mycustomdomain.co.in') {
            navigationToScreen(AUTH, INITIAL_SCREEN);
        }
    }
});


and clearing that listener on componentWillUnmount:: this.unsubscribeHandleOpenAppDynamicLinks();

In case of iOS only "onLink" function is working and I am getting url value as "undefined". getInitialLink() function will returns the URL that the app has been launched from. If the app was not launched from a URL the return value will be null, but I am getting "undefined" even when launching an app from url in case of iOS only. I am getting url inside onLink() in case of iOS when app is launched. Why this is happening??

Please suggest what I am doing wrong here.


Viewing all articles
Browse latest Browse all 16552

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>