Decodes content of BYTE data returned from the APNS feedback service.


   data BYTE,
   unregs  RECORD
  1. data defines a BYTE variable containing the feedback data. This BYTE variable must be located IN MEMORY.
  2. unregs defines a structured dynamic array that contains the list of unregistered device tokens.
    1. timestamp is the number of seconds since UNIX® Epoch (in UTC)
    2. deviceToken is an APNS device token that has been unregistered (encoded in Base-64)


Apple® recommends connecting frequently to the APNS feedback server in order to verify that your applications are still registered for push notifications.

To get APNS feedback, you must perform a TCP request (using SSL/TLS), to the following specific URI:
The DecodeFeedback() method decodes the content of the BYTE variable, which was passed as a parameter and received as response for the TCP request to the APNS feedback server.
Note: This BYTE variable must be located IN MEMORY.

For the second parameter, this method takes a structured dynamic array that will be filled with the list of unregistered APNS device tokens. It is up to the push program to stop sending push notification messages for these unregistered device tokens.

The timestamp member of an unregs dynamic array element can be used to verify that device tokens have not been re-registered since the feedback entry was generated. This timestamp is returned as a number of seconds since the UNIX epoch, in UTC. Use the util.Datetime.fromSecondsSinceEpoch utility API to convert timestamp to a DATETIME value in the current local time.

The deviceToken member of an unregs dynamic array element identifies iOS devices that have been unregistered from the APNS server. Note that these identifier is encoded in Base64.

In the event of a decoding error, the method will raise the exception -15566, with details in the SQLCA.SQLERRM register.


DEFINE feedback_data BYTE,
             timestamp   INTEGER,
             deviceToken STRING
           END RECORD,
       i INTEGER

LOCATE feedback_data IN MEMORY

... TCP request to APNS feedback server ...

CALL com.APNS.DecodeFeedback(feedback_data, unregs)

FOR i=1 TO unregs.getLength()
    DISPLAY i, " ", unrefs[i].deviceToken

For a complete example, see APNs feedback handler.