Created
April 2, 2021 07:58
-
-
Save kaushal9678/43e27c489884a2596201d7874c0269af to your computer and use it in GitHub Desktop.
for terminated app
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
useEffect(() => { | |
AppState.addEventListener("change", _handleAppStateChange); | |
Linking.getInitialURL().then((url) => { | |
if (url) { | |
const route = url.replace(/.*?:\/\//g, '').split('?'); | |
//if app is open first time and deep link path is initial route | |
if(url.includes('/jobs-') && appState.current === "active"){ | |
const job = route[0].substring(route[0].lastIndexOf('/') + 1) | |
const jobSearch = job.split('-').join(" ") | |
searchScreenViewModel.keyword = jobSearch; | |
performSearch(jobSearch,false); | |
}else{//redirect user to particular page | |
manageRoutes(url); | |
} | |
} | |
}).catch(err => console.error('An error occurred', err)); | |
return () => { | |
AppState.removeEventListener("change", _handleAppStateChange); | |
}; | |
}, []) | |
useEffect(() => { | |
//used if app is in background and deeplink path is initial route name | |
GlobalEmitter.on(GlobalEvents.JOB_SEARCH_DEEP_LINK,deepLinkCall); | |
return () => { | |
GlobalEmitter.removeListener(GlobalEvents.JOB_SEARCH_DEEP_LINK, deepLinkCall); | |
}; | |
}, []); | |
const deepLinkCall=(keyword:string)=>{ | |
searchScreenViewModel.keyword = keyword; | |
setJobTitleText(keyword); | |
if(currentRoute !== "Search"){ | |
navigation.navigateBackToScreen(NavigationScreens.Search) | |
} | |
performSearch(keyword,false); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment