Device Management
Register, manage, and target devices for push notifications. SDK registration on Flutter/Android/iOS/React Native/Web, REST API for backend management, device fields reference.
Register, manage, and target devices for push notifications.
Device Lifecycle#
- Register — Device gets push token
- Associate — Link to user ID
- Subscribe — Add to topics
- Receive — Get notifications
SDK Registration#
The SDK handles device registration automatically. Each platform exposes the same surface.
Call register() on every app launch (or page load, once notification permission is granted). It keeps the device's push token, app version, SDK version and last-seen time current on the server. The native Android, iOS and Web SDKs also refresh a registered device on their own (autoRefresh, on by default): at most once every 24 hours, or sooner when the app version, SDK version, push token or user changed. A refresh never prompts for notification permission.
clearUserId() detaches the user from the device on the server, so the device stops receiving that user's notifications after logout.
Reinstalling an app creates a new device id. The SDKs send a fingerprint of the install (hashed on the device, never a raw device id), so the record left by the previous install is retired instead of staying active for ever. Browsers re-subscribing to Web Push are matched the same way. Devices that stop checking in for 60 days are deactivated as well, and come back on their own the next time the app registers.
Flutter
import 'package:abrova_push/abrova_push.dart';
// Initialize AbrovaPush (only apiKey required)
await AbrovaPush.init(AbrovaPushConfig(
apiKey: 'ab_live_your_api_key',
));
// Register device with optional user ID and metadata
await AbrovaPush.register(
userId: 'user_123',
metadata: {
'tier': 'premium',
'language': 'en',
},
);
// Update user ID after login
await AbrovaPush.setUserId('user_123');
// Clear user ID after logout
await AbrovaPush.clearUserId();
// Topics
await AbrovaPush.subscribeTopic('news');
await AbrovaPush.subscribeTopic('promotions');
await AbrovaPush.unsubscribeTopic('promotions');
// Unregister (e.g., user opts out)
await AbrovaPush.unregister();Android
import ir.abrova.push.sdk.AbrovaPush
// Result arrives in AbrovaPushCallback.onRegistered(deviceId) / onError(error)
AbrovaPush.register(
userId = "user_123",
metadata = mapOf(
"tier" to "premium",
"language" to "en"
)
)
AbrovaPush.setUserId("user_123")
AbrovaPush.clearUserId()
AbrovaPush.subscribeTopic("news")
AbrovaPush.unsubscribeTopic("promotions")
// Stop the push service on this device
AbrovaPush.unregister()iOS
import AbrovaPush
// Result arrives in AbrovaPushDelegate didRegisterWithDeviceId / didFailWithError
AbrovaPush.shared.register(
userId: "user_123",
metadata: [
"tier": "premium",
"language": "en"
]
)
AbrovaPush.shared.setUserId("user_123")
AbrovaPush.shared.clearUserId()
AbrovaPush.shared.subscribeTopic("news")
AbrovaPush.shared.unsubscribeTopic("promotions")
// Disconnect and detach the user on the server
AbrovaPush.shared.unregister()React Native
import AbrovaPush from 'abrova-push-react-native';
await AbrovaPush.register({
userId: 'user_123',
metadata: {
tier: 'premium',
language: 'en',
},
});
await AbrovaPush.setUserId('user_123');
await AbrovaPush.clearUserId();
await AbrovaPush.subscribeTopic('news');
await AbrovaPush.unsubscribeTopic('promotions');
await AbrovaPush.unregister();Web
import AbrovaPush from '@abrova/push-web';
const abrovaPush = new AbrovaPush({ apiKey: 'ab_live_your_api_key' });
await abrovaPush.register({
userId: 'user_123',
metadata: { tier: 'premium' },
});
await abrovaPush.setUserId('user_123');
await abrovaPush.clearUserId();
await abrovaPush.subscribeTopic('news');
await abrovaPush.unsubscribeTopic('promotions');
await abrovaPush.unregister();Node.js SDK#
Manage devices directly from your backend.
import { AbrovaPush } from '@abrova/push-node';
const abrovaPush = new AbrovaPush({
apiKey: 'ab_live_your_api_key',
serverSecret: 'ab_srv_your_server_secret',
});
// List all active devices
const devices = await abrovaPush.devices.list();
// Subscribe / unsubscribe to topic
await abrovaPush.devices.subscribeTopic('device_id', 'news');
await abrovaPush.devices.unsubscribeTopic('device_id', 'news');
// Set / clear the user on a device
await abrovaPush.devices.setUserId('device_id', 'user_123');
await abrovaPush.devices.clearUserId('device_id');
// Permanently delete a device
await abrovaPush.devices.delete('device_id');REST API#
Devices normally register through the SDK. Use these endpoints to manage them from your backend.
Register
curl -X POST "https://push-api.abrova.ir/devices/register" \
-H "x-api-key: ab_live_your_api_key" \
-H "x-server-secret: ab_srv_your_server_secret" \
-H "Content-Type: application/json" \
-d '{
"deviceId": "unique_device_id",
"platform": "android",
"userId": "user_123",
"metadata": {
"tier": "premium"
}
}'Unregister (soft)
Stops sends to the device but keeps it, and its delivery history, in the Console. The device is reactivated automatically the next time the SDK registers.
curl -X POST "https://push-api.abrova.ir/devices/unique_device_id/unregister" \ -H "x-api-key: ab_live_your_api_key" \ -H "x-server-secret: ab_srv_your_server_secret"
Reactivate
curl -X POST "https://push-api.abrova.ir/devices/unique_device_id/reactivate" \ -H "x-api-key: ab_live_your_api_key" \ -H "x-server-secret: ab_srv_your_server_secret"
Delete
curl -X DELETE "https://push-api.abrova.ir/devices/unique_device_id" \ -H "x-api-key: ab_live_your_api_key" \ -H "x-server-secret: ab_srv_your_server_secret"
Subscribe to Topic
curl -X POST "https://push-api.abrova.ir/devices/unique_device_id/topics/news" \ -H "x-api-key: ab_live_your_api_key" \ -H "x-server-secret: ab_srv_your_server_secret"
Unsubscribe from Topic
curl -X DELETE "https://push-api.abrova.ir/devices/unique_device_id/topics/news" \ -H "x-api-key: ab_live_your_api_key" \ -H "x-server-secret: ab_srv_your_server_secret"
Set User ID
curl -X POST "https://push-api.abrova.ir/devices/unique_device_id/user" \
-H "x-api-key: ab_live_your_api_key" \
-H "x-server-secret: ab_srv_your_server_secret" \
-H "Content-Type: application/json" \
-d '{
"userId": "user_123"
}'Clear User ID
curl -X DELETE "https://push-api.abrova.ir/devices/unique_device_id/user" \ -H "x-api-key: ab_live_your_api_key" \ -H "x-server-secret: ab_srv_your_server_secret"
List All Devices
Without page or limit, returns all active devices as an array. With either, returns { items, total, page, limit } and accepts the filters platform, isActive, userId, appVersion, sdkName, sdkVersion, search, lastSeenBefore, lastSeenAfter and failureReason (the device's most recent delivery failure reason). limit defaults to 50 (max 200). Listing devices returns project-wide data, so it needs the server secret; the API key alone is refused.
curl -X GET "https://push-api.abrova.ir/devices?page=1&limit=50&platform=ios" \ -H "x-api-key: ab_live_your_api_key" \ -H "x-server-secret: ab_srv_your_server_secret"
Device Fields#
| Option | Type | Required | Description |
|---|---|---|---|
| deviceId | string | Yes | Unique identifier for the device |
| platform | string | Yes | "android", "ios", or "web" |
| pushToken | string | No | Push token set by the SDK (on iOS this is the PushKit VoIP token) |
| apnsToken | string | No | iOS APNs device token, set by the SDK |
| fcmToken | string | No | FCM token, only with the optional Android FCM bridge |
| userId | string | No | Optional user ID to associate with device |
| topics | string[] | No | List of subscribed topics |
| metadata | object | No | Custom key-value pairs for targeting |
| appVersion | string | - | App version reported by the SDK |
| sdkName | string | - | SDK that registered the device, e.g. "android", "ios", "web", "flutter" |
| sdkVersion | string | - | Version of that SDK |
| isActive | boolean | - | Whether the device receives sends (false after unregister or a permanently invalid token) |
| updatedAt | date | - | Last registration or refresh (shown as last seen in the Console) |
Best Practices#
Call register() each time your app starts so the device record stays current
Call setUserId() when users log in to enable user-targeted notifications
Always call clearUserId() when users log out to prevent wrong-account notifications
Store user preferences, membership tier, or other attributes for segmentation
Give users control over which topics they subscribe to in your app settings
View and manage all registered devices in the Devices Dashboard. Each row shows the platform, SDK name and version, app version and last-seen time; filter by any of them, and unregister or reactivate a device from the list. Click any row to open its device profile — a full page showing IDs, the raw metadata block (with copy-as-JSON), subscribed topics, and which saved segments the device currently belongs to. Handy for debugging targeting issues and answering "why isn't this device receiving my campaign?".