Skip to content

cfilipov/go-apns

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go APNs Package

This Go package implements the Apple Push Notification System (APNs) binary interface.

Usage

This package provides simple interfaces for establishing authenticated connections to APNs gateways and sending notifications. The function apns.DialAPN(...) returns a net.Conn which is authenticated and ready to receive data. Notifications implement the io.Writer and io.Reader interfaces so that sending a notification is done by having it write to a connection.

var notif = `
{
	"command": 2,
	"device-token": "beefca5e",
	"identifier": 1,
	"expiry": 0,
	"priority": 10,
	"payload": {
		"aps" : {
			"content-available": 1,
   	    	"alert" : "Hello World",
   			"badge" : 42
		}
	}
}`

func main() {
	cert, _ := apns.LoadPemFile("notifyme_cert.pem") // Load the pem file from the current dir.
	conn, _ := apns.DialAPN(&cert, apns.SANDBOX, false)
	defer conn.Close()

	n := apns.MakeNotification([]byte(notif))
	n.WriteTo(conn)
}

Other Go implementations of APNs:

Other non-Go APNs projects:

apnsend

The apnsend utility is a command line tool which uses the apns package for sending push notifications.

apnserver

[note: this is probably broken right now] The apnserver utility will respond to the APNs protocol with mock data. The server can be configured to a specific mock failure rate to simulate errors and dropped connections.

License

Distribution and use of this project is governed by the [3-clause] Revised BSD license that can be found in the LICENSE file.

Related Info

About

A simple library and tools for Apple's Push Notification Service (APNS).

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages