Skip to content

Commit db18b80

Browse files
committed
Catch huawei init code
1 parent 82c29e9 commit db18b80

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

app/src/huawei/kotlin/org/thoughtcrime/securesms/notifications/HuaweiTokenFetcher.kt

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import kotlinx.coroutines.flow.MutableStateFlow
99
import kotlinx.coroutines.launch
1010
import kotlinx.coroutines.withContext
1111
import org.session.libsession.messaging.notifications.TokenFetcher
12+
import org.session.libsignal.utilities.Log
1213
import javax.inject.Inject
1314
import javax.inject.Singleton
1415

@@ -33,9 +34,13 @@ class HuaweiTokenFetcher @Inject constructor(
3334

3435
init {
3536
GlobalScope.launch {
36-
val instanceId = HmsInstanceId.getInstance(context)
37-
withContext(Dispatchers.Default) {
38-
instanceId.getToken(APP_ID, TOKEN_SCOPE)
37+
try {
38+
val instanceId = HmsInstanceId.getInstance(context)
39+
withContext(Dispatchers.Default) {
40+
instanceId.getToken(APP_ID, TOKEN_SCOPE)
41+
}
42+
} catch (e: Exception) {
43+
Log.e("HuaweiTokenFetcher", "Failed to fetch token", e)
3944
}
4045
}
4146
}

0 commit comments

Comments
 (0)