-
Notifications
You must be signed in to change notification settings - Fork 19
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
Silent push is not reliably received on iOS #68
Comments
This is not a correctness issue, because the silent push will be received eventually. However, it is a performance issue, because our tests have shown that the power drain with a geofence is close to zero, while the power drain during monitoring, even with a distance filter, is significant. Let us try switching to using visits instead. I've been displaying the results of the visit as notifications on the phone, and they seem to be fairly reliable. And using visits will ensure that we don't have to deal with setting up remote push, which is not as much of a pain as you might imagine, but is still a pain. |
One fairly big question is, what do we do when the visit message is triggered? Do we just trust in the wisdom of iOS and say that the trip has ended, or do we do our own checks? It seems like it would be good to at least have the option of doing our own checks. |
Hm. Looking back at the record of changes in the past, we see an issue with geofences. It looks like geofences are not created properly when we are in the background. Looking at the logs reported at the time:
Note the ~ 25 minute gap between the call to create the geofence and the time that the monitoring started. I believe that I brought the app to the foreground around 4:25. Based on this, I am not sure whether the geofence would have ever triggered.
An advantage of using the push notification code is that the method does not exit, and the app get killed, until the completionMethod is called or 30 seconds have passed. This means that we are able to wait until the trip has completely ended before calling the completionMethod, which ensures that the geofence is set up correctly. On the other hand, the evidence above is that the geofence delegate is not invoked unless it is in the main thread.
So does the delay in delivering the message to the delegate imply that there is also a delay in the creating the geofence, or is it just in the message delivery? Need to test. And if it is a delay in creating the geofence, then we need to use something like NSCondition to ensure that we don't return from the method until we know what has happened to the geofence. |
The original idea behind using the silent push was to get a more reliable delivery mechanism than the background fetch, which is known to be flaky. However, during the first active test on Wednesday, we found in practice that remote pushes were also sometimes missing.
Consider the list of transitions for the phone which was using the geofence.
Until the first trip outside, we got pushes reliably:
After returning from the first trip at 10:35, I expected to get a remote push at around 11. But no remote push was delivered until 11:40, at which time I issued another call manually, which caused the geofence to be recreated.
Again, there was no remote push at noon, when we were in drama class. The next remote push was only delivered after we returned home and I generated a manual push at 1:11pm.
After that, we receive consistent pushes until midnight with the 19:00 (7pm) and 22:00 (10pm) updates skipped.
The text was updated successfully, but these errors were encountered: