push

package
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package push receives notifications from your server: APNs on iOS, and Firebase Cloud Messaging on Android.

nimbus native plugin add push

Android needs your Firebase project's google-services.json, at native/android/app/google-services.json. On iOS, turn on Push Notifications for the app in your Apple developer account.

ok, err := push.Request(ctx)
t, err := push.GetToken(ctx)
// send t.Value and t.Service to your server
go push.Watch(ctx, func(m push.Message) { openOrder(m.Data["order"]) })

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Request

func Request(ctx context.Context) (bool, error)

Request asks to show notifications, once.

func Watch

func Watch(ctx context.Context, f func(Message)) error

Watch calls f with each message until ctx ends, including the tap that opened the app. It blocks, so run it from a goroutine in an effect.

Types

type Message

type Message struct {
	Title  string            `json:"title"`  // its heading
	Body   string            `json:"body"`   // its text
	Data   map[string]string `json:"data"`   // what your server sent with it
	Tapped bool              `json:"tapped"` // whether they tapped it to get here
}

Message is a notification that arrived while the app was open, or one that was tapped.

func Messages

func Messages(ctx context.Context) ([]Message, error)

Messages returns what has arrived since the last call.

type Token

type Token struct {
	Value   string `json:"value"`   // send this to your server
	Service string `json:"service"` // "apns" or "fcm"
}

Token is where your server sends to reach this phone.

func GetToken

func GetToken(ctx context.Context) (Token, error)

GetToken registers with APNs or Firebase and returns this phone's token. It can change: send it to your server each time the app starts.

Jump to

Keyboard shortcuts

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