更改推送
This commit is contained in:
@@ -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 {
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user