mirror of
https://github.com/element-hq/element-android
synced 2024-11-24 18:35:40 +03:00
Update deprecated code
This commit is contained in:
parent
9881c9f61c
commit
f0afd5ceea
2 changed files with 11 additions and 9 deletions
|
@ -18,7 +18,7 @@ package im.vector.app.gplay.features.settings.troubleshoot
|
|||
import android.content.Intent
|
||||
import androidx.activity.result.ActivityResultLauncher
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import com.google.firebase.iid.FirebaseInstanceId
|
||||
import com.google.firebase.messaging.FirebaseMessaging
|
||||
import im.vector.app.R
|
||||
import im.vector.app.core.resources.StringProvider
|
||||
import im.vector.app.core.utils.startAddGoogleAccountIntent
|
||||
|
@ -36,7 +36,7 @@ class TestFirebaseToken @Inject constructor(private val context: AppCompatActivi
|
|||
override fun perform(activityResultLauncher: ActivityResultLauncher<Intent>) {
|
||||
status = TestStatus.RUNNING
|
||||
try {
|
||||
FirebaseInstanceId.getInstance().instanceId
|
||||
FirebaseMessaging.getInstance().token
|
||||
.addOnCompleteListener(context) { task ->
|
||||
if (!task.isSuccessful) {
|
||||
val errorMsg = if (task.exception == null) "Unknown" else task.exception!!.localizedMessage
|
||||
|
@ -57,7 +57,7 @@ class TestFirebaseToken @Inject constructor(private val context: AppCompatActivi
|
|||
}
|
||||
status = TestStatus.FAILED
|
||||
} else {
|
||||
task.result?.token?.let { token ->
|
||||
task.result?.let { token ->
|
||||
val tok = token.substring(0, Math.min(8, token.length)) + "********************"
|
||||
description = stringProvider.getString(R.string.settings_troubleshoot_test_fcm_success, tok)
|
||||
Timber.e("Retrieved FCM token success [$tok].")
|
||||
|
|
|
@ -21,7 +21,7 @@ import android.widget.Toast
|
|||
import androidx.core.content.edit
|
||||
import com.google.android.gms.common.ConnectionResult
|
||||
import com.google.android.gms.common.GoogleApiAvailability
|
||||
import com.google.firebase.iid.FirebaseInstanceId
|
||||
import com.google.firebase.messaging.FirebaseMessaging
|
||||
import im.vector.app.R
|
||||
import im.vector.app.core.di.ActiveSessionHolder
|
||||
import im.vector.app.core.di.DefaultSharedPreferences
|
||||
|
@ -71,14 +71,16 @@ object FcmHelper {
|
|||
// 'app should always check the device for a compatible Google Play services APK before accessing Google Play services features'
|
||||
if (checkPlayServices(activity)) {
|
||||
try {
|
||||
FirebaseInstanceId.getInstance().instanceId
|
||||
.addOnSuccessListener(activity) { instanceIdResult ->
|
||||
storeFcmToken(activity, instanceIdResult.token)
|
||||
FirebaseMessaging.getInstance().token
|
||||
.addOnSuccessListener { token ->
|
||||
storeFcmToken(activity, token)
|
||||
if (registerPusher) {
|
||||
pushersManager.registerPusherWithFcmKey(instanceIdResult.token)
|
||||
pushersManager.registerPusherWithFcmKey(token)
|
||||
}
|
||||
}
|
||||
.addOnFailureListener(activity) { e -> Timber.e(e, "## ensureFcmTokenIsRetrieved() : failed") }
|
||||
.addOnFailureListener { e ->
|
||||
Timber.e(e, "## ensureFcmTokenIsRetrieved() : failed")
|
||||
}
|
||||
} catch (e: Throwable) {
|
||||
Timber.e(e, "## ensureFcmTokenIsRetrieved() : failed")
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue