mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-30 13:35:18 +00:00
fix: fcm task was not cancelable and cannot remove listeners
This commit is contained in:
parent
d631897a3a
commit
1b417362ae
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,19 @@
|
|||||||
|
@file:JvmName("FcmUtils")
|
||||||
|
package org.thoughtcrime.securesms.loki.utilities
|
||||||
|
|
||||||
|
import com.google.android.gms.tasks.Task
|
||||||
|
import com.google.firebase.iid.FirebaseInstanceId
|
||||||
|
import com.google.firebase.iid.InstanceIdResult
|
||||||
|
import kotlinx.coroutines.*
|
||||||
|
|
||||||
|
|
||||||
|
fun getFcmInstanceId(body: (Task<InstanceIdResult>)->Unit): Job = MainScope().launch(Dispatchers.IO) {
|
||||||
|
val task = FirebaseInstanceId.getInstance().instanceId
|
||||||
|
while (!task.isComplete && isActive) {
|
||||||
|
// wait for task to complete while we are active
|
||||||
|
}
|
||||||
|
if (!isActive) return@launch // don't 'complete' task if we were canceled
|
||||||
|
withContext(Dispatchers.Main) {
|
||||||
|
body(task)
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user