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

[Help Want]: Not Working in IOS side kill mode after 30 minutes #1418

Open
2 of 3 tasks
PiyushPoshiya opened this issue Feb 1, 2025 · 17 comments
Open
2 of 3 tasks

[Help Want]: Not Working in IOS side kill mode after 30 minutes #1418

PiyushPoshiya opened this issue Feb 1, 2025 · 17 comments

Comments

@PiyushPoshiya
Copy link

Required Reading

  • Confirmed

Plugin Version

flutter_background_geolocation: ^4.16.6

Mobile operating-system(s)

  • iOS
  • Android

What do you require assistance about?

I am working on a Flutter application that requires continuous location tracking, even when the app is killed (terminated). The implementation works fine for 15-20 minutes, but after 30 minutes, location updates stop completely on iOS.

Environment:
Flutter Version: [✓] Flutter (Channel stable, 3.24.0, on macOS 14.5 23F79 darwin-arm64, locale en-IN)
Xcode Version: XCode 16.0
iOS Version: [iOS 15/16/17]
Device: [iPhone Model]

Question:
How can I ensure reliable location tracking in iOS even after the app is killed for more than 30 minutes? Are there any additional workarounds to keep the app running in the background or restart location updates?

[Optional] Plugin Code and/or Config

// Configure the plugin
    bg.BackgroundGeolocation.ready(
      bg.Config(
        locationAuthorizationRequest: 'Always',
        disableLocationAuthorizationAlert: false,
        disableMotionActivityUpdates: false,
        // backgroundPermissionRationale: bg.PermissionRationale(
        //     title: "Give me Location bro",
        //     message: "I want you for testing",
        //     positiveAction: "Click here",
        //     negativeAction: "Don't click here"),
        // stationaryRadius: 200,
        // minimumActivityRecognitionConfidence: 75,
        desiredAccuracy: bg.Config.DESIRED_ACCURACY_HIGH,
        distanceFilter: 250,
        // Set distance filter to 100 meters
        disableElasticity: true,
        preventSuspend: true,
        stopOnTerminate: false,
        startOnBoot: true,
        debug: false,
        logLevel: bg.Config.LOG_LEVEL_VERBOSE,
        foregroundService: true,
        forceReloadOnLocationChange: true,
        geofenceModeHighAccuracy: true,
        forceReloadOnGeofence: true,
        forceReloadOnMotionChange: true,
        isMoving: true,
        enableHeadless: true,
        showsBackgroundLocationIndicator: false,
        stopOnStationary: false,
        pausesLocationUpdatesAutomatically: false,
        //new
        heartbeatInterval: 60,
        // Server endpoint
        url: 'https://28xh460q-5000.use.devtunnels.ms/location',

        // Authorization header
        headers: {
          'Authorization':
              'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOjIxLCJleHAiOjE3Mzc1NjU0Mzh9.WR5N0PbUAG2X8JGTF4GOxCNv43ALvDWY_dYmZbxU34c',
          'Content-Type': 'application/json',
        },

        // Parameters to send with each location
        params: {
          "trackingId": trackingID,
        },
        extras: {
          "trackingId": trackingID,
        },

        // Sync and HTTP settings
        autoSync: true,
        // Automatically send locations to the server
        method: 'POST', // HTTP POST method
      ),
    ).then((bg.State state) async {
      if (!state.enabled) {
        // Start the plugin if it's not already running
        await bg.BackgroundGeolocation.start();
      }
    });

[Optional] Relevant log output

Stop the tracking in iOS killed mode after 30 minutes
@PiyushPoshiya PiyushPoshiya changed the title [Help Wanted]: Not Working in IOS side kill mode after 30 minutes [Help Want]: Not Working in IOS side kill mode after 30 minutes Feb 1, 2025
@christocracy
Copy link
Member

After terminating an iOS app, the plug-in will automatically resume tracking when the device moves about 200 meters.

This is easily demonstrated in the iOS simulator with location simulated with “Freeway Drive”

@christocracy
Copy link
Member

Read the api docs Config.stopOnTerminate for detailed information.

@PiyushPoshiya
Copy link
Author

i already set
stopOnTerminate: false
on my BG service configuration method. You can check in my code also, and it's working only 30 minutes after killed mode.

i al

@christocracy
Copy link
Member

Read the api docs Config.stopOnTerminate. There’s valuable information there.

Also see wiki “Debugging” and learn to fetch plug-in logs using method .emailLog (consult the api docs for usage).

@PiyushPoshiya
Copy link
Author

dear,
On Debuggind modes to working completely, On Emulator/Semultor to work also
but when we are use a release/live device, then face issue
i post to my bg.configue method Also, if you face any error code on my code, then please suggest me

please give me proper solution of this problem

@christocracy
Copy link
Member

Provide logs.

@PiyushPoshiya
Copy link
Author

already share code logs

@christocracy
Copy link
Member

No, you have not. The plug-in logs everything it does in its own logs database. Search the api docs “Logger”.

You MUST learn to analyze the plug-in logs.

@christocracy
Copy link
Member

Also read the wiki “Debugging”.

@PiyushPoshiya
Copy link
Author

https://github.com/transistorsoft/flutter_background_geolocation/wiki/Debugging
i already read this
but on simulator working perfectly, when i using live device then face problem

@christocracy
Copy link
Member

Provide logs

@PiyushPoshiya
Copy link
Author

is it require of shaking (movement) to phisical live device for get location ?

@christocracy
Copy link
Member

Yes

@PiyushPoshiya
Copy link
Author

how can i get logs file ?

@christocracy
Copy link
Member

Do you know how to access the api documentation?

@PiyushPoshiya
Copy link
Author

no, just give me step

@christocracy
Copy link
Member

The api docs have a search feature.

Search “emailLog”

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