2021-02-01 12:26:59 +02:00
|
|
|
# Pushbullet Usage
|
|
|
|
|
|
|
|
Ensure that you have already navigated to your GOPATH and installed the following packages:
|
|
|
|
|
|
|
|
* `go get -u github.com/nikoksr/notify`
|
|
|
|
* `go get github.com/cschomburg/go-pushbullet` - You might need this one too
|
|
|
|
|
|
|
|
## Steps for Pushbullet App
|
|
|
|
|
|
|
|
These are general and very high level instructions
|
|
|
|
|
2021-02-01 19:29:48 +02:00
|
|
|
1. Create a Pushbullet account
|
|
|
|
2. Download Pushbullet on any devices which are to receive notifications
|
2021-02-01 12:26:59 +02:00
|
|
|
3. Copy your *Access Token* for usage below form https://www.pushbullet.com/#settings
|
|
|
|
4. Copy the *Device Nickname* of the device you want to post a message to. See https://www.pushbullet.com/#settings/devices
|
|
|
|
|
|
|
|
## Sample Code
|
|
|
|
|
|
|
|
```go
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/nikoksr/notify"
|
|
|
|
"github.com/nikoksr/notify/service/pushbullet"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
|
|
|
|
notifier := notify.New()
|
|
|
|
|
|
|
|
// Provide your Access Token
|
|
|
|
service := pushbullet.New("AccessToken")
|
|
|
|
|
|
|
|
// Passing a device nickname as receiver for our messages.
|
|
|
|
service.AddReceivers("DeviceNickname")
|
|
|
|
|
|
|
|
// Tell our notifier to use the Pushbullet service. You can repeat the above process
|
|
|
|
// for as many services as you like and just tell the notifier to use them.
|
2021-02-06 11:20:21 +02:00
|
|
|
notifier.UseServices(service)
|
2021-02-01 12:26:59 +02:00
|
|
|
|
|
|
|
// Send a message
|
2021-02-01 14:57:53 +02:00
|
|
|
err = notifier.Send(
|
2021-02-01 12:26:59 +02:00
|
|
|
"Hello\n",
|
|
|
|
"I am a bot written in Go!",
|
|
|
|
)
|
|
|
|
|
2021-02-01 14:57:53 +02:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
# Steps for Pushbullet SMS
|
|
|
|
|
|
|
|
1. Follow the above instructions, ensuring that Pushbullet is installed on an Android device.
|
|
|
|
2. Enable 'SMS Sync' is turned on (under the SMS tab on the Android app)
|
|
|
|
|
|
|
|
## Sample Code
|
|
|
|
|
|
|
|
```go
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/nikoksr/notify"
|
|
|
|
"github.com/nikoksr/notify/service/pushbullet"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
|
|
|
|
notifier := notify.New()
|
|
|
|
|
|
|
|
// Provide your Access Token and Pushbullet nickname for your mobile device
|
|
|
|
service, err := pushbullet.NewSMS("AccessToken", "PhoneNickname")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Passing a phone number as receiver for our messages.
|
|
|
|
service.AddReceivers("PhoneNumber")
|
|
|
|
|
|
|
|
// Tell our notifier to use the Pushbullet service. You can repeat the above process
|
|
|
|
// for as many services as you like and just tell the notifier to use them.
|
2021-02-06 11:20:21 +02:00
|
|
|
notifier.UseServices(service)
|
2021-02-01 14:57:53 +02:00
|
|
|
|
|
|
|
// Send a message
|
|
|
|
err = notifier.Send(
|
|
|
|
"Hello\n",
|
|
|
|
"I am a bot written in Go!",
|
|
|
|
)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2021-02-01 12:26:59 +02:00
|
|
|
}
|
|
|
|
```
|