XuqmGroup-AndroidSDK/sdk-push/src/main/java/com/xuqm/sdk/push/PushSDK.kt
2026-04-21 22:07:29 +08:00

36 行
972 B
Kotlin

package com.xuqm.sdk.push
import android.content.Context
import com.xuqm.sdk.XuqmSDK
import com.xuqm.sdk.network.ApiClient
import com.xuqm.sdk.push.api.PushApi
import com.xuqm.sdk.utils.DeviceUtils
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
object PushSDK {
private val api: PushApi by lazy { ApiClient.create() }
private val scope = CoroutineScope(Dispatchers.IO)
fun registerToken(context: Context, appId: String, userId: String, token: String) {
XuqmSDK.requireInit()
val vendor = DeviceUtils.getVendor()
scope.launch {
runCatching {
api.registerToken(appId, userId, vendor, token)
}
}
}
fun unregisterToken(appId: String, userId: String) {
XuqmSDK.requireInit()
scope.launch {
runCatching {
api.unregisterToken(appId, userId)
}
}
}
}