mirror of
https://github.com/nikoksr/notify.git
synced 2025-01-10 00:28:36 +02:00
c159e97d01
Co-authored-by: Niko Köser <koeserniko@gmail.com>
2.3 KiB
2.3 KiB
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
- Create a Pushbullet account
- Download Pushbullet on any devices which are to receive notifications
- Copy your Access Token for usage below form https://www.pushbullet.com/#settings
- Copy the Device Nickname of the device you want to post a message to. See https://www.pushbullet.com/#settings/devices
Sample Code
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.
notifier.UseService(service)
// Send a message
err = notifier.Send(
"Hello\n",
"I am a bot written in Go!",
)
if err != nil {
panic(err)
}
}
Steps for Pushbullet SMS
- Follow the above instructions, ensuring that Pushbullet is installed on an Android device.
- Enable 'SMS Sync' is turned on (under the SMS tab on the Android app)
Sample Code
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.
notifier.UseService(service)
// Send a message
err = notifier.Send(
"Hello\n",
"I am a bot written in Go!",
)
if err != nil {
panic(err)
}
}