2
0
mirror of https://github.com/fork-maintainers/iceraven-browser synced 2024-11-11 13:11:01 +00:00

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

This commit is contained in:
Roger Yang 2022-11-29 12:29:05 -05:00 committed by mergify[bot]
parent f42e18a20e
commit 322b9ecf73

View File

@ -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() {