mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-09-20 16:50:58 +02:00
Tries to avoid crash when lacking google services in the play version.
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
*/
|
||||
package com.vitorpamplona.amethyst.service.notifications
|
||||
|
||||
import android.util.Log
|
||||
import com.google.firebase.messaging.FirebaseMessaging
|
||||
import com.vitorpamplona.amethyst.AccountInfo
|
||||
import com.vitorpamplona.amethyst.service.retryIfException
|
||||
@@ -35,12 +36,16 @@ object PushNotificationUtils {
|
||||
accounts: List<AccountInfo>,
|
||||
okHttpClient: (String) -> OkHttpClient,
|
||||
) = with(Dispatchers.IO) {
|
||||
val token = FirebaseMessaging.getInstance().token.await()
|
||||
if (hasInit?.equals(accounts) == true && lastToken == token) {
|
||||
return@with
|
||||
}
|
||||
try {
|
||||
val token = FirebaseMessaging.getInstance().token.await()
|
||||
if (hasInit?.equals(accounts) == true && lastToken == token) {
|
||||
return@with
|
||||
}
|
||||
|
||||
registerToken(token, accounts, okHttpClient)
|
||||
registerToken(token, accounts, okHttpClient)
|
||||
} catch (e: Exception) {
|
||||
Log.e("PushNotificationUtils", "Failed to get Firebase token", e)
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun checkAndInit(
|
||||
|
Reference in New Issue
Block a user