Skip to content

prakashbask/exponent-server-sdk-golang

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 

Repository files navigation

expo-server-sdk-go

Send push notifications to Expo apps using Go

Installation

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

Usage

package main

import (
    "fmt"
    expo "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: []expo.ExponentPushToken{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)
    }
    
    // Validate responses
    if response.ValidateResponse() != nil {
        fmt.Println(response.PushMessage.To, "failed")
    }
}

License

MIT

About

Exponent push notification go library

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%