Skip to content
Tcl methods for interfacing with the Apple Push Notification Service (APNS) for iPhone/iOS alerts
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


This Tcl code interfaces with the Apple Push Notification Service (APNS)
to allow you to send iPhone/iOS alerts.

We have been using this code in a production environment since May 2010.
It is currently delivering nearly 20k successful push alerts to our users
per day (with a peak of nearly 400 alerts per minute) and we expect
that it should continue to be able to scale to much higher levels.

This code has been developed on FreeBSD 8.0 with Tcl 8.5.9, but the
code does not have any unusual OS dependencies and should work on
other Tcl-supported environments.

Your iPhone application will need to be responsible for communicating
the deviceToken to your backend in advance.  The basic syntax of the
transmission will look like this:

         set json "{\"aps\": \"hello message $i\"}"
         set deviceToken "123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF" 
         send_apns $deviceToken $json

The above send_apns is a blocking call, but event driven handlers are
used in the background to perform all socket connecting, reading,
writing, and timeouts.  The network connection is kept persistent
between calls to send_apns in order to maximize throughput.

Periodically, a separate proc "connect_and_receive_apns_feedback" can
be called to retrieve a list of deviceTokens that have bounced by the
APNS, and you can process the list to remove those dead devices from
your database.
You can’t perform that action at this time.