forked from signalapp/Signal-Android
-
Notifications
You must be signed in to change notification settings - Fork 171
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1607 from oxen-io/merge/1.19.0
Merge/1.19.0
- Loading branch information
Showing
7 changed files
with
30 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 7 additions & 7 deletions
14
app/src/play/kotlin/org/thoughtcrime/securesms/notifications/FirebaseTokenFetcher.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,19 @@ | ||
package org.thoughtcrime.securesms.notifications | ||
|
||
import com.google.android.gms.tasks.Tasks | ||
import com.google.firebase.iid.FirebaseInstanceId | ||
import com.google.firebase.messaging.FirebaseMessaging | ||
|
||
import kotlinx.coroutines.Dispatchers | ||
import kotlinx.coroutines.isActive | ||
import kotlinx.coroutines.tasks.await | ||
import kotlinx.coroutines.withContext | ||
import javax.inject.Inject | ||
import javax.inject.Singleton | ||
|
||
@Singleton | ||
class FirebaseTokenFetcher @Inject constructor(): TokenFetcher { | ||
val TAG = "FirebaseTF" | ||
|
||
override suspend fun fetch() = withContext(Dispatchers.IO) { | ||
FirebaseInstanceId.getInstance().instanceId | ||
.also(Tasks::await) | ||
.takeIf { isActive } // don't 'complete' task if we were canceled | ||
?.run { result?.token ?: throw exception!! } | ||
FirebaseMessaging.getInstance().token.await().takeIf { isActive } ?: throw Exception("Firebase token is null") | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters