Merge pull request #552 from greenart7c3/fix-crash

fix crash when getting firebase token without play services
pull/553/head
Vitor Pamplona 2023-08-21 18:30:02 -04:00 zatwierdzone przez GitHub
commit c6124376df
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
1 zmienionych plików z 6 dodań i 1 usunięć

Wyświetl plik

@ -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)
}
}
}