You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have tried to get the location when the app is in background or the screen is locked/closed it works good on the development when i take the build and run the application the task that i have added is not executing. How to solve this issue i have given my code below.
ReactNativeForegroundService.register({id: 1244});constaddTask=()=>{ReactNativeForegroundService.add_task(()=>{console.log('task executed');getLocation();},{delay: 15000,onLoop: true,taskId: 1244,},);};conststartForegroundService=()=>{addTask();ReactNativeForegroundService.update({id: 1244,title: 'Sales 10X',message: 'Sales 10X is running in background for live tracking ',icon: 'ic_launcher',});};conststopForegroundService=()=>{ReactNativeForegroundService.stop(1244);};constappState=useRef(AppState.currentState);constappStateSubscription=useRef(null);consthandleAppStateChange=nextAppState=>{if(appState.current.match(/inactive|background/)&&nextAppState==='active'){console.log('App has come to the foreground! Stopping foreground service.',);stopForegroundService();}elseif(nextAppState==='background'){console.log('App is in the background! Starting foreground service.');startForegroundService();}appState.current=nextAppState;console.log('AppState',appState.current);};useEffect(()=>{letdata=userDetailData?.userDetails;if(data&&data?.permission_list&&data?.permission_list?.includes('usertracking')){console.log('change in app state');appStateSubscription.current=AppState.addEventListener('change',handleAppStateChange,);}return()=>{appStateSubscription.current?.remove();ReactNativeForegroundService.stop(1244);// RNLocation.stopUpdatingLocation();};},[userDetailData]);
The text was updated successfully, but these errors were encountered:
I have tried to get the location when the app is in background or the screen is locked/closed it works good on the development when i take the build and run the application the task that i have added is not executing. How to solve this issue i have given my code below.
The text was updated successfully, but these errors were encountered: