Overview
A PushDevice represents one browser profile or installed application.
installation_id is a stable ID chosen by your application. push_token is the current FCM token returned by Firebase. Firebase may refresh a token, so register the same installation_id again with the new token instead of creating a second logical installation.
Device registration must be performed from trusted backend code because it uses PulseGrid project credentials.
Setup
1. Obtain the real FCM token in the client application.
2. Send it to your own authenticated backend.
3. Register it with PulseGrid.
4. platform must be android, ios or web.
5. Optionally attach app_user_id, device name, app version, OS version, topics and metadata.
6. Re-register when Firebase refreshes the token.
7. Deactivate the installation when your application decides the device should no longer receive Push.
Code example
await pg.push.registerDevice({
installationId: "browser-c9f09b",
pushToken: fcmToken,
platform: "web",
deviceName: "Customer Chrome",
appVersion: "1.4.0",
topics: ["order-updates"],
});
await pg.push.deactivateDevice({
installationId: "browser-c9f09b",
});
pg.push.register_device(
installation_id="browser-c9f09b",
push_token=fcm_token,
platform="web",
device_name="Customer Chrome",
app_version="1.4.0",
topics=["order-updates"],
)
pg.push.deactivate_device(
installation_id="browser-c9f09b",
)
Notes
The project is inferred from the configured API key in SDK 0.2.0. Cross-project registration is rejected.
Do not invent FCM tokens for delivery testing. Use a token created by the Firebase application connected to the same Firebase project as the PulseGrid Push configuration.