Skip to content
Shiny.NET

Push

NuGet package Shiny.AppDeviceBridge.Push

The push bridge registers and unregisters for push, gives the page the token and tags, raises token events, and can hand push payloads to the page or background.js. It’s backed by Shiny.Push.

Android, iOS, Mac Catalyst, macOS and Windows. Linux has no push and answers 501.

Terminal window
dotnet add package Shiny.AppDeviceBridge.Push
builder.UseAppDeviceBridge(
bridge => bridge.AddPushBridge(o => o.DispatchToWebApp = true),
webApp => { /* … */ }
);
Client C# TypeScript
IPushBridge AddPushBridgeClient() PushBridge

The platform setup is Shiny.Push’s: the aps-environment entitlement and the remote-notification background mode on Apple platforms, google-services.json on Android. How payloads reach background.js is on Native Calls & Background.

import { PushBridge } from "@shinyorg/appdevicebridge";
const push = new PushBridge();
await push.onToken(t => sendToServer(t.token)); // the token can change; keep your server current
await push.onReceived(p => toast(p.title, p.message)); // while the page is open
const status = await push.register();
if (status.token) await sendToServer(status.token);
GET/_bridge/push#

The permission state and the current tokens, without prompting.

C#IPushBridge.GetStatusAsyncTSPushBridge.getStatus
Response
200 PushStatus
PushStatus · 3 fields
accessAccessStateWhether the app may receive pushes.
tokenstring | nullThe provider's token — what a server sends to. Null until registered.
nativeTokenstring | nullThe platform's own token (APNs, FCM) where it differs from token.
POST/_bridge/push/registration#

Requests permission if it has not been decided, then registers with the push provider.

C#IPushBridge.RegisterAsyncTSPushBridge.register
Response
200 PushStatus
PushStatus · 3 fields
accessAccessStateWhether the app may receive pushes.
tokenstring | nullThe provider's token — what a server sends to. Null until registered.
nativeTokenstring | nullThe platform's own token (APNs, FCM) where it differs from token.
DELETE/_bridge/push/registration#

Unregisters from the push provider.

C#IPushBridge.UnregisterAsyncTSPushBridge.unregister
Response
204 No content
GET/_bridge/push/tags#

The tags the device is registered with. Fails with 501 where the provider has no tags.

C#IPushBridge.GetTagsAsyncTSPushBridge.getTags
Response
200 PushTags
PushTags · 1 field
tagsstring[]
Errors
501Not on this platform
PUT/_bridge/push/tags#

Replaces the device's tags. Fails with 501 where the provider has no tags, 409 when it refuses them.

C#IPushBridge.SetTagsAsyncTSPushBridge.setTags
Body
application/json · PushTags
PushTags · 1 field
tagsstring[]
Response
204 No content
Errors
409Conflict501Not on this platform
EVENTpush.token#

The provider issued a new token.

C#IPushBridge.OnTokenAsyncTSPushBridge.onToken
Payload
PushTokenEvent
tokenstring
EVENTpush.unregistered#

The device was unregistered.

C#IPushBridge.OnUnregisteredAsyncTSPushBridge.onUnregistered
Payload
PushTokenEvent
tokenstring
EVENTpush.received#

A push arrived. Raised only when the app hands pushes to the web app.

C#IPushBridge.OnReceivedAsyncTSPushBridge.onReceived
Payload
PushPayload
dataRecord<string, string>The push's data fields.
titlestring | nullThe visible notification's title, when the push carried one.
messagestring | nullThe visible notification's body, when the push carried one.
EVENTpush.entry#

The user opened the app from a push. Raised only when the app hands pushes to the web app.

C#IPushBridge.OnEntryAsyncTSPushBridge.onEntry
Payload
PushPayload
dataRecord<string, string>The push's data fields.
titlestring | nullThe visible notification's title, when the push carried one.
messagestring | nullThe visible notification's body, when the push carried one.

JSON property names are camelCase and enums travel as their names. A ? marks a property the payload may omit;| null one that may be null.

PushStatusobject#

Push permission and registration.

accessAccessStateWhether the app may receive pushes.
tokenstring | nullThe provider's token — what a server sends to. Null until registered.
nativeTokenstring | nullThe platform's own token (APNs, FCM) where it differs from token.
AccessStateenum#

Where a permission stands. Reported by every bridge that needs one; the names match Shiny's own.

"Unknown""NotSupported""NotSetup""Disabled""Restricted""Denied""Available"
PushTagsobject#

The tags a device is registered with.

tagsstring[]
PushTokenEventobject#

A token that was issued or unregistered.

tokenstring
PushPayloadobject#

A push as the web app sees it.

dataRecord<string, string>The push's data fields.
titlestring | nullThe visible notification's title, when the push carried one.
messagestring | nullThe visible notification's body, when the push carried one.

These routes sit under AppDeviceBridgePolicies.Bridges like every other bridge: callers on this device by default. See Security.