~whereswaldon/gio-x

ref: 2edae8a2560135f81337aac777a83f170fda1a97 gio-x/notify/niotify_android.go -rw-r--r-- 690 bytes
2edae8a2Chris Waldon scroll: fix screenshot path 6 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
//+build android

package notify

import (
	"git.sr.ht/~whereswaldon/niotify/android"
)

type androidManager struct {
	channel *android.NotificationChannel
}

var _ managerInterface = &androidManager{}

func newManager() (Manager, error) {
	channel, err := android.NewChannel(android.ImportanceDefault, "DEFAULT", "niotify", "background notifications")
	if err != nil {
		return Manager{}, err
	}
	return Manager{
		&androidManager{
			channel: channel,
		},
	}, nil
}

func (a *androidManager) CreateNotification(title, text string) (*Notification, error) {
	notification, err := a.channel.Send(title, text)
	if err != nil {
		return nil, err
	}
	return &Notification{notification}, nil
}