Skip to content

9ssi7/exponent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

exponent

Send push notifications to Expo apps using Golang

revised version of: https://github.com/oliveroneill/exponent-server-sdk-golang/tree/master

Documentation

Go Reference

Installation

go get github.com/9ssi7/exponent

Usage

package main

import (
	"context"
	"time"

	"github.com/9ssi7/exponent"
)

func main() {
	c := exponent.NewClient(exponent.WithAccessToken("your-access-token"))

	tkn := exponent.MustParseToken("ExponentPushToken[xxxxxxxxxxxxxxxxxxxxxx]")
	ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
	defer cancel()
	res, err := c.PublishSingle(ctx, &exponent.Message{
		To:       []*exponent.Token{tkn},
		Body:     "This is a test notification",
		Data:     exponent.Data{"withSome": "data"},
		Sound:    "default",
		Title:    "Notification Title",
		Priority: exponent.DefaultPriority,
	})

	if err != nil {
		panic(err)
	}

	for _, receipt := range res {
		if receipt.IsOk() {
			println("Notification sent successfully")
		} else {
			println("Notification failed")
		}
	}
}

Contributing

We welcome contributions! Please see our Contribution Guidelines for details.

License

This project is licensed under the Apache License. See LICENSE for more details.

About

Send push notifications to Expo apps using Golang

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •  

Languages