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

stopTracking method not working #67

Open
arnabonetraker opened this issue Oct 18, 2023 · 3 comments
Open

stopTracking method not working #67

arnabonetraker opened this issue Oct 18, 2023 · 3 comments

Comments

@arnabonetraker
Copy link

Once the tracking is start i am not able to stop it.
The method is not returning any error or message.
So I am not able to figure out what is going on.

@ikbendewilliam
Copy link
Contributor

Do you still see the notification that the tracking is running? Or how can you tell it didn't stop?
Did you start it multiple times?

@arnabonetraker
Copy link
Author

I can see it in the console as loggingEnabled was set to true.
I am calling start and stop App lifecycle

didChangeAppLifecycleState(AppLifecycleState state) {
  super.didChangeAppLifecycleState(state);
  if(state == AppLifecycleState.resumed){
       stopTracking();
  }
  if(state == AppLifecycleState.paused){
      startTrackingIOS();
  }
}

I have the functions like this

@pragma('vm:entry-point')
void backgroundCallbackIOS() {
  BackgroundLocationTrackerManager.handleBackgroundUpdated(
        (data) async => Repo().update(data),
  );
}

Future<void> initializeBackgroundLocationService() async{
  await BackgroundLocationTrackerManager.initialize(
    backgroundCallbackIOS,
    config: const BackgroundLocationTrackerConfig(
      loggingEnabled: true,
      androidConfig: AndroidConfig(
        notificationIcon: 'explore',
        trackingInterval: Duration(seconds: 4),
        enableCancelTrackingAction: false,
        distanceFilterMeters: null,
      ),
      iOSConfig: IOSConfig(
        activityType: ActivityType.FITNESS,
        distanceFilterMeters: null,
        restartAfterKill: true,
      ),
    ),
  );
}


Future<void> startTracking() async{
  final result = await getTrackingStatus();
  if(!result)
    await BackgroundLocationTrackerManager.startTracking();
}

Future<void> stopTracking() async{
  final result = await getTrackingStatus();
  if(result)
    await BackgroundLocationTrackerManager.stopTracking();
}

Future<bool> getTrackingStatus() async {
  return await BackgroundLocationTrackerManager.isTracking();
}

@dpsavaliya
Copy link

Any update? @arnabonetraker

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

3 participants