Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In ios real device once killed the app, location is not triggered while moving #1398

Open
vanjiNapses opened this issue Dec 30, 2024 · 15 comments

Comments

@vanjiNapses
Copy link

vanjiNapses commented Dec 30, 2024

Your Environment

  • Plugin version:
  • Platform: iOS
  • OS version:
  • Device manufacturer / model:
  • Flutter info (flutter doctor):
  • Plugin config:
 // 1.  Listen to events (See docs for all 12 available events).
    bg.BackgroundGeolocation.onLocation(_onLocation, _onLocationError);
    bg.BackgroundGeolocation.onMotionChange(_onMotionChange);
    bg.BackgroundGeolocation.onActivityChange(_onActivityChange);
    bg.BackgroundGeolocation.onProviderChange(_onProviderChange);
    bg.BackgroundGeolocation.onConnectivityChange(_onConnectivityChange);
    bg.BackgroundGeolocation.onHeartbeat(_onHearBeatEventChange);
    // 2.  Configure the plugin
    bg.BackgroundGeolocation.ready(bg.Config(
      reset: true,
      debug: true,
      logLevel: bg.Config.LOG_LEVEL_VERBOSE,
      desiredAccuracy: bg.Config.DESIRED_ACCURACY_HIGH,
      distanceFilter: 50,
      heartbeatInterval: 60,
      allowIdenticalLocations: true,
      preventSuspend: true,
      foregroundService: true,
      persistMode: bg.Config.PERSIST_MODE_ALL,
      showsBackgroundLocationIndicator: true,
      notification: bg.Notification(
          sticky: true,
          title: "${FlavorTypes.appTitle} - tracking your location",
          text:
              "${FlavorTypes.appTitle} accessing background location to track your location, even when it's not running."),
      backgroundPermissionRationale: bg.PermissionRationale(
          title:
              "Allow ${FlavorTypes.appTitle} to access this device's location even when the app is closed or not in use.",
          message:
              "This app collects location data to enable recording your trips to work and calculate distance-travelled.",
          positiveAction: 'Allow',
          negativeAction: 'Cancel'),
      stopOnTerminate: false,
      startOnBoot: true,
      disableProviderChangeRecord: false,
      enableHeadless: true,
      autoSync: false,
      disableElasticity: true,
      locationAuthorizationRequest: 'Always',
    )).then((bg.State state) {
      if (!state.enabled) {
        bg.BackgroundGeolocation.start();
      }
    }).catchError((error) {
      print("Error $error");
    });
  }
  
  
  
  
  
    ///event handlers

  void _onLocation(bg.Location location) {
    print(
        '[IosBackGroundLocator location] - $location  and the event is :${location.event}');
    if (location.event != "motionchange") {
      if (location.age < 5000) {
        CommonLocationApiCall().postData(location.coords.longitude,
            location.coords.latitude, location.extras?["type"] ?? "OnLocation",
            defaultBatteryLevel: location.battery.level.toInt());
      } else {
        print(
            "[IosBackGroundLocator  the location is not updated :${location.age < 6000}");
      }
    } else {
      print(
          "[IosBackGroundLocator  the location is not updated :${location.event}");
    }
  }

Expected Behavior

while app is in fore ground and background it is working fine. but when i killed the app it is not trigged the location even i moved more than 200 m. Also notification are not comming. After a long disitance (may be 500 m) , when i am stationary for 10 seconds, that time only i recieve lot of notifications.those notifications are not releated to moving state. those are some releated to "MOTION TRIGGERED DELAY ENGAGED" some thing like that.

NOTE: I called config every time app reopens.

Actual Behavior

In ios real device once killed the app, location should trigger while moving

Steps to Reproduce

Context

Debug logs

Logs
PASTE_YOUR_LOGS_HERE
@christocracy
Copy link
Member

I suggest you test your iOS app in the simulator with location simulated with “Freeway Drive”.

@vanjiNapses
Copy link
Author

vanjiNapses commented Dec 30, 2024

I tested in simulator with location simulated with “Freeway Drive” and it is working fine . but in real device the location is not triggered even after 200m by walk in killed state.

I set the debug is true.(debug: true,)

I should see the notification for moving state in ios in killed state correct?

I am getting lot of notification once i came back to stationary state. while moving state no notification.

@vanjiNapses
Copy link
Author

vanjiNapses commented Dec 30, 2024

Is my config which i showed above is correct?

@christocracy
Copy link
Member

There is nothing unusual about your Config.

@vanjiNapses
Copy link
Author

but why it is not working in ios after killed the application.

@christocracy
Copy link
Member

christocracy commented Dec 30, 2024

but why it is not working in ios after killed the application.

If I knew that, I'd have told you already. I have no idea what you're doing wrong. I do not have this problem with the demo app. I can terminate the demo app and be 100% confident that the app will resume tracking after moving about 200 meters.

LIke I said above:

I suggest you test your iOS app in the simulator with location simulated with “Freeway Drive”.

Have you done this?

@christocracy
Copy link
Member

Also see this video demonstrating terminating the app running in the simulator.

@vanjiNapses
Copy link
Author

vanjiNapses commented Dec 30, 2024

I installed the app in simulater. I enabled simulators-> features -> loaction -> freeway drive. once i enabled automatically the location gets triggered. once is killed the app i show the notifications and sounds for movements

@vanjiNapses
Copy link
Author

Also see this video demonstrating terminating the app running in the simulator.

exactly this is what i am doing.

@christocracy
Copy link
Member

once i enabled automatically the location gets triggered.

What does "enabled automatically the location" mean?

@vanjiNapses
Copy link
Author

once i enabled automatically the location gets triggered.

What does "enabled automatically the location" mean?

i mean , the location triggered automattically for specific intervals once i covered the distance filter

@christocracy
Copy link
Member

once i covered the distance filter

I don’t know what this means

@vanjiNapses
Copy link
Author

Execution of the command buffer was aborted due to an error during execution. Insufficient Permission (to submit GPU work from background) (00000006:kIOGPUCommandBufferCallbackErrorBackgroundExecutionNotPermitted)

sometimes i got the able error. Is this is the reason for the above mentioned one?

incase yes, how to solve this?

@christocracy
Copy link
Member

I suggest you install the /example app in this repo and go outside to test. Use the “Advanced app” after install.

you don’t need to look at the code. Just install, launch, enable the switch in the top toolbar, then go outside to test.

@christocracy
Copy link
Member

Insufficient Permission (to submit GPU work from background) (00000006:kIOGPUCommandBufferCallbackErrorBackgroundExecutionNotPermitted)

I have never heard of that before. The plugin does not do anything related to the UI (ie: GPU). this is likely related to your own application code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants