Last active
July 19, 2023 00:03
-
-
Save sideshow/ae221a792261180c954d9bea72780f85 to your computer and use it in GitHub Desktop.
apns.go
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 ( | |
"log" | |
"sync" | |
"github.com/sideshow/apns2" | |
"github.com/sideshow/apns2/certificate" | |
) | |
// Run this from the terminal; | |
// bash> GODEBUG=http2debug=2 go run ./apns.go | |
func main() { | |
cert, pemErr := certificate.FromP12File("../cert.p12", "") | |
if pemErr != nil { | |
log.Println("Cert Error:", pemErr) | |
} | |
notification := &apns2.Notification{} | |
notification.DeviceToken = "11aa01229f15f0f0c52029d8cf8cd0aeaf2365fe4cebc4af26cd6d76b7919ef7" | |
notification.Topic = "com.sideshow.Apns2" | |
notification.Payload = []byte(`{"aps" : {"alert" : "Hello!"}}`) | |
client := apns2.NewClient(cert).Production() | |
log.Println("Starting push") | |
var wg sync.WaitGroup | |
for i := 0; i < 100000; i++ { | |
wg.Add(1) | |
go func() { | |
client.Push(notification) | |
wg.Done() | |
}() | |
} | |
wg.Wait() | |
log.Println("Im done!") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment