Search code examples
ios6push-notificationapple-push-notificationspassbookapns-php

How to call pushnotification when server want to update pass


I have an interface for updating pass. When I click 'update pass', I want to call pushnotification to the pass in device. I don't know how to do this. How to do this?


Solution

  • For Passbook, quite a few things have to be in place in order for a push to trigger a notification on a device. From your form, you will need to implement everything to follow this flow:

    1. post the data from your form to your server and update the pass record(s) in your database
    2. retrieve the device pushToken(s) for the device(s) that require the updated pass from your devices table (these should be linked to the pass table with a common key)
    3. connect to the production APNS using the PassID certificate that matches the passTypeIdentifier of the changed pass
    4. send an APNS message containing an empty payload for each device
    5. wait a few seconds......
    6. upon receiving the push, each device will contact your web service using the 'Getting the Serial Numbers for Passes Associated with a Device' method
    7. your web service must respond with a json dictionary containing the serial(s) of the updated pass (note only send serials relevant to the device, if you send a serial of a pass that is not installed, you will receive error log messages)
    8. when the device get's your response, it will call your service again with the 'Getting Latest Version of a Pass' for the serial you sent it.
    9. dynamically build the new .pkpass bundle and send as a response with the correct MIME type and 'Last-Modified' header
    10. providing that a field value has changed, and that field dictionary contains a changeMessage key, a notification will show on the device. If nothing has changed, or if no changeMessage is set, the above will still happen, the pass will update but you will not see a notification.