push

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2026 License: MIT Imports: 3 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package push registers the app for remote (push) notifications and reports notifications that arrive or that the user taps.

push.OnOpen(a, func(m push.Message) { route(m.Data) })   // before Run or in OnReady
token, err := push.Register(a)                          // send token to your server

iOS: APNs. Register asks for alert/sound/badge permission if the user was never asked, then returns the device token as lowercase hex. The app needs the aps-environment entitlement (a provisioning profile with Push Notifications); without it Register fails with the system's error. The simulator issues tokens too (iOS 16+ on Apple silicon) and accepts simulated pushes: xcrun simctl push booted <bundle-id> payload.apns.

Android: Firebase Cloud Messaging needs Google services, which Tango does not bundle. Register returns ErrUnsupported until the app wires FCM in (add the Firebase dependency and a FirebaseMessagingService that calls org.tango.host.TangoPush.token / .received / .opened — see docs/mobile-permissions.md); after that it returns the FCM token and the events below work.

Notifications arriving while the app runs in the foreground are shown as banners on iOS and reported with OnReceive. Taps — also the one that launched the app — are reported with OnOpen; register handlers before Run or in OnReady so the launch tap is not missed. Handlers run on the main thread.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnsupported      = platform.ErrUnsupported
	ErrPermissionDenied = platform.ErrPermissionDenied
)

Functions

func OnOpen

func OnOpen(a *tango.App, fn func(Message))

OnOpen calls fn when the user taps a notification.

func OnReceive

func OnReceive(a *tango.App, fn func(Message))

OnReceive calls fn for notifications that arrive while the app runs.

func OnToken

func OnToken(a *tango.App, fn func(token string))

OnToken calls fn with the token whenever the platform issues a new one (after Register, and when FCM rotates it).

func Register

func Register(a *tango.App) (string, error)

Register registers with the push service and returns the token.

Types

type Message

type Message struct {
	ID     string // the notification identifier, when the platform gives one
	Title  string
	Body   string
	Action string         // OnOpen: action identifier of a notification action button, "" for a plain tap
	Data   map[string]any // the whole payload: APNs userInfo (with "aps") on iOS, FCM data on Android
}

Message is a remote notification.

Jump to

Keyboard shortcuts

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