ابرووا
شروع رایگان
☰ فهرست مستندات · مدیریت دستگاه
به‌زودی. Abrova Push به‌زودی فعال می‌شود. این صفحه توضیح می‌دهد چطور کار خواهد کرد؛ هنوز قابل استفاده نیست.
این صفحه هنوز ترجمه نشده — نسخه‌ی انگلیسی نمایش داده می‌شود. English

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#

  1. Register — Device gets push token
  2. Associate — Link to user ID
  3. Subscribe — Add to topics
  4. 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.

One phone stays one device.

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

dart
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

kotlin
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

swift
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

typescript
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

typescript
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.

typescript
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

bash
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.

bash
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

bash
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

bash
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

bash
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

bash
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

bash
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

bash
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.

bash
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#

OptionTypeRequiredDescription
deviceIdstringYesUnique identifier for the device
platformstringYes"android", "ios", or "web"
pushTokenstringNoPush token set by the SDK (on iOS this is the PushKit VoIP token)
apnsTokenstringNoiOS APNs device token, set by the SDK
fcmTokenstringNoFCM token, only with the optional Android FCM bridge
userIdstringNoOptional user ID to associate with device
topicsstring[]NoList of subscribed topics
metadataobjectNoCustom key-value pairs for targeting
appVersionstring-App version reported by the SDK
sdkNamestring-SDK that registered the device, e.g. "android", "ios", "web", "flutter"
sdkVersionstring-Version of that SDK
isActiveboolean-Whether the device receives sends (false after unregister or a permanently invalid token)
updatedAtdate-Last registration or refresh (shown as last seen in the Console)

Best Practices#

Register on Every Launch

Call register() each time your app starts so the device record stays current

Set User ID After Login

Call setUserId() when users log in to enable user-targeted notifications

Clear User ID on Logout

Always call clearUserId() when users log out to prevent wrong-account notifications

Use Metadata for Targeting

Store user preferences, membership tier, or other attributes for segmentation

Let Users Manage Topics

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?".

این صفحه مفید بود؟
گزارش مشکل