diff --git a/Sources/SuperwallKit/CustomerCenter/CustomerCenterManager.swift b/Sources/SuperwallKit/CustomerCenter/CustomerCenterManager.swift index 29c79c2e9..61732abd5 100644 --- a/Sources/SuperwallKit/CustomerCenter/CustomerCenterManager.swift +++ b/Sources/SuperwallKit/CustomerCenter/CustomerCenterManager.swift @@ -137,10 +137,20 @@ final class CustomerCenterManager { self?.retainedDelegate = nil onDismiss?() } + presenting.present(controller, animated: presentsAnimated) + // UIKit refuses some presentations (the presenter isn't in a window, or is mid-transition) + // and only logs it, so check that it took the controller before holding on to anything. + if controller.presentingViewController == nil { + Logger.debug( + logLevel: .error, + scope: .customerCenter, + message: "The Customer Center couldn't be presented from \(type(of: presenting))." + ) + return + } retainedDelegate = delegate presentedController = controller presentCount += 1 - presenting.present(controller, animated: presentsAnimated) } /// Dismisses the presented Customer Center, if any. diff --git a/Sources/SuperwallKit/CustomerCenter/UIKit/CustomerCenterViewController.swift b/Sources/SuperwallKit/CustomerCenter/UIKit/CustomerCenterViewController.swift index bfe8de379..dc7c4a776 100644 --- a/Sources/SuperwallKit/CustomerCenter/UIKit/CustomerCenterViewController.swift +++ b/Sources/SuperwallKit/CustomerCenter/UIKit/CustomerCenterViewController.swift @@ -47,8 +47,9 @@ public final class CustomerCenterViewController: UIHostingController