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

Problems to get to work on Ios #151

Open
raul203al opened this issue Jun 13, 2023 · 13 comments
Open

Problems to get to work on Ios #151

raul203al opened this issue Jun 13, 2023 · 13 comments

Comments

@raul203al
Copy link

raul203al commented Jun 13, 2023

Hello, actually I'm using this plugin on capacitor i got it to work for Android Devices but when it comes to Iphone devices i only get troubles actually I modified the info pList with:

  • Privacy - Location Always and When In Use Usage Description
  • Privacy - Location When In Use Usage Description
    and also on the capabilities I checked the location updates, fetch and background processing

This is my configuration:

  await backgroundGeolocation.configure({
    interval: 5000,
    desiredAccuracy: 0,
    startForeground: true, 
    stopOnTerminate: true, 
    stationaryRadius: 100, 
    distanceFilter: 0, 
    notificationTitle: 'Location Enabled', 
    notificationText: 'Enabled', 
    locationProvider: backgroundGeolocation.DISTANCE_FILTER_PROVIDER, 
    postTemplate: postTemplate
  });

And this is my on event code:

  backgroundGeolocation.on('location', async () => {
    console.log("ENTRA LOC")
    if (!navigator.onLine) {
      return;
    }
    this.locationUpdate(await this.getLocationData());
  });

Finally the xcode log:

2023-06-13 13:52:44.140120+0200 App[88984:1058797] CDVBackgroundGeolocation #onAuthorizationChanged
2023-06-13 13:52:44.140804+0200 App[88984:1059078] Configuration persisted successfully
2023-06-13 13:52:44:140 App[88984:1058797] LocationManager didChangeAuthorizationStatus 4
2023-06-13 13:52:44.144086+0200 App[88984:1058880] LocationManager didChangeAuthorizationStatus 4
2023-06-13 13:52:44:158 App[88984:1058797] DistanceFilterLocationProvider will start
2023-06-13 13:52:44.161157+0200 App[88984:1058880] DistanceFilterLocationProvider will start
2023-06-13 13:52:44:174 App[88984:1058797] DistanceFilterLocationProvider switchMode 1
2023-06-13 13:52:44.179519+0200 App[88984:1058881] DistanceFilterLocationProvider switchMode 1
2023-06-13 13:52:44:191 App[88984:1058797] DistanceFilterLocationProvider didUpdateLocations (operationMode: 1)
2023-06-13 13:52:44:193 App[88984:1058797] Location age 0.437930
⚡️ [log] - EMPIEZA LOC
⚡️ [log] - FetchLocation: 9 This FetchLocation Isn't related with this
⚡️ [log] - 1
2023-06-13 13:52:44:263 App[88984:1058797] DistanceFilterLocationProvider didUpdateLocations (operationMode: 1)
2023-06-13 13:52:44:263 App[88984:1058797] Location age 0.111447

As you can see in the log it shows my console log but it never execute the function (inside the functions there are more logs)

@HarelM
Copy link
Collaborator

HarelM commented Jun 13, 2023

Have you played with the configuration? Distance filter of 0 while using distance provider send like a bad idea, but it might work IDK.
I'm using raw provider and it is working as expected on iOS for me.

@raul203al
Copy link
Author

Thanks for answer so fast now wI have another problem with the sqlite database it doesn't create the necessary tables should I need to add something to the config or related on Android works well

@raul203al
Copy link
Author

Hi?

@HarelM
Copy link
Collaborator

HarelM commented Jun 15, 2023

I have it working on iOS, I can't debug your app...

@raul203al
Copy link
Author

I know you can't debug my app but may something is wrong with my config, maybe the import?

@HarelM
Copy link
Collaborator

HarelM commented Jun 15, 2023

@raul203al
Copy link
Author

Thanks i got it to work last thing is it posible to set a location interval for iOS?

@raul203al
Copy link
Author

Does the interval works for ios in that service?

@tsanko95
Copy link

Thanks i got it to work last thing is it posible to set a location interval for iOS?

Hi Raúl, how did you make it works ?
Gracias :)

@raul203al
Copy link
Author

Hi tsanko I couldn´t make it works on ios, actually I´m doing other things probably in the some weeks I´ll give it another try if I get it to work I´ll dm you or reply this

@risinghero
Copy link

Do events really work in backround mode? I think that they dont... Because they require javascript and webview

@HarelM
Copy link
Collaborator

HarelM commented Dec 29, 2023

They work to a certain limit, I also think it's different between capacitor and Cordova.
Generally speaking, my approach was to trust the db of the plugin and not the state of the webview.

@risinghero
Copy link

risinghero commented Jan 8, 2024

I think that in cordova they just dont work in background mode. Cause webview gets destroyed. And javascript code just cant be executed. Events are only for foreground mode. But you can get all locations when your app is activated and brought to foreground and then log.

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

4 participants