pushnotification

package module
Version: v0.0.0-...-d38f610 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2016 License: MIT Imports: 4 Imported by: 0

README

pushnotification

GoDoc License

Package pushnotification sends push notification via Amazon SNS

Example

package main

import (
	"log"
	"os"

	"github.com/Iwark/pushnotification"
	"github.com/aws/aws-sdk-go/aws"
	"github.com/joho/godotenv"
)

func main() {
	if err := godotenv.Load(); err != nil {
		log.Fatal(err)
	}

	push := pushnotification.Service{
		AWSAccessKey:         os.Getenv("AWSAccessKey"),
		AWSAccessSecret:      os.Getenv("AWSAccessSecret"),
		AWSSNSApplicationARN: os.Getenv("AWSSNSApplicationARN"),
		AWSRegion:            os.Getenv("AWSRegion"),
	}

	err := push.Send(os.Getenv("DeviceToken"), &pushnotification.Data{
		Alert: aws.String("test message"),
		Sound: aws.String("default"),
		Badge: aws.Int(1),
	})
	if err != nil {
		log.Fatal(err)
	}
}

License

pushnotification is released under the MIT License.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Data

type Data struct {
	Alert *string     `json:"alert,omitempty"`
	Sound *string     `json:"sound,omitempty"`
	Data  interface{} `json:"custom_data"`
	Badge *int        `json:"badge,omitempty"`
}

Data is the data of the sending pushnotification.

type Service

type Service struct {
	AWSAccessKey         string
	AWSAccessSecret      string
	AWSSNSApplicationARN string
	AWSRegion            string
}

Service is the main entry point into using this package.

func (*Service) Send

func (s *Service) Send(deviceToken string, data *Data) (err error)

Send sends a push notification

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL