2

I am having an issue trying to have an ongoing location tracking enabled when the following conditions are in place:

  • Background fetch is disabled
  • App is killed

When the above happens, location updates are stopped. I tried to have my server send push notifications to wake the app up but they do not arrive if the app is killed.

What is puzzling is that a similar functionality seems to work just fine on WhatsApp (the live location). On WhatsApp, even if I disable background fetch and kill the app, it somehow manages to wake it up again to send updated location information.

Does anyone have any idea on what they are doing?

ADev
  • 5,259
  • 2
  • 16
  • 29
  • Related or dup? https://stackoverflow.com/questions/30396367/getting-location-for-an-ios-app-when-it-is-in-the-background-and-even-killed?rq=1 – mc01 Jan 26 '18 at 17:07
  • No because that answer explicitly mentions that you need "project settings with Background Fetch and Location Updates turned on". WhatsApp works even if background fetch is off. – ADev Jan 26 '18 at 17:17

2 Answers2

2

It seems WhatsApp could be using PushKit to get around this problem. According to this question:

WhatsApp could be using VOIP background mode along with PushKit for solving this problem.

Voip pushes are:

  • delivered directly to the app.
  • considered high-priority notifications and are delivered without delay.
  • delivered even if the app was force-quit by the user.

I have also created a quick sample app to try this and it works like a charm. However, again according to the question linked, Apple doesn't really allow this solution:

Apple no longer allows the usage of the API for push notifications of non-VOIP apps. They do however allow WhatsApp to do it in their infinite fairness.

ADev
  • 5,259
  • 2
  • 16
  • 29
  • Have you achieved this (Tracking user location when app is killed). If yes please share the code so that it will help me. Even i'm also facing the same issue. – Mahesh Narla Nov 22 '19 at 08:12
0

Use significant-change location services. It will work even the app is terminated.

jpulikkottil
  • 666
  • 9
  • 24
  • I already do that too and it doesn't help much if the scenario I described in my question is present. :( – ADev Jan 29 '18 at 09:23