Created
February 24, 2016 16:56
-
-
Save julianshen/90a7b5c4a24eb13f41fa to your computer and use it in GitHub Desktop.
test_push.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 ( | |
"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