Namespace: SpawnDev.SpawnJS.JSObjects
Inherits: SpawnJSObject
Source: JSObjects/PushMessageData.cs
MDN Reference: PushMessageData on MDN
The PushMessageData interface of the Push API provides methods which let you retrieve the push data sent by a server in various formats. https://developer.mozilla.org/en-US/docs/Web/API/PushMessageData
| Signature | Description |
|---|---|
PushMessageData(SpawnJSObjectReference _ref) |
Default deserialize constructor |
| Method | Return Type | Description |
|---|---|---|
ArrayBuffer() |
ArrayBuffer |
Extracts the data as an ArrayBuffer object. |
Blob() |
Blob |
Extracts the data as a Blob object. |
Json() |
T |
Extracts the data as a JSON object. |
Text() |
string |
Extracts the data as a plain text string. |
SpawnDev.SpawnJS Mapping Note: The JavaScript examples below show the standard Web API usage. In SpawnDev.SpawnJS, the same API is available with C# conventions:
- Properties and methods use PascalCase (e.g.,
readyStatebecomesReadyState)- Events use ActionEvent with
+=/-=(e.g.,addEventListener("click", fn)becomesOnClick += handler)- Async methods return
Task<T>instead ofPromise<T>- Objects should be disposed with
usingstatements- Access via
JS.Get<PushMessageData>(...)or constructornew PushMessageData(...)
self.addEventListener("push", (event) => {
const obj = event.data.json();
if (obj.action === "subscribe" || obj.action === "unsubscribe") {
fireNotification(obj, event);
port.postMessage(obj);
} else if (obj.action === "init" || obj.action === "chatMsg") {
port.postMessage(obj);
}
});