Devices Service¶
The Devices service manages device registration for push notifications (FCM). Register a device to receive incoming call alerts and messages even when the app is in the background.
// Access via client
final devices = client.devices;
Platform Types¶
Platform |
Description |
|---|---|
|
Android devices (default) |
|
iOS devices |
|
Web browsers |
Methods¶
register¶
Register a device to receive push notifications. Call this after the user logs in and you have a valid FCM token.
Signature
Future<Map<String, dynamic>> register({
required String fcmToken,
Platform platform = Platform.android,
String? deviceName,
})
Parameters
Parameter |
Type |
Description |
|---|---|---|
|
String |
Firebase Cloud Messaging token from FirebaseMessaging.getToken() |
|
Platform |
Device platform: |
|
String? |
Optional label for the device (e.g. “John’s iPhone”) |
Example
final fcmToken = await FirebaseMessaging.instance.getToken();
await client.devices.register(
fcmToken: fcmToken!,
platform: Platform.android,
deviceName: 'My Phone',
);
unregister¶
Unregister a device so it no longer receives push notifications. Call this on logout.
Signature
Future<Map<String, dynamic>> unregister(String fcmToken)
Parameters
Parameter |
Type |
Description |
|---|---|---|
|
String |
The FCM token of the device to unregister |
Example
await client.devices.unregister(fcmToken);
listDevices¶
List all devices registered by the current user.
Signature
Future<List<Map<String, dynamic>>> listDevices()
Returns
A list of device objects, each containing device_id, platform, device_name, and registered_at.
Example
final devices = await client.devices.listDevices();
for (final device in devices) {
print('${device["device_name"]} - ${device["platform"]}');
}
revokeDevice¶
Revoke access for a specific registered device by its ID.
Signature
Future<Map<String, dynamic>> revokeDevice(String deviceId)
Parameters
Parameter |
Type |
Description |
|---|---|---|
|
String |
The unique device ID returned from |
Example
await client.devices.revokeDevice('device_id_here');