登出时取消消息推送注册
This commit is contained in:
@@ -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 ->
|
||||
|
||||
Reference in New Issue
Block a user