mirror of
https://github.com/element-hq/element-android
synced 2024-12-18 07:12:47 +03:00
Update pusher with FCM new token only if using FCM
This commit is contained in:
parent
48498020a0
commit
f65074b3c5
2 changed files with 15 additions and 3 deletions
|
@ -23,6 +23,7 @@ import im.vector.app.R
|
||||||
import im.vector.app.core.di.ActiveSessionHolder
|
import im.vector.app.core.di.ActiveSessionHolder
|
||||||
import im.vector.app.core.pushers.FcmHelper
|
import im.vector.app.core.pushers.FcmHelper
|
||||||
import im.vector.app.core.pushers.PushersManager
|
import im.vector.app.core.pushers.PushersManager
|
||||||
|
import im.vector.app.core.pushers.UnifiedPushHelper
|
||||||
import im.vector.app.core.pushers.VectorMessagingHelper
|
import im.vector.app.core.pushers.VectorMessagingHelper
|
||||||
import im.vector.app.features.settings.VectorPreferences
|
import im.vector.app.features.settings.VectorPreferences
|
||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
|
@ -36,11 +37,16 @@ class FirebaseReceiver : FirebaseMessagingService() {
|
||||||
@Inject lateinit var activeSessionHolder: ActiveSessionHolder
|
@Inject lateinit var activeSessionHolder: ActiveSessionHolder
|
||||||
@Inject lateinit var pushersManager: PushersManager
|
@Inject lateinit var pushersManager: PushersManager
|
||||||
@Inject lateinit var vectorMessagingHelper: VectorMessagingHelper
|
@Inject lateinit var vectorMessagingHelper: VectorMessagingHelper
|
||||||
|
@Inject lateinit var unifiedPushHelper: UnifiedPushHelper
|
||||||
|
|
||||||
override fun onNewToken(token: String) {
|
override fun onNewToken(token: String) {
|
||||||
Timber.d("New Firebase token")
|
Timber.d("New Firebase token")
|
||||||
fcmHelper.storeFcmToken(token)
|
fcmHelper.storeFcmToken(token)
|
||||||
if (vectorPreferences.areNotificationEnabledForDevice() && activeSessionHolder.hasActiveSession()) {
|
if (
|
||||||
|
vectorPreferences.areNotificationEnabledForDevice() &&
|
||||||
|
activeSessionHolder.hasActiveSession() &&
|
||||||
|
unifiedPushHelper.isEmbeddedDistributor()
|
||||||
|
) {
|
||||||
pushersManager.enqueueRegisterPusher(token, getString(R.string.pusher_http_url))
|
pushersManager.enqueueRegisterPusher(token, getString(R.string.pusher_http_url))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -240,11 +240,17 @@ class UnifiedPushHelper @Inject constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
fun isEmbeddedDistributor(): Boolean {
|
fun isEmbeddedDistributor(): Boolean {
|
||||||
return UnifiedPush.getDistributor(context) == context.packageName && fcmHelper.isFirebaseAvailable()
|
return isInternalDistributor() && fcmHelper.isFirebaseAvailable()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun isBackgroundSync(): Boolean {
|
fun isBackgroundSync(): Boolean {
|
||||||
return UnifiedPush.getDistributor(context) == context.packageName && !fcmHelper.isFirebaseAvailable()
|
return isInternalDistributor() && !fcmHelper.isFirebaseAvailable()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun isInternalDistributor(): Boolean {
|
||||||
|
return UnifiedPush.getDistributor(context).isEmpty() ||
|
||||||
|
UnifiedPush.getDistributor(context) == context.packageName
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getPrivacyFriendlyUpEndpoint(): String? {
|
fun getPrivacyFriendlyUpEndpoint(): String? {
|
||||||
|
|
Loading…
Reference in a new issue