transistorsoft / react-native-background-geolocation

Sophisticated, battery-conscious background-geolocation with motion-detection
http://shop.transistorsoft.com/pages/react-native-background-geolocation
MIT License
2.65k stars 426 forks source link

iOS continuous background geolocation not working- But works well with Android #1817

Closed ghnsharma closed 5 months ago

ghnsharma commented 1 year ago

Environment

Expected Behavior

On iOS, it will continuously receive location updates in the background mode.

Actual Behavior

Android is working perfectly fine both in the foreground and in the background. However, on iOS, it only receives updates with a 4-5-minute delay every time after coming out of stationary mode.

Steps to Reproduce

  1. kill application and test

Debug logs

Screenshot 2023-09-12 at 3 43 40 PM
christocracy commented 1 year ago

Show me your package.json

ghnsharma commented 1 year ago

{ "name": "MyApp", "version": "0.0.1", "private": true, "scripts": { "android": "react-native run-android", "ios": "react-native run-ios", "start": "react-native start", "test": "jest", "lint": "eslint ." }, "dependencies": { "@aws-sdk/client-s3": "^3.40.1", "@invertase/react-native-apple-authentication": "^2.1.4", "@react-native-community/art": "^1.2.0", "@react-native-community/async-storage": "^1.12.1", "@react-native-community/checkbox": "^0.5.7", "@react-native-community/cli": "^6.1.0", "@react-native-community/datetimepicker": "^3.0.4", "@react-native-community/masked-view": "^0.1.10", "@react-native-community/picker": "^1.8.1", "@react-native-community/push-notification-ios": "^1.8.0", "@react-native-firebase/app": "^12.1.0", "@react-native-firebase/messaging": "^12.1.0", "@react-native-google-signin/google-signin": "^7.0.0-alpha.3", "@react-navigation/bottom-tabs": "^5.9.2", "@react-navigation/drawer": "^5.9.3", "@react-navigation/material-top-tabs": "^5.3.6", "@react-navigation/native": "^5.7.6", "@react-navigation/stack": "^5.9.3", "aws-sdk": "^2.1026.0", "axios": "^0.21.1", "base-64": "^1.0.0", "base64-arraybuffer": "^1.0.1", "fast-plist": "^0.1.2", "i18n-js": "^3.8.0", "lodash.memoize": "^4.1.2", "moment": "^2.29.1", "moment-timezone": "^0.5.33", "prop-types": "^15.7.2", "qs": "^6.10.3", "react": "17.0.1", "react-chips": "^0.8.0", "react-native": "0.64.0", "react-native-actionsheet": "^2.4.2", "react-native-app-intro-slider": "^4.0.4", "react-native-background-fetch": "^4.2.1", "react-native-background-geolocation": "^4.13.3", "react-native-calendars": "^1.403.0", "react-native-camera": "3.44.3", "react-native-collapsible": "^1.5.3", "react-native-country-picker-modal": "^2.0.0", "react-native-date-picker": "^4.2.6", "react-native-document-picker": "^5.2.0", "react-native-document-scanner-plugin": "^0.7.4", "react-native-draggable-flatlist": "^2.5.0", "react-native-elements": "^2.3.2", "react-native-email-link": "^1.11.0", "react-native-expandable-listview": "^1.2.11", "react-native-file-viewer": "^2.1.5", "react-native-floating-action": "^1.21.0", "react-native-fs": "^2.18.0", "react-native-gesture-handler": "^1.8.0", "react-native-google-places-autocomplete": "^2.4.1", "react-native-iap": "^8.6.3", "react-native-image-crop-picker": "^0.36.4", "react-native-image-picker": "^3.6.0", "react-native-image-to-pdf": "^1.2.0", "react-native-images-to-pdf": "^0.0.2", "react-native-input-credit-card": "^0.5.5", "react-native-keyboard-aware-scroll-view": "^0.9.5", "react-native-linear-gradient": "^2.5.6", "react-native-localize": "^1.4.2", "react-native-media-controls": "^2.1.0", "react-native-modal": "^11.7.0", "react-native-modal-datetime-picker": "^10.2.0", "react-native-orientation": "^3.1.3", "react-native-permissions": "^3.0.5", "react-native-print": "^0.8.0", "react-native-progress": "^4.1.2", "react-native-push-notification": "^7.3.1", "react-native-qrcode-svg": "^6.1.1", "react-native-radio-buttons-group": "^2.2.4", "react-native-ratings": "^7.3.0", "react-native-raw-bottom-sheet": "^2.2.0", "react-native-reanimated": "^2.2.0", "react-native-render-html": "^6.3.4", "react-native-safe-area-context": "^3.1.8", "react-native-screens": "3.3.0", "react-native-signature-capture": "^0.4.11", "react-native-simple-radio-button": "^2.7.4", "react-native-slider": "^0.11.0", "react-native-snap-carousel": "^3.9.1", "react-native-stripe-api": "^0.1.0", "react-native-stripe-checkout-webview": "0.0.13", "react-native-super-grid": "^4.0.3", "react-native-svg": "^12.1.1", "react-native-tab-view": "^2.15.2", "react-native-tag-autocomplete": "^1.0.22", "react-native-tags-input": "^1.0.10", "react-native-text-input-mask": "^3.1.4", "react-native-toast-message": "^1.4.9", "react-native-vector-icons": "^7.1.0", "react-native-video": "^5.2.0", "react-native-video-player": "^0.12.0", "react-native-video-processing": "^2.0.0", "react-native-view-pdf": "^0.11.0", "react-native-webview": "^10.10.2", "react-redux": "^7.2.1", "redux": "^4.0.5", "redux-persist": "^6.0.0", "redux-saga": "^1.1.3", "reduxsauce": "^1.2.0", "rn-fetch-blob": "^0.12.0" }, "devDependencies": { "@babel/core": "7.13.14", "@babel/runtime": "7.13.10", "@react-native-community/eslint-config": "2.0.0", "babel-jest": "26.6.3", "eslint": "7.14.0", "eslint-config-prettier": "^6.11.0", "eslint-config-standard": "^14.1.1", "eslint-plugin-import": "^2.20.2", "eslint-plugin-node": "^11.1.0", "eslint-plugin-prettier": "^3.1.3", "eslint-plugin-promise": "^4.2.1", "eslint-plugin-react": "^7.20.0", "eslint-plugin-react-native": "^3.8.1", "eslint-plugin-standard": "^4.0.1", "jest": "26.6.3", "metro-react-native-babel-preset": "0.64.0", "prettier": "^2.0.5", "react-native-rename": "^2.4.1", "react-test-renderer": "17.0.1" }, "jest": { "preset": "react-native", "setupFiles": [ "./node_modules/react-native-gesture-handler/jestSetup.js" ], "transformIgnorePatterns": [ "/node_modules/(?!react-native)/.+" ] }, "rnpm": { "assets": [ "./App/Assets/Fonts/" ] } }

christocracy commented 1 year ago

reset: false,

Why are you using reset: false. Almost nobody should be using that. Do you know what it does?

christocracy commented 1 year ago

"react-native-background-geolocation": "^4.12.1",

The version posted to your issue doesn’t match the version from your package.json.

"react-native-background-geolocation": "^4.13.3",

christocracy commented 1 year ago

I suggest you fetch the logs from the plug-in. See wiki “Debugging” and learn to use the .emailLog method.

ghnsharma commented 1 year ago

"react-native-background-geolocation": "^4.12.1",

The version posted to your issue doesn’t match the version from your package.json.

"react-native-background-geolocation": "^4.13.3",

We updated the package after pushing the issue to see if it works.

ghnsharma commented 1 year ago

email logs { activityRecognitionInterval = 10000; activityType = 1; authorization = { }; autoSync = 1; autoSyncThreshold = 0; batchSync = 0; debug = 1; desiredAccuracy = "-1"; desiredOdometerAccuracy = 100; didDeviceReboot = 0; didLaunchInBackground = 0; didRequestUpgradeLocationAuthorization = 1; disableAutoSyncOnCellular = 0; disableElasticity = 0; disableLocationAuthorizationAlert = 1; disableMotionActivityUpdates = 0; disableStopDetection = 0; distanceFilter = 10; elasticityMultiplier = 1; enableTimestampMeta = 0; enabled = 1; extras = { }; geofenceInitialTriggerEntry = 1; geofenceProximityRadius = 2000; geofenceTemplate = ""; headers = { }; heartbeatInterval = 60; httpRootProperty = location; httpTimeout = 60000; iOSHasWarnedLocationServicesOff = 0; isFirstBoot = 0; isMoving = 0; lastLocationAuthorizationStatus = 3; locationAuthorizationAlert = { cancelButton = Cancel; instructions = "To use background location, you must enable '{locationAuthorizationRequest}' in the Location Services settings"; settingsButton = Settings; titleWhenNotEnabled = "Background location is not enabled"; titleWhenOff = "Location services are off"; }; locationAuthorizationRequest = Always; locationTemplate = ""; locationTimeout = 60; locationsOrderDirection = ASC; logLevel = 0; logMaxDays = 3; maxBatchSize = "-1"; maxDaysToPersist = 1; maxRecordsToPersist = "-1"; method = POST; minimumActivityRecognitionConfidence = 70; odometer = "43986.17490828034"; params = { }; pausesLocationUpdatesAutomatically = 1; persistMode = 2; preventSuspend = 0; schedule = ( ); schedulerEnabled = 0; showsBackgroundLocationIndicator = 1; startOnBoot = 1; stationaryRadius = 25; stopAfterElapsedMinutes = "-1"; stopDetectionDelay = 0; stopOnStationary = 0; stopOnTerminate = 0; stopTimeout = 5; trackingMode = 1; url = ""; useSignificantChangesOnly = 0; }

christocracy commented 1 year ago

There is a very large zip file contains the plug-in logs which is attached to the email. I’m less interested in the text in the body of the email,

ghnsharma commented 1 year ago

Our Application Logs background-geolocation (3).log.gz

Your Demo Application Logs background-geolocation (4).log.gz

christocracy commented 1 year ago

What org name did you register with my demo app?

ghnsharma commented 1 year ago

https://tracker.transistorsoft.com/Augmentworks

christocracy commented 1 year ago

Tracking for Augmentworks looks fine.

Screenshot 2023-09-13 at 7 47 23 AM
ghnsharma commented 1 year ago

Yes, it looks good here from your application. We tried matching all configuration as yours but still not working on iOS devices from our application, it always gives gaps of 4-5 min delay. It is working on simulator though when we try on city run. Anything you can think of that we are missing?

christocracy commented 1 year ago

Have you checked your XCode logs to see if your app is crashing (from your own application code)?

See XCode -> Window -> Devices & Simulators -> [View Device Logs]

Screenshot 2023-09-13 at 8 33 01 AM
ghnsharma commented 1 year ago

App is not crashing as it is already in killed state, service is running continuously, it is getting location data only after specific time period. It runs for sometime and then it goes to sleep and again gets started. And this happens continuously.

On simulator it works well. But on devices it shows gaps. We had been using your SDK since long time and it had been giving continuous tracking before for us. But suddenly it stopped giving continuous updates on production server where nothing is changed and this is happening on ios only.

So we are not able to understand the issue.

christocracy commented 1 year ago

Our Application Logs background-geolocation (3).log.gz

Your zip file is empty.

logLevel = 0;

Use LOG_LEVEL_VERBOSE

ghnsharma commented 1 year ago

background-geolocation (6).log

christocracy commented 1 year ago

What would you like to know about these logs?

ghnsharma commented 1 year ago

When it goes into the background, it triggers after covering some distance. However, it goes to sleep for 4 minutes, then starts again for 1 minute, and repeats this cycle. So, I don't know why it's causing a 4-minute delay every time.

christocracy commented 1 year ago

I suggest you build yourself a simple Hello World and attempt to reproduce it

ghnsharma commented 1 year ago

ok will check.

ghnsharma commented 1 year ago

Sorry for the late reply.

I tried the 'Hello World' project, but it still gives a 5-minute gap in background modes. For reference, I am attaching the details of my demo project. Archive.zip

christocracy commented 1 year ago

You're aware there CAN be a "gap" when a device first starts travelling? it typically takes movement of at least 200 meters before tracking engages. That is represented by the "green polyline" on the demo server (and example app). Depending on the device / environment, it can take longer.

ghnsharma commented 1 year ago

Yes, I am aware of the gap at the beginning, but it continues to occur continuously. Please check today's latest testing data.

https://tracker.transistorsoft.com/AugmentWorks

christocracy commented 1 year ago

I suggest you analyze your logs at the start / end of those "gaps". I suspect it's your application code responsible.

I also suggest you install the SampleApp to test and compare in parallel.

I do not experience anything like this and none of the other thousands of customers are posting about this.

github-actions[bot] commented 6 months ago

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] commented 5 months ago

This issue was closed because it has been inactive for 14 days since being marked as stale.