Exponent push notification go library based on Expo's python sdk
go get github.com/oliveroneill/exponent-server-sdk-golang/sdk
Use to send push notifications to Exponent Experiences from a Golang server.
Full documentation on the API is available if you want to dive into the details.
Example usage
package main
import (
"fmt"
"github.com/oliveroneill/exponent-server-sdk-golang/sdk"
)
func main() {
// To check the token is valid
pushToken, err := expo.NewExponentPushToken("ExponentPushToken[xxxxxxxxxxxxxxxxxxxxxx]")
if err != nil {
panic(err)
}
// Create a new Expo SDK client
client := expo.NewPushClient(nil)
// Publish message
response, err := client.Publish(
&expo.PushMessage{
To: pushToken,
Body: "This is a test notification",
Data: map[string]string{"withSome": "data"},
Sound: "default",
Title: "Notification Title",
Priority: expo.DefaultPriority,
},
)
// Check errors
if err != nil {
panic(err)
return
}
// Validate responses
if response.ValidateResponse() != nil {
fmt.Println(response.PushMessage.To, "failed")
}
}
- Need to add more unit tests