bark

package
v0.0.0-...-db4472a Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2024 License: MIT Imports: 9 Imported by: 0

README

Bark

Bark is an application allows you to push customed notifications to your iPhone

Usage

// Create a bark service. `device key` is generated when you install the application. You can use the
// `bark.NewWithServers()` function to create a service with a custom server.
barkService := bark.NewWithServers("your bark device key", bark.DefaultServerURL)

// Or use `bark.New()` to create a service with the default server.
barkService = bark.New("your bark device key")

// Add more servers
barkService.AddReceivers("https://your-bark-server.com")

// Tell our notifier to use the bark service.
notify.UseServices(barkService)

// Send a test message.
_ = notify.Send(
    context.Background(),
    "Subject/Title",
    "The actual message - Hello, you awesome gophers! :)",
)

Documentation

Overview

Package bark provides a service for sending messages to bark.

Usage:

package main

import (
    "context"
    "log"

    "github.com/nikoksr/notify"
    "github.com/nikoksr/notify/service/bark"
)

func main() {
    // Create a bark service. `device key` is generated when you install the application. You can use the
    // `bark.NewWithServers` function to create a service with a custom server.
    barkService := bark.NewWithServers("your bark device key", bark.DefaultServerURL)

    // Or use `bark.New` to create a service with the default server.
    barkService = bark.New("your bark device key")

    // Tell our notifier to use the bark service.
    notify.UseServices(barkService)

    // Send a test message.
    _ = notify.Send(
        context.Background(),
        "Subject/Title",
        "The actual message - Hello, you awesome gophers! :)",
    )
}

Index

Constants

View Source
const DefaultServerURL = "https://api.day.app/"

DefaultServerURL is the default server to use for the bark service.

Variables

This section is empty.

Functions

This section is empty.

Types

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service allow you to configure Bark service.

func New

func New(deviceKey string) *Service

New returns a new instance of Bark service. You can use this service to send messages to bark. By default, the service will use the default server (https://api.day.app/).

func NewWithServers

func NewWithServers(deviceKey string, serverURLs ...string) *Service

NewWithServers returns a new instance of Bark service. You can use this service to send messages to bark. You can specify the servers to send the messages to. By default, the service will use the default server (https://api.day.app/) if you don't specify any servers.

func (*Service) AddReceivers

func (s *Service) AddReceivers(serverURLs ...string)

AddReceivers adds server URLs to the list of servers to use for sending messages. We call it Receivers and not servers because strictly speaking, the server is still receiving the message, and additionally we're following the naming convention of the other services.

func (*Service) Send

func (s *Service) Send(ctx context.Context, subject, content string) error

Send takes a message subject and a message content and sends them to bark application.

Jump to

Keyboard shortcuts

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