Skip to content

bazuker/exponent-server-sdk-golang

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 

Repository files navigation

exponent-server-sdk-golang

Build Status

Exponent push notification go library based on Expo's python sdk

Installation

go get github.com/oliveroneill/exponent-server-sdk-golang/sdk

Usage

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")
    }
}

TODO

  • Need to add more unit tests

See Also

About

Exponent push notification go library

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%