Skip to content

Commit dfc41d8

Browse files
author
Paul Von Schrottky
authored
Hot Fix: Open AppStore directly rather than through SKStoreProductViewController (#23276)
2 parents 8424590 + e75a1dd commit dfc41d8

2 files changed

Lines changed: 5 additions & 55 deletions

File tree

RELEASE-NOTES.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
25.0
22
-----
33

4+
24.9.1
5+
-----
6+
* [**] Fix bug where the option to switch to the Jetpack app is broken [#23276]
47

58
24.9
69
-----
Lines changed: 2 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import Foundation
2-
import StoreKit
32

43
class JetpackRedirector {
54

@@ -31,63 +30,11 @@ class JetpackRedirector {
3130

3231
// First, check if the WordPress app can open Jetpack by testing its URL scheme.
3332
// if we can potentially open Jetpack app, let's open it through universal link to avoid scheme conflicts (e.g., a certain game :-).
34-
// finally, if the user might not have Jetpack installed, open App Store view controller through StoreKit.
33+
// finally, if the user might not have Jetpack installed, open App Store
3534
if UIApplication.shared.canOpenURL(jetpackDeepLinkURL) {
3635
UIApplication.shared.open(jetpackUniversalLinkURL)
3736
} else {
38-
showJetpackAppInstallation(fallbackURL: jetpackAppStoreURL)
37+
UIApplication.shared.open(jetpackAppStoreURL)
3938
}
4039
}
41-
42-
private static func showJetpackAppInstallation(fallbackURL: URL) {
43-
let viewController = RootViewCoordinator.sharedPresenter.rootViewController.topmostPresentedViewController
44-
let storeProductVC = SKStoreProductViewController()
45-
let appID = [SKStoreProductParameterITunesItemIdentifier: "1565481562"]
46-
47-
configureNavigationBarAppearance(storeProductVC)
48-
49-
storeProductVC.loadProduct(withParameters: appID) { (result, error) in
50-
if result {
51-
viewController.present(storeProductVC, animated: true)
52-
} else if let error = error {
53-
DDLogError("Failed loading Jetpack App product: \(error.localizedDescription)")
54-
UIApplication.shared.open(fallbackURL)
55-
}
56-
}
57-
}
58-
59-
// MARK: - SKStoreProductViewController navigation bar appearance
60-
61-
/// Sets SKStoreProductViewController navigation bar translucent
62-
///
63-
/// Application's global navigation appearance settings interferes with SKStoreProductViewController
64-
/// which requires for this temporary workaround
65-
private static func configureNavigationBarAppearance(_ controller: SKStoreProductViewController) {
66-
let previousisTranslucentValue = UINavigationBar.appearance().isTranslucent
67-
UINavigationBar.appearance().isTranslucent = true
68-
69-
/// Reset to default translucent value
70-
storeProductViewControllerObserver = StoreProductViewControllerObserver(onDismiss: {
71-
UINavigationBar.appearance().isTranslucent = previousisTranslucentValue
72-
storeProductViewControllerObserver = nil
73-
})
74-
75-
controller.delegate = storeProductViewControllerObserver
76-
}
77-
78-
/// Observe product view controller dismissal
79-
class StoreProductViewControllerObserver: NSObject, SKStoreProductViewControllerDelegate {
80-
private let onDismiss: () -> ()
81-
82-
init(onDismiss: @escaping () -> ()) {
83-
self.onDismiss = onDismiss
84-
super.init()
85-
}
86-
87-
func productViewControllerDidFinish(_ viewController: SKStoreProductViewController) {
88-
onDismiss()
89-
}
90-
}
91-
92-
private static var storeProductViewControllerObserver: StoreProductViewControllerObserver?
9340
}

0 commit comments

Comments
 (0)