Android SDK Android
Topic، Subscriber ID، External ID و Alias در Android
مدیریت دستهبندی و هویت کاربر با متدهای آماده Pushfa Android SDK، بدون فراخوانی مستقیم endpointها.
مدل شناسهها
| شناسه | معنی | مدیریت |
|---|---|---|
| FCM token | آدرس فنی Push و قابل تغییر | SDK خودکار |
| Subscriber ID | شناسه پایدار همین نصب تا Uninstall/Clear Data | SDK خودکار |
| External ID | شناسه اصلی حساب کاربر در سیستم شما | setExternalId |
| Custom Alias | شناسههای تکمیلی مانند mobile یا crm_id | addAlias / addAliases |
مدیریت Topic
UUID تاپیک پنل را بفرستید، نه نام نمایشی آن. Callback فهرست فعلی Topicها را برمیگرداند.
val topicUuid = "TOPIC_UUID_FROM_PUSHFA"
Pushfa.subscribeTopic(topicUuid) { result ->
Log.d("Pushfa", "topics=${result.value.orEmpty()}")
}
Pushfa.unsubscribeTopic(topicUuid) { result ->
Log.d("Pushfa", "topics=${result.value.orEmpty()}")
}
Pushfa.getTopics { result ->
val serverTopics = result.value.orEmpty()
}
External ID در Login و Logout
بعد از Login شناسه داخلی کاربر را ثبت کنید. هنگام Logout مقدار null بفرستید تا اعلان حساب قبلی به کاربر بعدی همان دستگاه نرسد.
// Login
Pushfa.setExternalId("USER-123") { result ->
Log.d("Pushfa", "externalId=${result.value}")
}
// Logout
Pushfa.setExternalId(null) { result ->
Log.d("Pushfa", "External ID removed")
}
Pushfa.getExternalId { result ->
val currentExternalId = result.value
}
Custom Alias
Labelها را ثابت انتخاب کنید و برای اطلاعات شخصی مانند شماره موبایل، رضایت و سیاست حریم خصوصی محصول را رعایت کنید.
Pushfa.addAlias("mobile", "09120000000") { result -> }
Pushfa.addAliases(
mapOf(
"crm_id" to "CRM-9",
"tier" to "gold",
"city" to "qazvin",
),
) { result ->
Log.d("Pushfa", "aliases=${result.value}")
}
Pushfa.removeAlias("tier") { result -> }
Pushfa.removeAliases(listOf("crm_id", "mobile")) { result -> }
Pushfa.getAliases { result -> val aliases = result.value.orEmpty() }
