fix crash when not using play services

This commit is contained in:
greenart7c3
2023-08-21 19:20:14 -03:00
parent ec3b07147c
commit a1f116909f
@@ -1,5 +1,6 @@
package com.vitorpamplona.amethyst.service.notifications
import android.util.Log
import com.google.firebase.messaging.FirebaseMessaging
import com.vitorpamplona.amethyst.AccountInfo
import kotlinx.coroutines.Dispatchers
@@ -8,6 +9,10 @@ import kotlinx.coroutines.tasks.await
class PushNotificationUtils {
suspend fun init(accounts: List<AccountInfo>) = with(Dispatchers.IO) {
// get user notification token provided by firebase
RegisterAccounts(accounts).go(FirebaseMessaging.getInstance().token.await())
try {
RegisterAccounts(accounts).go(FirebaseMessaging.getInstance().token.await())
} catch (e: Exception) {
Log.e("Firebase token", "failed to get firebase token", e)
}
}
}