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.53k stars 424 forks source link

Ios app crash in background. #1981

Closed FatihAvs closed 1 month ago

FatihAvs commented 1 month ago

Your Environment

import BackgroundGeolocation from 'react-native-background-geolocation'; import AsyncStorage from '@react-native-async-storage/async-storage'; const startBackgroundGeolocation = async () => {

BackgroundGeolocation.onLocation((location) => {

}, error => { console.warn("[location] ERROR: ", error); });

//useEffect(()=>{ //konumIzniİste(); //}) BackgroundGeolocation.onMotionChange(location => { console.warn("[motionchange] ", location); });

// This handler fires on HTTP responses BackgroundGeolocation.onHttp(response => { console.warn("[http] ", JSON.parse(response?.responseText)); var httpResponseFromMyServer = JSON.parse(response?.responseText); var httpResponseSevkiyatVarYok = httpResponseFromMyServer?.data?.sevkiyatVar; if(httpResponseSevkiyatVarYok!=null){ if(httpResponseSevkiyatVarYok==true){ console.warn("Aktif Sevkiyat Var, Konum güncellemelerine devam") } else if(httpResponseSevkiyatVarYok==false){ BackgroundGeolocation.stop(function () { console.warn("- Sevkiyat Yok Konum Almayı Durdur"); })

  }
}

});

// This event fires when a change in motion activity is detected BackgroundGeolocation.onActivityChange(activityEvent => { console.warn("[activitychange] ", activityEvent); });

// This event fires when the user toggles location-services authorization BackgroundGeolocation.onProviderChange(providerEvent => { console.warn("[providerchange] ", providerEvent); });

//// // 2. Execute #ready method (required) // const userToken = await AsyncStorage.getItem("userToken") BackgroundGeolocation.ready({ httpRootProperty: 'coordData', notification: { title: "myapp", text: "location" }, // Geolocation Config url: "myapi/AddCordinatesToUserNew", headers: { "Authorization": Bearer ${userToken}, "content-type": "application/json" },

distanceFilter: 50,  // Must be 0 or locationUpdateInterval is ignored!

autoSync: true,
// Activity Recognition,

stopTimeout: 1,
// Application config
debug: false,
// <-- enable this hear debug sounds.
logLevel: BackgroundGeolocation.LOG_LEVEL_VERBOSE,
stopOnTerminate: false,   // <-- Allow the background-service to continue tracking when app terminated.
startOnBoot: true,        // <-- Auto start tracking when device is powered-up.

}, (state) => { console.warn("- BackgroundGeolocation is configured and ready: ", state);

if (!state.enabled) {
  ////
  // 3. Start tracking!
  //
  BackgroundGeolocation.start(function () {
    console.warn("- Start success");
  }).then(response => console.warn("responseee",response)).catch(err => console.warn(err));
}

})

} export default startBackgroundGeolocation;


## Expected Behavior
Expecting properly send user location to our api.

## Actual Behavior
App crashing while driving.

## Steps to Reproduce
<!--- reproduce this issue; include code to reproduce, if relevant -->
1.
2.
3.
4.

## Context
<!--- What were you trying to do? -->

## Debug logs
<!-- include iOS / Android logs
- ios XCode logs,
- use #getLog #emailLog methods (@see docs)
- Android: $ adb logcat -s TSLocationManager
-->
<details><summary>Details</summary>
<p>

I EOF


</p>
</details> 

>

<details><summary>Details</summary>
ls> 
<details><summary>Logs</summary>

``` <!-- Syntax highlighting:  DO NOT REMOVE -->
PASTE_YOUR_LOGS_HERE

christocracy commented 1 month ago

Why are you posting this crash here to this repo?

FatihAvs commented 1 month ago

Why are you posting this crash here to this repo?

because I think the crash is due to react native background location. There is no crash when the location is not active.

christocracy commented 1 month ago

Your stacktrace does not reference this plug-in. If it did, there would be references to the symbolTSLocationManager.

There are no references to this plug-in in your stacktrace. The plug-in is not at-fault.

FatihAvs commented 1 month ago

Your stacktrace does not reference this plug-in. If it did, there would be references to the symbolTSLocationManager.

There are no references to this plug-in in your stacktrace. The plug-in is not at-fault.

Could the distance filter being 50 m have increased resource usage at high speeds and caused a crash? Because we usually encounter this crash while driving at high speed on the highway.

christocracy commented 1 month ago

Could the distance filter being 50 m have increased resource usage at high speeds

No. That’s not a low distanceFilter. 50 is what I’ve used for testing for the last 9 years. read the api docs Config.distanceFilter: distanceFilter is automatically increased based upon speed.

I also see references in your stacktrace to TTSSpeechThread (text-to-speech).

FatihAvs commented 1 month ago

Could the distance filter being 50 m have increased resource usage at high speeds

No. That’s not a low distanceFilter. 50 is what I’ve used for testing for the last 9 years. read the api docs Config.distanceFilter: distanceFilter is automatically increased based upon speed.

I also see references in your stacktrace to TTSSpeechThread (text-to-speech).

Thank you for your efforts for always providing help in every matter.