Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions WooCommerce/Classes/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,12 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
let stores = ServiceLocator.stores
let analytics = ServiceLocator.analytics
let pushNotesManager = ServiceLocator.pushNotesManager

/// This is important to initialize early as there are a few code points where the authenticator is used.
ServiceLocator.authenticationManager.initialize()
stores.initializeAfterDependenciesAreInitialized()
setupAnalytics(analytics)

setupAnalytics(analytics)
setupCocoaLumberjack()
setupLibraryLogger()
setupLogLevel(.verbose)
Expand Down Expand Up @@ -224,7 +227,7 @@ extension AppDelegate {
ZendeskProvider.shared.initialize()
}

/// Sets up the WordPress Authenticator.
/// Sets up app analytics.
///
func setupAnalytics(_ analytics: Analytics) {
analytics.initialize()
Expand Down
6 changes: 5 additions & 1 deletion WooCommerce/Classes/ViewRelated/AppCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,11 @@ private extension AppCoordinator {

/// Configures the WPAuthenticator for usage in both logged-in and logged-out states.
func configureAuthenticator() {
authenticationManager.initialize()
if isRunningTests {
/// This is needed to fix crashes in unit tests.
/// The authenticator is initialized in AppDelegate when running the app.
authenticationManager.initialize()
}
authenticationManager.setLoggedOutAppSettings(loggedOutAppSettings)
authenticationManager.displayAuthenticatorIfLoggedOut = { [weak self] in
guard let self, self.isLoggedIn == false else { return nil }
Expand Down