Search code examples
iosobjective-cbackgroundgeolocationlocation

ios closed app send location 2 times per day


I am doing a small application for iOS (with Qt and Native code)

I need send my position twice a day to a server (user REST API)

I have no ideas, I do not understand how I could launch a recovery twice a day in a service without my application being on.

Do you have any examples / suggestions to help me?

So far the solution I have found is to use the "background fetch" but I don't know if it is usable when the application is closed and not only in "background". And I also don't know if it's possible to use the locationmanager in this case. https://developer.apple.com/documentation/uikit/app_and_environment/scenes/preparing_your_ui_to_run_in_the_background/updating_your_app_with_background_app_refresh

Thank you


Solution

  • Background fetch wouldn't work if the app is terminated by the user instead of being in a suspended state in the background.

    The same goes if you are using background location updates. https://developer.apple.com/documentation/corelocation/cllocationmanager/1620568-allowsbackgroundlocationupdates

    I haven't tested if this would work but you could try setting up a silent remote push notification and send it to your app twice a day, then when the app wakes to deal with the notification you get the users location.

    https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/pushing_background_updates_to_your_app