登出时取消消息推送注册

This commit is contained in:
2024-10-12 10:07:18 +08:00
parent ae4d87c5ab
commit c0956b3b94
7 changed files with 56 additions and 17 deletions

View File

@@ -11,12 +11,17 @@ import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.launch
object Messaging {
fun RegistDevice(scope: CoroutineScope, context: Context) {
fun registerDevice(scope: CoroutineScope, context: Context) {
registerJpush(scope, context)
// registerFCM(scope)
}
suspend fun unregisterDevice(context: Context) {
unregisterJpush(context)
}
fun registerJpush(scope: CoroutineScope, context: Context) {
val accountService: AccountService = AccountServiceImpl()
val regId = JPushInterface.getRegistrationID(context)
@@ -25,6 +30,12 @@ object Messaging {
}
}
private suspend fun unregisterJpush(context: Context) {
val accountService: AccountService = AccountServiceImpl()
val regId = JPushInterface.getRegistrationID(context)
accountService.unregisterMessageChannel(client = "jpush", identifier = regId)
}
fun registerFCM(scope: CoroutineScope) {
val accountService: AccountService = AccountServiceImpl()
FirebaseMessaging.getInstance().token.addOnCompleteListener(OnCompleteListener { task ->