更改推送

This commit is contained in:
2024-09-18 17:03:26 +08:00
parent cc463fc7c4
commit 93182c3985
11 changed files with 128 additions and 27 deletions

View File

@@ -1,6 +1,8 @@
package com.aiosman.riderpro
import android.content.Context
import android.util.Log
import cn.jpush.android.api.JPushInterface
import com.aiosman.riderpro.data.AccountService
import com.aiosman.riderpro.data.AccountServiceImpl
import com.google.android.gms.tasks.OnCompleteListener
@@ -9,7 +11,21 @@ import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.launch
object Messaging {
fun InitFCM(scope: CoroutineScope) {
fun RegistDevice(scope: CoroutineScope, context: Context) {
registerJpush(scope, context)
// registerFCM(scope)
}
fun registerJpush(scope: CoroutineScope, context: Context) {
val accountService: AccountService = AccountServiceImpl()
val regId = JPushInterface.getRegistrationID(context)
scope.launch {
accountService.registerMessageChannel(client = "jpush", identifier = regId)
}
}
fun registerFCM(scope: CoroutineScope) {
val accountService: AccountService = AccountServiceImpl()
FirebaseMessaging.getInstance().token.addOnCompleteListener(OnCompleteListener { task ->
if (!task.isSuccessful) {
@@ -27,4 +43,5 @@ object Messaging {
}
})
}
}