Close #28021: Add ability to opt in to receiving push notifications on Android 13+ devices

fork
Roger Yang 2 years ago committed by mergify[bot]
parent f42e18a20e
commit 322b9ecf73

@ -80,6 +80,7 @@ import org.mozilla.fenix.ext.isKnownSearchDomain
import org.mozilla.fenix.ext.setCustomEndpointIfAvailable import org.mozilla.fenix.ext.setCustomEndpointIfAvailable
import org.mozilla.fenix.ext.settings import org.mozilla.fenix.ext.settings
import org.mozilla.fenix.nimbus.FxNimbus import org.mozilla.fenix.nimbus.FxNimbus
import org.mozilla.fenix.onboarding.ensureMarketingChannelExists
import org.mozilla.fenix.perf.MarkersActivityLifecycleCallbacks import org.mozilla.fenix.perf.MarkersActivityLifecycleCallbacks
import org.mozilla.fenix.perf.ProfilerMarkerFactProcessor import org.mozilla.fenix.perf.ProfilerMarkerFactProcessor
import org.mozilla.fenix.perf.StartupTimeline import org.mozilla.fenix.perf.StartupTimeline
@ -367,6 +368,16 @@ open class FenixApplication : LocaleAwareApplication(), Provider {
} }
} }
// For Android 13 or above, prompt the user for notification permission at the start.
// Regardless if the user accepts or denies the permission prompt, the prompt will occur only once.
fun queueNotificationPermissionRequest() {
if (SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
queue.runIfReadyOrQueue {
ensureMarketingChannelExists(this)
}
}
}
initQueue() initQueue()
// We init these items in the visual completeness queue to avoid them initing in the critical // We init these items in the visual completeness queue to avoid them initing in the critical
@ -376,6 +387,7 @@ open class FenixApplication : LocaleAwareApplication(), Provider {
queueReviewPrompt() queueReviewPrompt()
queueRestoreLocale() queueRestoreLocale()
queueStorageMaintenance() queueStorageMaintenance()
queueNotificationPermissionRequest()
} }
private fun startMetricsIfEnabled() { private fun startMetricsIfEnabled() {

Loading…
Cancel
Save