notificationhubs

package module
v0.1.3-0...-05073e5 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2020 License: MIT Imports: 20 Imported by: 0

README

Azure Notification Hubs for Go(lang)

This library provides a Microsoft Azure Notification Hubs Client for backend applications. It is packaged as a Go module to and is tested with Go 1.12+.

Originally a fork from Gozure with patches from Martin Etnestad @ vippsas.

Now maintained and packaged by Daresay AB, @daresaydigital.

Basically a wrapper for this Rest API

Build Status

Installing

Using go get

go get github.com/NathanBaulch/azure-notificationhubs-go

Registering device

package main

import (
  "context"
  "strings"
  "github.com/NathanBaulch/azure-notificationhubs-go"
)

func main() {
  var (
    hub      = notificationhubs.NewNotificationHub("YOUR_DefaultFullSharedAccessConnectionString", "YOUR_HubPath")
    template = `{
    "aps":{
      "alert":{
        "title":"$(title)",
        "body":"$(body)",
      },
      "badge":"#(badge)",
      "topic":"co.daresay.app",
      "content-available": 1
    },
    "name1":"$(value1)",
    "name2":"$(value2)"
  }`
  )

  template = strings.ReplaceAll(template, "\n", "")
  template = strings.ReplaceAll(template, "\t", "")

  reg := notificationhubs.NewTemplateRegistration(
    "ABC123",                       // The token from Apple or Google
    nil,                            // Expiration time, probably endless
    "ZXCVQWE",                      // Registration id, if you want to update an existing registration
    "tag1,tag2",                    // Tags that matches this device
    notificationhubs.ApplePlatform, // or GcmPlatform for Android
    template,                       // The template. Use "$(name)" for strings and "#(name)" for numbers
  )

  // or hub.NewRegistration( ... ) without template

  hub.RegisterWithTemplate(context.TODO(), *reg)
  // or if no template:
  hub.Register(context.TODO(), *reg)
}

Sending notification

package main

import (
  "context"
  "fmt"
  "github.com/NathanBaulch/azure-notificationhubs-go"
)

func main() {
  var (
    hub     = notificationhubs.NewNotificationHub("YOUR_DefaultFullSharedAccessConnectionString", "YOUR_HubPath")
    payload = []byte(`{"title": "Hello Hub!"}`)
    n, _    = notificationhubs.NewNotification(notificationhubs.Template, payload)
  )

  // Broadcast push
  b, _, err := hub.Send(context.TODO(), n, nil)
  if err != nil {
    panic(err)
  }

  fmt.Println("Message successfully created:", string(b))

  // Tag category push
  tags := "tag1 || tag2"
  b, _, err = hub.Send(context.TODO(), n, &tags)
  if err != nil {
    panic(err)
  }

  fmt.Println("Message successfully created:", string(b))
}

Tag expressions

Read more about how to segment notification receivers in the official documentation.

Example expressions

Example devices:

"devices": {
  "A": {
    "tags": [
      "tag1",
      "tag2"
    ]
  },
  "B": {
    "tags": [
      "tag2",
      "tag3"
    ]
  },
  "C": {
    "tags": [
      "tag1",
      "tag2",
      "tag3"
    ]
  },
}
  • Send to devices that has tag1 or tag2. Example devices A, B and C.

    hub.Send(notification, "tag1 || tag2")
    
  • Send to devices that has tag1 and tag2. Device A and C.

    hub.Send(notification, "tag1 && tag2")
    
  • Send to devices that has tag1 and tag2 but not tag3. Device A.

    hub.Send(notification, "tag1 && tag2 && !tag3")
    
  • Send to devices that has not tag1. Device B.

    hub.Send(notification, "!tag1")
    

Changelog

v0.1.2
  • Bugfix for reading the message id on standard hubs. Headers are always lowercase.
v0.1.1
  • Bugfix for when device registration were responding an unexpected response.
v0.1.0
  • Support for templated notifications
  • Support for notification telemetry in higher tiers
v0.0.2
  • Big rewrite
  • Added get registrations
  • Travis CI
  • Renamed the entities to use the same nomenclature as Azure
  • Using fixtures for tests
  • Support tag expressions
v0.0.1

First release by Daresay. Restructured the code and renamed the API according to Go standards.

TODO

  • Implement cancel scheduled notifications using http DELETE. Find inspo from the Java SDK here.

  • Only Android and iOS is supported today, implement the other supported platforms. Probably limited usecase.

License

See the LICENSE file for license rights and limitations (MIT).

Documentation

Index

Constants

View Source
const (
	Template           NotificationFormat = "template"
	AppleFormat        NotificationFormat = "apple"
	BaiduFormat        NotificationFormat = "baidu"
	GcmFormat          NotificationFormat = "gcm"
	KindleFormat       NotificationFormat = "adm"
	WindowsFormat      NotificationFormat = "windows"
	WindowsPhoneFormat NotificationFormat = "windowsphone"

	AdmPlatform                  TargetPlatform = "adm"
	AdmTemplatePlatform          TargetPlatform = "admtemplate"
	ApplePlatform                TargetPlatform = "apple"
	AppleTemplatePlatform        TargetPlatform = "appletemplate"
	BaiduPlatform                TargetPlatform = "baidu"
	BaiduTemplatePlatform        TargetPlatform = "baidutemplate"
	GcmPlatform                  TargetPlatform = "gcm"
	GcmTemplatePlatform          TargetPlatform = "gcmtemplate"
	TemplatePlatform             TargetPlatform = "template"
	WindowsphonePlatform         TargetPlatform = "windowsphone"
	WindowsphoneTemplatePlatform TargetPlatform = "windowsphonetemplate"
	WindowsPlatform              TargetPlatform = "windows"
	WindowsTemplatePlatform      TargetPlatform = "windowstemplate"

	APNSPlatform InstallationPlatform = "apns"
	WNSPlatform  InstallationPlatform = "wns"
	MPNSPlatform InstallationPlatform = "mpns"
	ADMPlatform  InstallationPlatform = "adm"
	GCMPlatform  InstallationPlatform = "gcm"

	InstallationChangeAdd     InstallationChangeOp = "add"
	InstallationChangeRemove  InstallationChangeOp = "remove"
	InstallationChangeReplace InstallationChangeOp = "replace"

	// Abandoned: Message processing has been abandoned.
	// It will happen when the message could not be processed within the acceptable time window.
	// By default, it's 30 minutes.
	Abandoned NotificationState = "Abandoned"
	// Canceled: This scheduled message was canceled by user.
	Canceled NotificationState = "Canceled"
	// Completed: Message processing has completed.
	Completed NotificationState = "Completed"
	// Enqueued: Message has been accepted but processing has not yet begun.
	Enqueued NotificationState = "Enqueued"
	// NoTargetFound: No devices were found to send this message.
	NoTargetFound NotificationState = "NoTargetFound"
	// Processing: Message processing has started.
	Processing NotificationState = "Processing"
	// Scheduled: Message is in queue and will be sent on the scheduled time.
	Scheduled NotificationState = "Scheduled"
	// Unknown: Message processing is in an unknown state.
	Unknown NotificationState = "Unknown"

	// AbandonedNotificationMessages: Count of send requests to push service that were dropped because of a timeout.
	AbandonedNotificationMessages NotificationOutcomeName = "AbandonedNotificationMessages"
	// BadChannel: Communication to the push service failed because the channel was invalid.
	BadChannel NotificationOutcomeName = "BadChannel"
	// ChannelDisconnected: Push service disconnected.
	ChannelDisconnected NotificationOutcomeName = "ChannelDisconnected"
	// ChannelThrottled: Push service denied access due to throttling.
	ChannelThrottled NotificationOutcomeName = "ChannelThrottled"
	// Dropped: Push service indicates that the message was dropped.
	Dropped NotificationOutcomeName = "Dropped"
	// ExpiredChannel: Communication to the push service failed because the channel expired.
	ExpiredChannel NotificationOutcomeName = "ExpiredChannel"
	// InvalidCredentials: Credentials used to authenticate to the push service failed.
	InvalidCredentials NotificationOutcomeName = "InvalidCredentials"
	// InvalidNotificationSize: Push request is too large.
	InvalidNotificationSize NotificationOutcomeName = "InvalidNotificationSize"
	// NoTargets: Count of requests that found nothing to send to.
	NoTargets NotificationOutcomeName = "NoTargets"
	// PnsInterfaceError: Push service contract communication failed.
	PnsInterfaceError NotificationOutcomeName = "PnsInterfaceError"
	// PnsServerError: Push service indicated that an error happened on their side.
	PnsServerError NotificationOutcomeName = "PnsServerError"
	// PnsUnavailable: Push service is not available.
	PnsUnavailable NotificationOutcomeName = "PnsUnavailable"
	// PnsUnreachable: Push service was unresponsive.
	PnsUnreachable NotificationOutcomeName = "PnsUnreachable"
	// Skipped: Count of duplicate registrations (same PNS handle found, different registration ID).
	Skipped NotificationOutcomeName = "Skipped"
	// Success: Successfully sent the request to some number of devices.
	Success NotificationOutcomeName = "Success"
	// Throttled: Push service denied access due to throttling.
	Throttled NotificationOutcomeName = "Throttled"
	// UnknownError: An unknown error happened.
	UnknownError NotificationOutcomeName = "UnknownError"
	// WrongToken: The PNS handle was not recognized by the PNS as a valid handle.
	WrongToken NotificationOutcomeName = "WrongToken"
)

Public constants

Variables

This section is empty.

Functions

This section is empty.

Types

type Headers

type Headers map[string]string

Headers structure

type Installation

type Installation struct {
	InstallationID     string                               `json:"installationId,omitempty"`
	LastActiveOn       *time.Time                           `json:"lastActiveOn,omitempty"`
	ExpirationTime     *time.Time                           `json:"expirationTime,omitempty"`
	LastUpdate         *time.Time                           `json:"lastUpdate,omitempty"`
	Platform           InstallationPlatform                 `json:"platform,omitempty"`
	PushChannel        string                               `json:"pushChannel,omitempty"`
	ExpiredPushChannel bool                                 `json:"expiredPushChannel,omitempty"`
	Tags               []string                             `json:"tags,omitempty"`
	Templates          map[string]InstallationTemplate      `json:"templates,omitempty"`
	SecondaryTiles     map[string]InstallationSecondaryTile `json:"secondaryTiles,omitempty"`
}

Installation is a device installation in the hub

type InstallationChange

type InstallationChange struct {
	Op    InstallationChangeOp `json:"op,omitempty"`
	Path  string               `json:"path,omitempty"`
	Value string               `json:"value,omitempty"`
}

InstallationChange is a device installation change

func AddSecondaryTile

func AddSecondaryTile(name string, secondaryTile InstallationSecondaryTile) InstallationChange

AddSecondaryTile adds a secondary tile to the installation Deprecated: doesn't appear to be supported

func AddSecondaryTileTag

func AddSecondaryTileTag(name, tag string) InstallationChange

AddSecondaryTileTag adds a tag to a secondary tile in the installation

func AddSecondaryTileTemplate

func AddSecondaryTileTemplate(name, templateName string, template InstallationTemplate) InstallationChange

AddSecondaryTileTemplate adds a template to the installation

func AddTag

func AddTag(tag string) InstallationChange

AddTag adds a tag to the installation

func AddTemplate

func AddTemplate(name string, template InstallationTemplate) InstallationChange

AddTemplate adds a template to the installation

func AddTemplateTag

func AddTemplateTag(name, tag string) InstallationChange

AddTemplateTag adds a tag to a template in the installation

func RemoveSecondaryTile

func RemoveSecondaryTile(name string) InstallationChange

RemoveSecondaryTile removes a secondary tile from the installation Deprecated: doesn't appear to be supported

func RemoveSecondaryTileTag

func RemoveSecondaryTileTag(name, tag string) InstallationChange

RemoveSecondaryTileTag removes a tag from a secondary tile in the installation

func RemoveSecondaryTileTemplate

func RemoveSecondaryTileTemplate(name, template string) InstallationChange

RemoveSecondaryTileTemplate removes a template from the installation

func RemoveTag

func RemoveTag(tag string) InstallationChange

RemoveTag removes a tag from the installation

func RemoveTemplate

func RemoveTemplate(name string) InstallationChange

RemoveTemplate removes a template from the installation

func RemoveTemplateTag

func RemoveTemplateTag(name, tag string) InstallationChange

RemoveTemplateTag removes a tag from a template in the installation

func SetPushChannel

func SetPushChannel(pushChannel string) InstallationChange

SetPushChannel sets the installation push channel

func SetSecondaryTilePushChannel

func SetSecondaryTilePushChannel(name, pushChannel string) InstallationChange

SetSecondaryTilePushChannel sets the push channel on a secondary tile in the installation

func SetSecondaryTileTags

func SetSecondaryTileTags(name string, tags ...string) InstallationChange

SetSecondaryTileTags sets the tags on a secondary tile in the installation

func SetSecondaryTileTemplateBody

func SetSecondaryTileTemplateBody(name, template, body string) InstallationChange

SetSecondaryTileTemplateBody sets the body on a template in the installation

func SetSecondaryTileTemplateHeaders

func SetSecondaryTileTemplateHeaders(name, template string, headers map[string]string) InstallationChange

SetSecondaryTileTemplateHeaders sets the headers on a template in the installation

func SetSecondaryTileTemplateTags

func SetSecondaryTileTemplateTags(name, template string, tags ...string) InstallationChange

SetSecondaryTileTemplateTags sets the tags on a template in the installation

func SetSecondaryTileTemplates

func SetSecondaryTileTemplates(name string, templates map[string]InstallationTemplate) InstallationChange

SetSecondaryTileTemplates sets the installation templates

func SetSecondaryTiles

func SetSecondaryTiles(secondaryTiles map[string]InstallationSecondaryTile) InstallationChange

SetSecondaryTiles sets the installation secondary tiles Deprecated: doesn't appear to be supported

func SetTags

func SetTags(tags ...string) InstallationChange

SetTags sets the installation tags

func SetTemplateBody

func SetTemplateBody(name, body string) InstallationChange

SetTemplateBody sets the body on a template in the installation

func SetTemplateHeaders

func SetTemplateHeaders(name string, headers map[string]string) InstallationChange

SetTemplateHeaders sets the headers on a template in the installation

func SetTemplateTags

func SetTemplateTags(name string, tags ...string) InstallationChange

SetTemplateTags sets the tags on a template in the installation

func SetTemplates

func SetTemplates(templates map[string]InstallationTemplate) InstallationChange

SetTemplates sets the installation templates Deprecated: doesn't appear to be supported

type InstallationChangeOp

type InstallationChangeOp string

InstallationChangeOp is the installation change operation

type InstallationPlatform

type InstallationPlatform string

InstallationPlatform is the installation platform

type InstallationSecondaryTile

type InstallationSecondaryTile struct {
	PushChannel string                          `json:"pushChannel,omitempty"`
	Tags        []string                        `json:"tags,omitempty"`
	Templates   map[string]InstallationTemplate `json:"templates,omitempty"`
}

InstallationSecondaryTile is a device installation secondary tile

type InstallationTemplate

type InstallationTemplate struct {
	Body    string            `json:"body,omitempty"`
	Headers map[string]string `json:"headers,omitempty"`
	Expiry  *time.Time        `json:"expiry,omitempty"`
	Tags    []string          `json:"tags,omitempty"`
}

InstallationTemplate is a device installation template

type Notification

type Notification struct {
	Format  NotificationFormat
	Payload []byte
}

Notification is a message that can be sent through the hub

func NewNotification

func NewNotification(format NotificationFormat, payload []byte) (*Notification, error)

NewNotification initializes and returns Notification pointer

func (*Notification) String

func (n *Notification) String() string

String returns Notification string representation

type NotificationDetails

type NotificationDetails struct {
	ID                string                `xml:"NotificationId"`
	State             NotificationState     `xml:"State"`
	EnqueueTime       string                `xml:"EnqueueTime"`
	StartTime         string                `xml:"StartTime"`
	EndTime           string                `xml:"EndTime"`
	Body              string                `xml:"NotificationBody"`
	TargetPlatforms   string                `xml:"TargetPlatforms"`
	ApnsOutcomeCounts *NotificationOutcomes `xml:"ApnsOutcomeCounts"`
	GcmOutcomeCounts  *NotificationOutcomes `xml:"GcmOutcomeCounts"`
}

NotificationDetails is the detailed information about a sent or scheduled message

type NotificationFormat

type NotificationFormat string

NotificationFormat is the format of a notification

func (NotificationFormat) GetContentType

func (f NotificationFormat) GetContentType() string

GetContentType returns Content-Type associated with NotificationFormat

func (NotificationFormat) IsValid

func (f NotificationFormat) IsValid() bool

IsValid identifies whether notification format is valid

type NotificationHub

type NotificationHub struct {
	SasKeyValue string
	SasKeyName  string
	HubURL      *url.URL
	// contains filtered or unexported fields
}

NotificationHub is a client for sending messages through Azure Notification Hubs

func NewNotificationHub

func NewNotificationHub(connectionString, hubPath string) *NotificationHub

NewNotificationHub initializes and returns NotificationHub pointer

func (*NotificationHub) Install

func (h *NotificationHub) Install(ctx context.Context, installation Installation) (err error)

Install sends a device installation to the Azure hub

func (*NotificationHub) Installation

func (h *NotificationHub) Installation(ctx context.Context, installationID string) (raw []byte, installation *Installation, err error)

Installation reads one specific installation

func (*NotificationHub) NotificationDetails

func (h *NotificationHub) NotificationDetails(ctx context.Context, notificationID string) (details *NotificationDetails, raw []byte, err error)

NotificationDetails reads one specific registration

func (*NotificationHub) Register

func (h *NotificationHub) Register(ctx context.Context, r Registration) (raw []byte, registrationResult *RegistrationResult, err error)

Register sends a device registration to the Azure hub

func (*NotificationHub) RegisterWithTemplate

func (h *NotificationHub) RegisterWithTemplate(ctx context.Context, r TemplateRegistration) (raw []byte, registrationResult *RegistrationResult, err error)

RegisterWithTemplate sends a device registration with template to the Azure hub

func (*NotificationHub) Registration

func (h *NotificationHub) Registration(ctx context.Context, registrationID string) (raw []byte, registrationResult *RegistrationResult, err error)

Registration reads one specific registration

func (*NotificationHub) Registrations

func (h *NotificationHub) Registrations(ctx context.Context) (raw []byte, registrations *Registrations, err error)

Registrations reads all registrations

func (*NotificationHub) Schedule

func (h *NotificationHub) Schedule(ctx context.Context, n *Notification, tags *string, deliverTime time.Time) (raw []byte, telemetry *NotificationTelemetry, err error)

Schedule publishes a scheduled notification Format tags according to https://docs.microsoft.com/en-us/azure/notification-hubs/notification-hubs-tags-segment-push-message or nil if no tags should be used

func (*NotificationHub) Send

func (h *NotificationHub) Send(ctx context.Context, n *Notification, tags *string) (raw []byte, telemetry *NotificationTelemetry, err error)

Send publishes notification directly Format tags according to https://docs.microsoft.com/en-us/azure/notification-hubs/notification-hubs-tags-segment-push-message ex. "(follows_RedSox || follows_Cardinals) && location_Boston" or nil if no tags should be used

func (*NotificationHub) SendDirect

func (h *NotificationHub) SendDirect(ctx context.Context, n *Notification, deviceHandle string) (raw []byte, telemetry *NotificationTelemetry, err error)

SendDirect publishes notification to a specific device

func (*NotificationHub) SendDirectBatch

func (h *NotificationHub) SendDirectBatch(ctx context.Context, n *Notification, deviceHandles ...string) (raw []byte, telemetry *NotificationTelemetry, err error)

SendDirectBatch publishes notification to a collection of devices

func (*NotificationHub) SetExpirationTimeGenerator

func (h *NotificationHub) SetExpirationTimeGenerator(e utils.ExpirationTimeGenerator)

SetExpirationTimeGenerator makes is possible to use a custom generator

func (*NotificationHub) SetHTTPClient

func (h *NotificationHub) SetHTTPClient(c utils.HTTPClient)

SetHTTPClient makes it possible to use a custom http client

func (*NotificationHub) Uninstall

func (h *NotificationHub) Uninstall(ctx context.Context, installationID string) (err error)

Uninstall sends a device installation delete to the Azure hub

func (*NotificationHub) Unregister

func (h *NotificationHub) Unregister(ctx context.Context, registration RegisteredDevice) (err error)

Unregister sends a device registration delete to the Azure hub

func (*NotificationHub) Update

func (h *NotificationHub) Update(ctx context.Context, installationID string, changes ...InstallationChange) (err error)

Update sends a collection of installation changes to the Azure hub

type NotificationOutcome

type NotificationOutcome struct {
	Name  NotificationOutcomeName `xml:"Name"`
	Count int                     `xml:"Count"`
}

NotificationOutcome name value pair for statistics

type NotificationOutcomeName

type NotificationOutcomeName string

NotificationOutcomeName is a possible outcome of a notification

type NotificationOutcomes

type NotificationOutcomes struct {
	Outcomes []NotificationOutcome `xml:"Outcome"`
}

NotificationOutcomes array of outcomes

type NotificationState

type NotificationState string

NotificationState is the state of the notification

type NotificationTelemetry

type NotificationTelemetry struct {
	NotificationMessageID string `json:"notificationMessageID,omitempty"`
}

NotificationTelemetry is the id of a sent or scheduled message

func NewNotificationTelemetryFromHTTPResponse

func NewNotificationTelemetryFromHTTPResponse(response *http.Response) (*NotificationTelemetry, error)

NewNotificationTelemetryFromHTTPResponse reads the Location header from URL Notification Telemetry is only available for Standard tier Notification Hubs.

func NewNotificationTelemetryFromLocationURL

func NewNotificationTelemetryFromLocationURL(url string) *NotificationTelemetry

NewNotificationTelemetryFromLocationURL create Telemetry from Location URL

type RegisteredDevice

type RegisteredDevice struct {
	DeviceID       string     `xml:"-"              json:"deviceID,omitempty"`
	ETag           string     `xml:"ETag"           json:"eTag,omitempty"`
	ExpirationTime *time.Time `xml:"-"              json:"expirationTime,omitempty"`
	Template       string     `xml:"BodyTemplate"   json:"template,omitempty"`
	RegistrationID string     `xml:"RegistrationId" json:"registrationID,omitempty"`
	Tags           []string   `xml:"-"              json:"tags,omitempty"`

	DeviceToken          *string `xml:"DeviceToken"       json:"-"`
	ExpirationTimeString *string `xml:"ExpirationTime"    json:"-"`
	GcmRegistrationID    *string `xml:"GcmRegistrationId" json:"-"`
	TagsString           *string `xml:"Tags"              json:"-"`
}

RegisteredDevice is a device registration to the hub

type Registration

type Registration struct {
	DeviceID           string             `json:"deviceID,omitempty"`
	ExpirationTime     *time.Time         `json:"expirationTime,omitempty"`
	NotificationFormat NotificationFormat `json:"service,omitempty"`
	RegistrationID     string             `json:"registrationID,omitempty"`
	Tags               string             `json:"tags,omitempty"`
}

Registration is a device registration to the hub

func NewRegistration

func NewRegistration(deviceID string, expirationTime *time.Time, notificationFormat NotificationFormat,
	registrationID string, tags string) *Registration

NewRegistration initializes and returns a Notification pointer

type RegistrationContent

type RegistrationContent struct {
	Format           NotificationFormat `xml:"-" json:"format,omitempty"`
	Target           TargetPlatform     `xml:"-" json:"target,omitempty"`
	RegisteredDevice *RegisteredDevice  `xml:"-" json:"registeredDevice,omitempty"`

	AppleRegistrationDescription         *RegisteredDevice `xml:"AppleRegistrationDescription"         json:"-"`
	AppleTemplateRegistrationDescription *RegisteredDevice `xml:"AppleTemplateRegistrationDescription" json:"-"`
	GcmRegistrationDescription           *RegisteredDevice `xml:"GcmRegistrationDescription"           json:"-"`
	GcmTemplateRegistrationDescription   *RegisteredDevice `xml:"GcmTemplateRegistrationDescription"   json:"-"`
}

RegistrationContent is information about a specific device registration

type RegistrationResult

type RegistrationResult struct {
	ID                  string               `xml:"id"        json:"id,omitempty"`
	Published           *time.Time           `xml:"published" json:"published,omitempty"`
	RegistrationContent *RegistrationContent `xml:"content"   json:"content,omitempty"`
	Title               string               `xml:"title"     json:"title,omitempty"`
	Updated             *time.Time           `xml:"updated"   json:"updated,omitempty"`
}

RegistrationResult is the response from registration

type Registrations

type Registrations struct {
	ID      string               `xml:"id"      json:"id,omitempty"`
	Title   string               `xml:"title"   json:"title,omitempty"`
	Updated *time.Time           `xml:"updated" json:"updated,omitempty"`
	Entries []RegistrationResult `xml:"entry"   json:"entries,omitempty"`
}

Registrations is a list of RegistrationResults

type TargetPlatform

type TargetPlatform string

TargetPlatform is the specific platform

func (TargetPlatform) IsValid

func (f TargetPlatform) IsValid() bool

IsValid identifies whether target is valid

type TemplateRegistration

type TemplateRegistration struct {
	DeviceID       string         `json:"deviceID,omitempty"`
	ExpirationTime *time.Time     `json:"expirationTime,omitempty"`
	RegistrationID string         `json:"registrationID,omitempty"`
	Tags           string         `json:"tags,omitempty"`
	Platform       TargetPlatform `json:"platform,omitempty"`
	Template       string         `json:"template,omitempty"`
}

TemplateRegistration is a device registration to the hub supporting a template

func NewTemplateRegistration

func NewTemplateRegistration(deviceID string, expirationTime *time.Time, registrationID string, tags string,
	platform TargetPlatform, template string) *TemplateRegistration

NewTemplateRegistration initializes and returns a TemplateNotification pointer

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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