Skip to content

Instantly share code, notes, and snippets.

@julianshen
Created February 24, 2016 16:56
Show Gist options
  • Save julianshen/90a7b5c4a24eb13f41fa to your computer and use it in GitHub Desktop.
Save julianshen/90a7b5c4a24eb13f41fa to your computer and use it in GitHub Desktop.
test_push.go
package main
import (
"fmt"
"github.com/alexjlockwood/gcm"
)
func main() {
// Create the message to be sent.
data := map[string]interface{}{"push_id": "10131233", "time": "2016-02-23T06:43:13.265Z", "data": "{'title':'test'}"} regIDs := []string{"device-token-y5g"}
msg := gcm.NewMessage(data, regIDs...)
// Create a Sender to send the message.
sender := &gcm.Sender{ApiKey: "API_KEY"}
// Send the message and receive the response after at most two retries.
resp, err := sender.Send(msg, 2)
if err != nil {
fmt.Println("Failed to send message:", err)
return
}
fmt.Println(resp)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment