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

fork
Roger Yang 1 year 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.settings
import org.mozilla.fenix.nimbus.FxNimbus
import org.mozilla.fenix.onboarding.ensureMarketingChannelExists
import org.mozilla.fenix.perf.MarkersActivityLifecycleCallbacks
import org.mozilla.fenix.perf.ProfilerMarkerFactProcessor
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()
// 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()
queueRestoreLocale()
queueStorageMaintenance()
queueNotificationPermissionRequest()
}
private fun startMetricsIfEnabled() {

Loading…
Cancel
Save