Skip to content

HTTP/2 Apple Push Notification service (APNs) provider for Go with token-based connection

License

Notifications You must be signed in to change notification settings

bergusman/apns-go

Repository files navigation

APNs Provider

HTTP/2 Apple Push Notification service (APNs) provider for Go with token-based connection

Example:

key, err := apns.AuthKeyFromFile("AuthKey_XXXXXXXXXX.p8")
if err != nil {
	log.Fatal(err)
}

token := apns.NewToken(key, "XXXXXXXXXX", "YYYYYYYYYY")
client := apns.NewClient(token, nil)

n := &apns.Notification{
	DeviceToken: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
	Host:        apns.HostDevelopment,
	Topic:       "com.example.app",
	Payload: apns.BuildPayload(&apns.APS{
		Alert: "Hi",
	}, nil),
}

fmt.Println(client.Push(n))