transistorsoft / flutter_background_geolocation

Sophisticated, battery-conscious background-geolocation & geofencing with motion-detection
https://www.transistorsoft.com/shop/products/flutter-background-geolocation
Other
649 stars 239 forks source link

iPhone Crash and not recording in background #658

Closed LocaTrackGitHub closed 2 years ago

LocaTrackGitHub commented 3 years ago

Your Environment

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3) • Android SDK at /Users/hen3/Library/Android/sdk • Platform android-30, build-tools 29.0.3 • ANDROID_HOME = /Users/hen3/Library/Android/sdk • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165) • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS • Xcode at /Applications/Xcode.app/Contents/Developer • Xcode 12.4, Build version 12D4e • CocoaPods version 1.11.2

[✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2020.3) • Android Studio at /Applications/Android Studio.app/Contents • Flutter plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165)

[✓] VS Code (version 1.61.1) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.27.0

[✓] VS Code (version 1.44.0) • VS Code at /Users/hen3/Applications/Visual Studio Code.app/Contents • Flutter extension version 3.27.0

[✓] Connected device (3 available) • Land Rover Explore (mobile) • MP6J427N4778688 • android-arm64 • Android 8.1.0 (API 27) • iPhone 12 Pro (mobile) • 71CE28A0-7CF4-4E60-8139-9AE819718DE5 • ios • com.apple.CoreSimulator.SimRuntime.iOS-14-4 (simulator)

--- in init bg.BackgroundGeolocation.onLocation((bg.Location location) { _onLocation(location); }); bg.BackgroundGeolocation.onMotionChange((bg.Location location) { _onLocation(location); }); (() async { bg.BackgroundGeolocation.ready(bg.Config( desiredAccuracy: logAccuracyLevel, distanceFilter: 10.0, stopOnTerminate: false, enableHeadless: true, startOnBoot: true, debug: false, reset: true, autoSync: true, foregroundService: true, url: constants.baseServiceUrlH+'/locatrack/user/location/transistorsoft/insert/', params: { "myParams": {"deviceId" : await PlatformDeviceId.getDeviceId} }, logLevel: bg.Config.LOG_LEVEL_WARNING, )).then((bg.State state) { if (!state.enabled) { //// // 3. Start the plugin. // bg.BackgroundGeolocation.start(); print('Started bg.BackgroundGeolocation'); } }); })();

--- in main bg.BackgroundGeolocation.registerHeadlessTask(headlessTask);

---headless

void headlessTask(bg.HeadlessEvent headlessEvent) async { print('[BackgroundGeolocation HeadlessTask]: $headlessEvent'); // Implement a 'case' for only those events you're interested in. switch(headlessEvent.name) { case bg.Event.TERMINATE: bg.State state = headlessEvent.event; print('- State: $state'); break; case bg.Event.HEARTBEAT: bg.HeartbeatEvent event = headlessEvent.event; print('- HeartbeatEvent: $event'); break; case bg.Event.LOCATION: bg.Location location = headlessEvent.event; print('[bg.BackgroundGeolocation.onLocation 2] - : $location'); _onLocation(location); break; case bg.Event.MOTIONCHANGE: bg.Location location = headlessEvent.event; print('- Location: $location'); _onLocation(location); break; case bg.Event.GEOFENCE: bg.GeofenceEvent geofenceEvent = headlessEvent.event; print('- GeofenceEvent: $geofenceEvent'); break; case bg.Event.GEOFENCESCHANGE: bg.GeofencesChangeEvent event = headlessEvent.event; print('- GeofencesChangeEvent: $event'); break; case bg.Event.SCHEDULE: bg.State state = headlessEvent.event; print('- State: $state'); break; case bg.Event.ACTIVITYCHANGE: bg.ActivityChangeEvent event = headlessEvent.event; print('ActivityChangeEvent: $event'); break; case bg.Event.HTTP: bg.HttpEvent response = headlessEvent.event; print('HttpEvent: $response'); break; case bg.Event.POWERSAVECHANGE: bool enabled = headlessEvent.event; print('ProviderChangeEvent: $enabled'); break; case bg.Event.CONNECTIVITYCHANGE: bg.ConnectivityChangeEvent event = headlessEvent.event; print('ConnectivityChangeEvent: $event'); break; case bg.Event.ENABLEDCHANGE: bool enabled = headlessEvent.event; print('EnabledChangeEvent: $enabled'); break; } }

--- onLocation void _onLocation(bg.Location location) async { var _myService = locator(); FlutterSecureStorage _storage = FlutterSecureStorage(); var token = await _storage.read(key: 'token'); if (['', null, false, 0].contains(token)) { token = await _storage.read(key: 'token_old'); } if (!['', null, false, 0].contains(token)) { var deviceId = await PlatformDeviceId.getDeviceId; deviceId ??= "notset"; //print('MMM'); print('Saving location.... token= ${token} pos=${location.coords.latitude},${location.coords.longitude} on device ${deviceId}'); var stringExtra= '{"activity":${location.activity.toString()}, "batteryis":${location.battery.toString()},"extras":${location.extras.toString()},"geofence":${location.geofence.toString()},"isMoving":${location.isMoving.toString()},"map":${location.map.toString()},"odometer":${location.odometer.toString()},"sample":${location.sample.toString()},"timestamp":${location.timestamp.toString()},","uuid":${location.uuid.toString()}}'; print(stringExtra); var responseCode = await _myService.saveLocation( token, location.coords.latitude, location.coords.longitude, deviceId, stringExtra); print('Response was ${responseCode}'); } }


## Expected Behavior
<!--- Tell us what should happen -->
Well was hoping to track a route....

## Actual Behavior
<!--- Tell us what happens instead -->
Tracks part or no route when the app is closed

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

## Context
<!--- What were you trying to do? -->
Fix this
## Debug logs
<!-- include iOS / Android logs
- ios XCode logs,
- use #getLog #emailLog methods (@see docs)
- Android: $ adb logcat -s TSLocationManager
-->
<details>
    <summary>Logs</summary>

``` <!-- syntax-highligting:  DO NOT REMOVE -->
PASTE_YOUR_LOGS_HERE

christocracy commented 3 years ago

iPhone Crash

Where is the stacktrace?

LocaTrackGitHub commented 3 years ago

What stacktraces this is a tester reporting this not on my local...not sure what you mean with that? There is no logs and no errors just a guy driving and the background sometimes kicking in sometimes not...

christocracy commented 3 years ago

Without a stacktrace specifically referencing this plugin, it's impossible to say that your crash is due to the plugin or a bug in your own code.

People often use Crashalytics, like the guy in that other issue you posted in.

LocaTrackGitHub commented 3 years ago
Schermafbeelding 2021-10-18 om 15 21 12

Also it tracks lines like this....which to me seems odd and perhaps delayed entries causing it... I will check out crashalytics in tne mean time... Any idea what is causing the lines?

christocracy commented 3 years ago

See api docs Config.distanceFilter to learn about "distanceFilter elasticity"

LocaTrackGitHub commented 3 years ago

Thank you will look into that, this project dont use firebase, seems like crashalytics is based on a firebase project, is there any other flutter crash reporting tool I can use to get you the stack trace?

heshesh2010 commented 3 years ago

here is log i think may help u i have same issue :

Metal: MTLReleaseAssertionFailure + 220

https://share.getcloudapp.com/DOu682wW

christocracy commented 3 years ago

@heshesh2010 your posted stack-trace has nothing to do with this plugin. When you have an iOS stack-trace that references this plugin, you will see symbols referencing TSLocationManager, or other symbols beginning with the prefix TS (for Transistor Software).

LocaTrackGitHub commented 3 years ago

I hope this could somehow help one is a screenshot of how an app I paid for tracks me and the other one where I seem to get preiodic background updates. Both apps were closed whilst driving so I assume its something to do with the background tracking. I am hoping its something implemented wrong or a small adustment that can fix this.

Schermafbeelding 2021-11-10 om 09 17 05
christocracy commented 3 years ago

Why don't you install the /example in this repo and compare that?

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. You may also mark this issue as a "discussion" and I will leave this open.

stale[bot] commented 2 years ago

Closing this issue after a prolonged period of inactivity. Fell free to reopen this issue, if this still affecting you.