Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
47 lines (40 sloc) 1.54 KB

This project is no longer maintained. Check out anachronistic/apns instead.


This Go package provides a client that can establish a connection with the Apple Push Notification service and deliver notifications to end users based on a device token. This package has been implemented according to Apple's documentation (available at ever changing/breaking URLs).



go get


Create a Client and connect to the APNs

client := apns.NewClient(apns.SandboxGateway, // or apns.ProductionGateway
    func(invalidToken string) {
        // called when we try to send a notification to an invalid token
        // You should delete the token from your db by disassociating it with
        // the user you tried sending the notification too. When this is called
        // it means the person either uninstalled your app or has switched to
        // a new device.
err := client.Connect()
if err != nil {
    // handle the connection error

Create a Notification

n := apns.NewNotification(aDeviceToken)
n.Alert = "Hello, user!"
n.Badge = 1
// optionally, include app data ('aps' element of notification json)
n.AppData = map[string]interface{}{"sound":"tada", "Foo":"Bar"}

Send the Notification