Created
July 29, 2014 05:34
-
-
Save joekarl/a93238739cf9b339a924 to your computer and use it in GitHub Desktop.
Quickstart go-libapns
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
apns "github.com/joekarl/go-libapns" | |
"ioutil" | |
) | |
func main() { | |
//tlsConn is a socket connection to apple's gateway | |
apnsConnection, _ := apns.NewAPNSConnection(&APNSConfig{ | |
CertificateBytes: ioutil.ReadFile("path/to/cert.pem"), | |
KeyBytes: ioutil.Readfile("path/to/key.pem") | |
}) | |
payload := &apns.Payload { | |
Token: "2ed202ac08ea9...cf8d55910df290567037dcc4", | |
AlertText: "This is a push notification!", | |
} | |
apnsConnection.SendChannel <- payload | |
apnsConnection.Disconnect() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment