Location Push Service Extension not fired

I'm developing an app that needs to monitor user location and, due to some feature, I need to send a Location Push Notification to send the device location to the server.

This is everything I did, following the apple doccumentation:

  • I requested (and obtained) the com.apple.developer.location.push entitlement to Apple and I included it in the app.
  • I created the proper certificates and added the proper signing capabilities to the app.
  • I created a Location Push Service Extension in my app.
  • I asked the user a token with startMonitoringLocationPushes and I sent it to the server.
  • I established a Token-Based Connection to APNs and I sent the notification request.

After several attempts, everything now seems to work fine, as I receive a status 200 from APNS and no error messages, but the app doesn't receive the notification, or the extensions doesn't get "awakened/fired".

How can I understand what's wrong?

I'm pretty sure that all the procedure is correct because I don't receive any errors like TokenNotForPurpose, BadToken, or else... I had these errors at first attempts but now I get status 200...

I hope someone coulp help me, I'm going crazy trying to solve this and my customer waiting is going nervous waiting for the app to be released

There are too many moving parts to start guessing what might be wrong, remotely here. Your best bet is going to be to start looking at the Console log and see what might be happening when you send the location push. You would want to filter the output with your bundle id to avoid all the other unrelated log entries. There should be some indication as to what might be happening.

Now that you have fixed the problems with actually sending the push (getting 200), you would want to make sure it is not one of the following issues (not an exhaustive list):

  • malformed push payload. You would get a 200 but it would fail on the device
  • using the incorrect (but valid) apns-topic and token. If you also have implemented regular or VoIP notifications in your app, for instance, make sure the correct token is being used.
  • system not able to launch the extension. Usually due to incorrect project configuration
  • extension crashing at launch.
  • extension crashing later while processing. Do you have logging at the point of entry?
  • location permissions issue
  • extension not finishing in a timely manner, or using too much memory and being killed

What I would suggest is to add ample os_log() statements to the extension, and then observe what is going on in the Console log. You will likely see something that will help further pinpoint the problem.

Hi Gualtier Malde,

Thank for your reply, you gave me a lot of suggestions to try/think about. I'm agree, I realize that remotely it's not simple...

Let's start listing what I'm sure It's correct:

  • apns-topic and token: if I change something I get errors, something like "token not for topic", now I get 200
  • location permissions: I'm sure I asked and gave "Always" permission properly
  • extension not finishing in a timely manner, or using too much memory and being killed: I am logging at extension entry point, but no logs come out in the console

I was, then, wondering about correct payload or extension not launching/crashing... I will try to add some better log and I will check that the payload is correct, then I will provide more info about my progress.

Thanks again for your support 

Ok I solved.

The extension was crashing. The problem was not due to the extension nor to something related to the Location service, but to a component that I use to manage differents schemes and targets. I changed it and now I receive the push notification.

I realized it looking the device logs, while printing in console from the extension doesn't work.

Thanks again for your support Gualtier Malde

Can you please share how did you manage to make it works?

Location Push Service Extension not fired
 
 
Q