So I'm working on this project where I'm fixing the deep link issue on IOS.
The problem is the app's behaviour is that when you open a link or a shared link created by my app: https://www.sampleurl.com/?property=555
The app opens(previously close, not running in the background) it will return to my welcome screen after a few seconds. I want it to just stay to the specific screen(property detail screen).
Here's the code for when the app is opened:
loadApp = async () => {
const hasLoggedIn = await AsyncStorage.getItem('has_logged_in');
const defaultBiz = await AsyncStorage.getItem('biz_view');
if (hasLoggedIn && defaultBiz === '1') {
Api.getToken();
this.props.navigation.navigate('Biz');
} else {
if (hasLoggedIn) {
Api.getToken();
}
setTimeout(() => {
this.props.navigation.navigate('Auth');
const prop_id = this.props.navigation.getParam('property_id');
}, 3000);
}
};
this function is being passed to
componentDidMount(){
this.loadApp();
}
Here is the stack navigator:
const AppNavigator = createSwitchNavigator(
{
AuthLoading: {
screen: AuthLoadingScreen,
path: ''
},
Auth: {
screen: AuthStackNavigator,
path: ''
},
App: {
screen: MainAppNavigator,
path: ''
},
Biz: {
screen: BizAppNavigator,
path: ''
}
},
{
initialRouteName: 'AuthLoading'
}
);
So my investigation is that I am able to see the specific property detail(on PropertyDetailScreen) for a few seconds because of the delay (the setTimeOut => 2000 ms) that I set up.
I want to create a condition that if the app receives a data from the deep link, it won't do the navigation on 'Auth'(which where my WelcomeScreen is included). Is there a way I can receive a specific data/information from the deep link?
The correct behaviour that I want to happen is when I open the url, the app will go directly on the specific property detail(rendered on the PropertyDetailScreen), and won't return to my WelcomeScreen ('Auth')
Auth = to my exported AuthStackNavigator
const AuthStackNavigator = createStackNavigator({
Welcome: WelcomeScreen,
Login: LoginScreen,
Verification: VerifyMobileScreen,
ProfileUpdateName: ProfileUpdateNameScreen
});
On android, the setup is working fine.