exponent-server-sdk-golang

module
v0.0.0-...-0e9a686 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 31, 2021 License: MIT

README

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL