Skip to content

brushedtype/btpush

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

bt-push-go-sdk

This is a Go library to interact with the BT Push backend.

Installation

go get github.com/brushedtype/btpush

Example

import (
  "net/http"
  "net/url"
  "log"

  "github.com/brushedtype/btpush"
)

func main() {
  // Initialise a client with an auth token
  btPush := btpush.New(btpush.Config{
    Token: "some-token",
  })

  // Send alert notifications to a user
  resp, err := btPush.SendAlertNotificationsUser("some-uuid", btpush.Content{
    Title:            "Sample Title",
    Body:             "Sample Body",
    Subtitle:         "Sample Subtitle",
    Badge:            99,
    Sound:            "sample.aif",
    ContentAvailable: 1,
  })

  // Error handling
  if err != nil {
    log.Println(err)

    switch err.Type {
      case btpush.ErrorTypeAPNSError:
        log.Println("APNS is experiencing issues")
        break
      default:
        log.Println("Other issues")
        break
    }
  }

  // Send alert notifications to a user's specific devices
  resp, err := btPush.SendAlertNotificationsDevices("some-uuid", []string{"some-device-uuid"}, btpush.Content{
    Title:            "Sample Title",
    Body:             "Sample Body",
    Subtitle:         "Sample Subtitle",
    Badge:            99,
    Sound:            "sample.aif",
    ContentAvailable: 1,
  })

  // Send silent notifications to a user's specific devices
  resp, err := btPush.SendSilentNotificationsUser("some-uuid", btpush.Content{
    Data: map[string]string{
      "foo": "bar",
    },
    Badge:          99,
    MutableContent: 1,
    Sound:          "sample.aif",
  })

  // Send silent notifications to a user's specific devices
  resp, err := btPush.SendSilentNotificationsDevices("some-uuid", []string{"some-device-uuid"}, btpush.Content{
    Data: map[string]string{
      "foo": "bar",
    },
    Badge:          99,
    MutableContent: 1,
    Sound:          "sample.aif",
  })
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages