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 ¶
var ( ErrUnsupported = platform.ErrUnsupported ErrPermissionDenied = platform.ErrPermissionDenied )
Functions ¶
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.