com.APNS.DecodeFeedback

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

Important:

On March 31 2021 Apple® discontinued the APNs legacy binary protocol. Therefore, the com.APNS class is now desupported. The documentation pages related to the APNS binary protocol are still provided for information. Contact your support center, if you need to implement APNS with the new HTTP/2-based provider API.

Starting with Genero V5.00, the com.APNS classe will be removed from the com package.

Syntax

com.APNS.DecodeFeedback(
   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)

Usage

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:
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.

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.