com.APNS.DecodeFeedback

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

Syntax

com.APNS.DecodeFeedback(
   data BYTE,
   unregs DYNAMIC ARRAY OF RECORD
          timestamp INTEGER,
          deviceToken STRING
       END RECORD
   )
  1. data is the BYTE variable containing the feedback data. This BYTE variable must be located IN MEMORY.
  2. unregs is a structured dynamic array that will contain the list of unregistered device tokens.
    1. timestamp is the number of seconds since Unix Epoch (in UTC)
    2. deviceToken is a APNS device token that has been unregistered (encoded in Base-64)

Usage

Apple recommends to connect 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), to the following specific URI:
tcps://feedback.push.apple.com:2196
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.

Example

DEFINE feedback_data BYTE,
       unregs DYNAMIC ARRAY OF RECORD
             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
END FOR

For a complete example, see APNs feedback handler.