App architecture when 'state changing' APNS fails

I’ve seen several questions on this topic. But all simply say you just have to recover from other means. But none explain what the other means are! I couldn’t find an answer on SO. This is also a follow up from the comments of this question.

Let’s say I’m working on a Uber app. Drivers need to know passenger locations.

  • Dismissing iOS push notifications remotely
  • any limitation push notification via APNS or C2DM?
  • Apple Push Notification in Background Issue
  • APNS + PHP “stream_socket_client(): Failed to enable crypto”
  • iOS 10 How to set UNotificationContent threadIdentifier for remote notification
  • Can I somehow do a synchronous HTTP request via NSURLSession in Swift
  • A passenger sets a pickup location for 123 XYZStreet.

    2 minutes later she decides to cancel the entire pickup. So now I need
    to inform the driver. This is an important state changing update.

    The first thought that comes to mind is:

    Send a notification that has content-available:1 so I can update the app as soon as the notification arrives, and in the didReceiveNotification I call GET(PassengerInfoModel) and also have include "alert" : "Pickup has been canceled. Don't go there' So the driver would also be visually informed. Obviously tapping on the notification is not what manages the updates. The content-available being set to 1 will manage that.

    But doing that, still what happens when the arrival of that notification fails—completely? Well then the latest GET(PassengerInfoModel) won’t happen. As a solution I’ve heard of a HEAD request:

    The HEAD method is identical to GET except that the server MUST NOT
    return a message-body in the response
    . The metainformation contained
    in the HTTP headers in response to a HEAD request SHOULD be identical
    to the information sent in response to a GET request. This method can
    be used for obtaining metainformation about the entity implied by the
    request without transferring the entity-body itself. This method is
    often used for testing hypertext links for validity, accessibility,
    and recent modification.

    Not sure what happens if using a HEAD request we figured out that there was an update!? Do we then make a GET request in the success case of the HEAD’s completion Handler?

    Question1 How should we handle the HEAD request response? (I’m guessing that for the server to be able to route HEAD requests, there must be some changes, but let’s just assume that’s outside the scope of the question).

    Question2 How often do we have to do this request? Based on this comment one solution could be to set a repeating timer in the viewDidAppear e.g. make a HEAD request every 2 minutes. Is that a good idea?

    Question3 Now let’s say we did that HEAD request, but the GET(PassengerInfoModel) is requested from 2 other scenes/viewControllers as well. The server can’t differentiate between the different scenes/viewControllers. I’m guessing a solution would be have all our app’s network requests managed through a singleton NetworkHandler. Is that a good idea?

    I understand that this question is broad, but believe the issue needs to be addressed as a whole

    Solutions Collect From Internet About “App architecture when 'state changing' APNS fails”

    Question1 How should we handle the HEAD request response? (I’m guessing that for the server to be able to route HEAD requests, there must be some changes, but let’s just assume that’s outside the scope of the question).

    You probably don’t need to deal with HEAD requests. Using Etags is a standard mechanism which lets you make a GET request and the server can just return an empty body with 304 response if nothing has changed, or the actual new content if something has.

    Question2 How often do we have to do this request? Based on this comment one solution could be to set a repeating timer in the viewDidAppear e.g. make a HEAD request every 2 minutes. Is that a good idea?

    I think this is reasonable, especially if you want to inform your user when you are unable to make that request successfully. You might also consider using Apple’s Reachability code to detect when you can or cannot talk to your server.

    Question3 Now let’s say we did that HEAD request, but the GET(PassengerInfoModel) is requested from 2 other scenes/viewControllers as well. The server can’t differentiate between the different scenes/viewControllers. I’m guessing a solution would be have all our app’s network requests managed through a singleton NetworkHandler. Is that a good idea?

    Yes, I think having a singleton is reasonable, though I’m not sure why the server cares what view controller is making the request. Like can’t they just request different urls?