0

I am working on project where I have to track user location, I am using background modes to get location in background but when application is in background and user turns off his location then I have to tell server "Location is turned off" and "Application is in background" every 5 mins. Application is supposed to work constantly with the server even when app is background.

(APPLICATION IS IN BACKGROUND)

1)Silent Push Notifications works fine and I call my desired API.

2)BackGround Location works fine.

Problems below: When User turns off location application doesn't work in background.

(APPLICATION IS SUSPENDED)

1)Silent Push notification works rarely (Twice in an hour) content-avaiable = 1 and priority high.

2)Sound notification are delivered but API is not called every time.

3)Tried Background Fetch but BackGroundFetch also does not guarantee to call API every 5 mins.

Any solution to keep calling API in the background every 5 mins.

  • No, you cannot refresh the app to get location data whenever you want. The system will decide when to let your app refresh. From experience, Background App Refresh will occur at the very most in 15 minute intervals and sometimes doesn't happen for hours. – Confuseious Jul 12 '21 at 07:49
  • Any other solution to achieve the goal. – hassan masood Jul 12 '21 at 08:08
  • The best you can do is inform the user that location permissions are required and that they should not force close the app. – Confuseious Jul 12 '21 at 10:15
  • I'm sending local Notification on termination, but we have to check user's setting at any cost every five mins. As they are employees of my company, they tries to cheat by turning off location and say application suspended automatically. – hassan masood Jul 13 '21 at 05:29
  • You could possibly integrate with [Shortcuts](https://developer.apple.com/documentation/sirikit/offering_actions_in_the_shortcuts_app/) and force the employees to set up an automation to send the location to your server every five minutes. I would not recommend this for an app distributed to users because they'd be unlikely to do this but it would work just fine when you can mandate it. – Confuseious Jul 13 '21 at 06:06
  • Thanks for your suggestion. we will definitely think about it. – hassan masood Jul 13 '21 at 06:12

0 Answers0