From 681257bea77c9d3df9c87ccbfb64dae9f7752716 Mon Sep 17 00:00:00 2001 From: Jonathan Almeida Date: Tue, 27 Aug 2019 17:15:38 -0400 Subject: [PATCH] For #4960: Initialize push only if available (#4964) --- .../org/mozilla/fenix/FenixApplication.kt | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/org/mozilla/fenix/FenixApplication.kt b/app/src/main/java/org/mozilla/fenix/FenixApplication.kt index 4d32d693c..caa455da5 100644 --- a/app/src/main/java/org/mozilla/fenix/FenixApplication.kt +++ b/app/src/main/java/org/mozilla/fenix/FenixApplication.kt @@ -66,8 +66,6 @@ open class FenixApplication : Application() { return } - setupPush() - // Make sure the engine is initialized and ready to use. components.core.engine.warmUp() @@ -100,12 +98,7 @@ open class FenixApplication : Application() { components.analytics.metrics.start() } - // Sets the PushFeature as the singleton instance for push messages to go to. - // We need the push feature setup here to deliver messages in the case where the service - // starts up the app first. - if (FeatureFlags.sendTabEnabled && components.backgroundServices.pushConfig != null) { - PushProcessor.install(components.backgroundServices.push) - } + setupPush() } private fun registerRxExceptionHandling() { @@ -184,10 +177,18 @@ open class FenixApplication : Application() { } private fun setupPush() { - components - .backgroundServices - .push - .initialize() + // Sets the PushFeature as the singleton instance for push messages to go to. + // We need the push feature setup here to deliver messages in the case where the service + // starts up the app first. + if (FeatureFlags.sendTabEnabled && components.backgroundServices.pushConfig != null) { + val push = components.backgroundServices.push + + // Install the AutoPush singleton to receive messages. + PushProcessor.install(push) + + // Initialize the service. This could potentially be done in a coroutine in the future. + push.initialize() + } } private fun setupCrashReporting() {