(legacy) update FCM token task with new api
@@ -39,7 +39,7 @@ import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.work.WorkManager
import com.google.android.gms.tasks.OnCompleteListener
-import com.google.firebase.iid.FirebaseInstanceId
+import com.google.firebase.messaging.FirebaseMessaging
import com.msopentech.thali.toronionproxy.OnionProxyManager
import com.typesafe.config.ConfigFactory
import fr.acinq.bitcoin.scala.*
@@ -155,16 +155,12 @@ class EclairNodeService : Service() {
EventBus.getDefault().register(this)
}
Prefs.getFCMToken(applicationContext) ?: run {
- FirebaseInstanceId.getInstance().instanceId
- .addOnCompleteListener(OnCompleteListener { task ->
+ FirebaseMessaging.getInstance().token.addOnCompleteListener(OnCompleteListener { task ->
if (!task.isSuccessful) {
- log.warn("failed to retrieve fcm token", task.exception)
+ log.warn("failed to retrieve fcm token: ", task.exception)
return@OnCompleteListener
}
- log.debug("retrieved fcm token")
- task.result?.token?.let { token ->
- Prefs.saveFCMToken(applicationContext, token)
- }
+ task.result?.let { serviceScope.launch { Prefs.saveFCMToken(applicationContext, it) } }
})
}
appContext = AppContext.getInstance(applicationContext)
