forked from mozilla-mobile/firefox-ios
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MOB-2917] APN Consent on launch Experiment (#800)
* Create APNConsentOnLaunchExperiment and request on launch if needed * Temporarily point to Core's feature branch * Point back to Core main branch * Add debug setting * Handle conflicting experiments * Always initialize Braze independent of experiment * Make isEnabled private * Remove unnecessary notification status retrieval
- Loading branch information
1 parent
a50e6b1
commit 209977f
Showing
9 changed files
with
97 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
Client/Ecosia/Experiments/Unleash/APNConsentOnLaunchExperiment.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// This Source Code Form is subject to the terms of the Mozilla Public | ||
// License, v. 2.0. If a copy of the MPL was not distributed with this | ||
// file, You can obtain one at http://mozilla.org/MPL/2.0/ | ||
|
||
import Foundation | ||
import Core | ||
|
||
struct APNConsentOnLaunchExperiment { | ||
private init() {} | ||
|
||
static var toggleName: Unleash.Toggle.Name { | ||
.apnConsentOnLaunch | ||
} | ||
|
||
private static var isEnabled: Bool { | ||
// Make sure that the other engagement service experiment is not enabled since they are conflicting | ||
Unleash.isEnabled(toggleName) && !Unleash.isEnabled(.braze) | ||
} | ||
|
||
static func requestAPNConsentIfNeeded(delegate: UNUserNotificationCenterDelegate) async { | ||
guard isEnabled, ClientEngagementService.shared.notificationAuthorizationStatus == .notDetermined else { | ||
return | ||
} | ||
Analytics.shared.apnConsentOnLaunchExperiment(.view) | ||
ClientEngagementService.shared.requestAPNConsent(notificationCenterDelegate: delegate) { granted, error in | ||
Analytics.shared.apnConsentOnLaunchExperiment(granted ? .allow : .deny) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters