import { useCallback , useEffect , useState } from 'react' ; import { getInstallReferrerAsync } from 'expo-application' ; see https see https example export function useApplicationAndroidInstallReferrer ( options = { } ) { const [ applicationInstallReferrer , setApplicationInstallReferrer ] = useState < string > ( ) ; const { get = true } = options ; const getApplicationInstallReferrer = useCallback ( ( ) => ( getInstallReferrerAsync ( ) . then ( setApplicationInstallReferrer ) ) , [ ] ) ; useEffect ( ( ) => { if ( get ) { getApplicationInstallReferrer ( ) ; } } , [ get , getApplicationInstallReferrer ] ) ; return [ applicationInstallReferrer , getApplicationInstallReferrer ] ; } export interface ApplicationAndroidInstallReferrerOptions { /** If it should fetch the application install referrer when mounted, defaults to `true` */ get ? : boolean ; }