Skip to content

Commit

Permalink
In-App Updates: Open app store listing (#23216)
Browse files Browse the repository at this point in the history
  • Loading branch information
momo-ozawa authored May 16, 2024
2 parents 28de9ee + 30d3b03 commit f742dbf
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ struct AppStoreLookupResponse: Decodable {
struct AppStoreInfo: Decodable {
let trackName: String
let trackId: Int
let trackViewUrl: String
let version: String
let releaseNotes: String
let minimumOsVersion: String
Expand Down
13 changes: 8 additions & 5 deletions WordPress/Classes/Services/AppUpdate/AppUpdatePresenter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import WordPressFlux
protocol AppUpdatePresenterProtocol {
func showNotice(using appStoreInfo: AppStoreInfo)
func showBlockingUpdate(using appStoreInfo: AppStoreInfo)
func openAppStore()
func openAppStore(appStoreUrl: String)
}

final class AppUpdatePresenter: AppUpdatePresenterProtocol {
Expand All @@ -20,7 +20,7 @@ final class AppUpdatePresenter: AppUpdatePresenterProtocol {
) { accepted in
if accepted {
WPAnalytics.track(.inAppUpdateAccepted, properties: ["type": "flexible"])
self.openAppStore()
self.openAppStore(appStoreUrl: appStoreInfo.trackViewUrl)
} else {
WPAnalytics.track(.inAppUpdateDismissed)
}
Expand All @@ -40,13 +40,16 @@ final class AppUpdatePresenter: AppUpdatePresenterProtocol {
let viewModel = AppStoreInfoViewModel(appStoreInfo)
let controller = BlockingUpdateViewController(viewModel: viewModel) {
WPAnalytics.track(.inAppUpdateAccepted, properties: ["type": "blocking"])
self.openAppStore()
self.openAppStore(appStoreUrl: appStoreInfo.trackViewUrl)
}
let navigation = UINavigationController(rootViewController: controller)
topViewController.present(navigation, animated: true)
}

func openAppStore() {
// TODO
func openAppStore(appStoreUrl: String) {
guard let url = URL(string: appStoreUrl) else {
return
}
UIApplication.shared.open(url)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ private final class MockAppUpdatePresenter: AppUpdatePresenterProtocol {
didShowBlockingUpdate = true
}

func openAppStore() {
func openAppStore(appStoreUrl: String) {
didOpenAppStore = true
}
}

0 comments on commit f742dbf

Please sign in to comment.