Documentation
¶
Overview ¶
Package pushbots is an unoficiall API wrapper around pushbots (http://www.pushbots.com) REST api
Documentation about the API can be found at https://pushbots.com/developer/rest Use it to send push notifications for both android and ios for fun and profit
Index ¶
- Constants
- type PushBots
- func (pushbots *PushBots) AddNotificationType(token, platform, alias, notificationType string) error
- func (pushBots *PushBots) ApplyEndpointOverride(endpointOverride string)
- func (pushbots *PushBots) Badge(token, platform string, badgeCount int) error
- func (pushbots *PushBots) Batch(platform, msg, sound, badge string, ...) error
- func (pushbots *PushBots) Broadcast(platform string, msg, sound, badge string, payload map[string]interface{}) error
- func (pushbots *PushBots) Geo(token, platform, lat, lng string) error
- func (pushbots *PushBots) RecordAnalytics(token, platform, stats string) error
- func (pushbots *PushBots) RegisterDevice(token, platform, lat, lng string, notificationTypes, tags []string, ...) error
- func (pushbots *PushBots) RemoveNotificationType(token, platform, alias, notificationType string) error
- func (pushbots *PushBots) SendPushToDevice(platform, token, msg, sound, badge string, payload map[string]interface{}) error
- func (pushbots *PushBots) TagDevice(token, platform, alias, tag string) error
- func (pushbots *PushBots) UnTagDevice(token, platform, alias, tag string) error
- func (pushbots *PushBots) UnregisterDevice(token, platform string) error
Examples ¶
Constants ¶
const ( PlatformIos = "0" PlatformAndroid = "1" PlatformAll = "3" )
Constants for the different platforms supported
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type PushBots ¶
type PushBots struct {
AppId string
Secret string
Debug bool
// contains filtered or unexported fields
}
Holds the appid and app secret for use in requests
func NewPushBots ¶
Create a new pushbots object
func (*PushBots) AddNotificationType ¶
func (pushbots *PushBots) AddNotificationType(token, platform, alias, notificationType string) error
Adds a notification type to a device
func (*PushBots) ApplyEndpointOverride ¶
Override the base endpoint used to construct the API urls
func (*PushBots) Batch ¶
func (pushbots *PushBots) Batch(platform, msg, sound, badge string, tags, exceptTags, notificationTypes, exceptNotificationTypes []string, alias, exceptAlias string, payload map[string]interface{}) error
Batch push notifications to matching devices
func (*PushBots) Broadcast ¶
func (pushbots *PushBots) Broadcast(platform string, msg, sound, badge string, payload map[string]interface{}) error
Send a broadcast to multiple devices
Example ¶
package main
import (
"github.com/FunOrDieLTD/go-pushbots"
"log"
)
func main() {
var appId string = "your app id"
var secret string = "your secret"
msg := "Your message"
sound := "your_sound"
badge := "0"
payload := map[string]interface{}{
"your": "custom data here",
}
pushBots := pushbots.NewPushBots(appId, secret, true)
err := pushBots.Broadcast(pushbots.PlatformAll, msg, sound, badge, payload)
if err != nil {
log.Fatal(err)
}
}
Output:
func (*PushBots) RecordAnalytics ¶
Record analytics for a device
func (*PushBots) RegisterDevice ¶
func (pushbots *PushBots) RegisterDevice(token, platform, lat, lng string, notificationTypes, tags []string, alias string) error
Register a device with PushBots
Example ¶
package main
import (
"github.com/FunOrDieLTD/go-pushbots"
"log"
)
func main() {
var appId string = "your app id"
var secret string = "your secret"
deviceToken := "Your device token"
pushBots := pushbots.NewPushBots(appId, secret, true) // true enables debugging
deviceToken = "Your device token"
err := pushBots.RegisterDevice(deviceToken, pushbots.PlatformIos, "", "", []string{}, []string{}, "") // Registers an ios device using only it's token
if err != nil {
log.Fatal(err)
}
}
Output:
func (*PushBots) RemoveNotificationType ¶
func (pushbots *PushBots) RemoveNotificationType(token, platform, alias, notificationType string) error
Removes a notification type from a device
func (*PushBots) SendPushToDevice ¶
func (pushbots *PushBots) SendPushToDevice(platform, token, msg, sound, badge string, payload map[string]interface{}) error
Send a push to one device
Example ¶
package main
import (
"github.com/FunOrDieLTD/go-pushbots"
"log"
)
func main() {
var appId string = "your app id"
var secret string = "your secret"
deviceToken := "Your device token"
msg := "Your message"
sound := "your_sound"
badge := "0"
payload := map[string]interface{}{
"your": "custom data here",
}
pushBots := pushbots.NewPushBots(appId, secret, true) // true enables debugging
err := pushBots.SendPushToDevice(pushbots.PlatformIos, deviceToken, msg, sound, badge, payload)
if err != nil {
log.Fatal(err)
}
}
Output:
func (*PushBots) TagDevice ¶
Add a tag to a device
Example ¶
package main
import (
"github.com/FunOrDieLTD/go-pushbots"
"log"
)
func main() {
var appId string = "your app id"
var secret string = "your secret"
deviceToken := "Your device token"
pushBots := pushbots.NewPushBots(appId, secret, true) // true enables debugging
deviceToken = "Your device token"
tag := "your_new_tag"
err := pushBots.TagDevice(deviceToken, pushbots.PlatformIos, "", tag)
if err != nil {
log.Fatal(err)
}
}
Output:
func (*PushBots) UnTagDevice ¶
Remove a tag from a device
func (*PushBots) UnregisterDevice ¶
Unregister a device
