Skip to content

Commit a6e1033

Browse files
Merge pull request #19653 from wordpress-mobile/task/19601-overlay-cta
Jetpack Focus: Hook up the CTA button for the fullscreen overlay
2 parents 362ecc4 + 331d360 commit a6e1033

File tree

4 files changed

+43
-29
lines changed

4 files changed

+43
-29
lines changed

WordPress/Classes/ViewRelated/Jetpack/Branding/Coordinator/JetpackBrandingCoordinator.swift

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3,37 +3,10 @@ import UIKit
33
/// A class containing convenience methods for the the Jetpack branding experience
44
class JetpackBrandingCoordinator {
55

6-
/// Used to "guess" if the Jetpack app is already installed.
7-
/// The check is done from the WordPress side.
8-
///
9-
/// Note: The string values should kept in-sync with Jetpack's URL scheme.
10-
///
11-
static var jetpackDeepLinkScheme: String {
12-
#if DEBUG
13-
return "jpdebug"
14-
#elseif INTERNAL_BUILD
15-
return "jpinternal"
16-
#elseif ALPHA_BUILD
17-
return "jpalpha"
18-
#else
19-
return "jetpack"
20-
#endif
21-
}
22-
236
static func presentOverlay(from viewController: UIViewController, redirectAction: (() -> Void)? = nil) {
247

258
let action = redirectAction ?? {
26-
guard let jetpackDeepLinkURL = URL(string: "\(jetpackDeepLinkScheme)://app"),
27-
let jetpackUniversalLinkURL = URL(string: "https://jetpack.com/app"),
28-
let jetpackAppStoreURL = URL(string: "https://apps.apple.com/app/jetpack-website-builder/id1565481562") else {
29-
return
30-
}
31-
32-
// First, check if the WordPress app can open Jetpack by testing its URL scheme.
33-
// 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, direct them to App Store page.
35-
let urlToOpen = UIApplication.shared.canOpenURL(jetpackDeepLinkURL) ? jetpackUniversalLinkURL : jetpackAppStoreURL
36-
UIApplication.shared.open(urlToOpen)
9+
JetpackRedirector.redirectToJetpack()
3710
}
3811

3912
let jetpackOverlayViewController = JetpackOverlayViewController(viewFactory: makeJetpackOverlayView, redirectAction: action)
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import Foundation
2+
3+
class JetpackRedirector {
4+
5+
/// Used to "guess" if the Jetpack app is already installed.
6+
/// The check is done from the WordPress side.
7+
///
8+
/// Note: The string values should kept in-sync with Jetpack's URL scheme.
9+
///
10+
static var jetpackDeepLinkScheme: String {
11+
#if DEBUG
12+
return "jpdebug"
13+
#elseif INTERNAL_BUILD
14+
return "jpinternal"
15+
#elseif ALPHA_BUILD
16+
return "jpalpha"
17+
#else
18+
return "jetpack"
19+
#endif
20+
}
21+
22+
static func redirectToJetpack() {
23+
guard let jetpackDeepLinkURL = URL(string: "\(jetpackDeepLinkScheme)://app"),
24+
let jetpackUniversalLinkURL = URL(string: "https://jetpack.com/app"),
25+
let jetpackAppStoreURL = URL(string: "https://apps.apple.com/app/jetpack-website-builder/id1565481562") else {
26+
return
27+
}
28+
29+
// First, check if the WordPress app can open Jetpack by testing its URL scheme.
30+
// if we can potentially open Jetpack app, let's open it through universal link to avoid scheme conflicts (e.g., a certain game :-).
31+
// finally, if the user might not have Jetpack installed, direct them to App Store page.
32+
let urlToOpen = UIApplication.shared.canOpenURL(jetpackDeepLinkURL) ? jetpackUniversalLinkURL : jetpackAppStoreURL
33+
UIApplication.shared.open(urlToOpen)
34+
}
35+
}

WordPress/Classes/ViewRelated/Jetpack/Branding/Fullscreen Overlay/JetpackFullscreenOverlayViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ class JetpackFullscreenOverlayViewController: UIViewController {
218218

219219

220220
@IBAction func switchButtonPressed(_ sender: Any) {
221-
// TODO: Add here action to redirect to the JP app
221+
JetpackRedirector.redirectToJetpack()
222222
viewModel.trackSwitchButtonTapped()
223223
}
224224

WordPress/WordPress.xcodeproj/project.pbxproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1556,6 +1556,8 @@
15561556
803C493C283A7C0C00003E9B /* QuickStartChecklistHeader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 803C493A283A7C0C00003E9B /* QuickStartChecklistHeader.swift */; };
15571557
803C493E283A7C2200003E9B /* QuickStartChecklistHeader.xib in Resources */ = {isa = PBXBuildFile; fileRef = 803C493D283A7C2200003E9B /* QuickStartChecklistHeader.xib */; };
15581558
803C493F283A7C2200003E9B /* QuickStartChecklistHeader.xib in Resources */ = {isa = PBXBuildFile; fileRef = 803C493D283A7C2200003E9B /* QuickStartChecklistHeader.xib */; };
1559+
803D90F7292F0188007CC0D0 /* JetpackRedirector.swift in Sources */ = {isa = PBXBuildFile; fileRef = 803D90F6292F0188007CC0D0 /* JetpackRedirector.swift */; };
1560+
803D90F8292F0188007CC0D0 /* JetpackRedirector.swift in Sources */ = {isa = PBXBuildFile; fileRef = 803D90F6292F0188007CC0D0 /* JetpackRedirector.swift */; };
15591561
803DE81328FFAE36007D4E9C /* RemoteConfigStore.swift in Sources */ = {isa = PBXBuildFile; fileRef = 803DE81228FFAE36007D4E9C /* RemoteConfigStore.swift */; };
15601562
803DE81428FFAE36007D4E9C /* RemoteConfigStore.swift in Sources */ = {isa = PBXBuildFile; fileRef = 803DE81228FFAE36007D4E9C /* RemoteConfigStore.swift */; };
15611563
803DE81628FFAEF2007D4E9C /* RemoteConfigParameter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 803DE81528FFAEF2007D4E9C /* RemoteConfigParameter.swift */; };
@@ -6839,6 +6841,7 @@
68396841
80293CF6284450AD0083F946 /* WordPress-Swift.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "WordPress-Swift.h"; sourceTree = "<group>"; };
68406842
803C493A283A7C0C00003E9B /* QuickStartChecklistHeader.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QuickStartChecklistHeader.swift; sourceTree = "<group>"; };
68416843
803C493D283A7C2200003E9B /* QuickStartChecklistHeader.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = QuickStartChecklistHeader.xib; sourceTree = "<group>"; };
6844+
803D90F6292F0188007CC0D0 /* JetpackRedirector.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JetpackRedirector.swift; sourceTree = "<group>"; };
68426845
803DE81228FFAE36007D4E9C /* RemoteConfigStore.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RemoteConfigStore.swift; sourceTree = "<group>"; };
68436846
803DE81528FFAEF2007D4E9C /* RemoteConfigParameter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RemoteConfigParameter.swift; sourceTree = "<group>"; };
68446847
803DE81828FFB7B5007D4E9C /* RemoteConfigParameterTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RemoteConfigParameterTests.swift; sourceTree = "<group>"; };
@@ -10607,6 +10610,7 @@
1060710610
children = (
1060810611
3F43704328932F0100475B6E /* JetpackBrandingCoordinator.swift */,
1060910612
803DE820290642B4007D4E9C /* JetpackFeaturesRemovalCoordinator.swift */,
10613+
803D90F6292F0188007CC0D0 /* JetpackRedirector.swift */,
1061010614
801D9519291AC0B00051993E /* JetpackOverlayFrequencyTracker.swift */,
1061110615
);
1061210616
path = Coordinator;
@@ -21009,6 +21013,7 @@
2100921013
596C035E1B84F21D00899EEB /* ThemeBrowserViewController.swift in Sources */,
2101021014
4353BFA9219E0E820009CED3 /* RevisionOperationViewController.swift in Sources */,
2101121015
E2E7EB46185FB140004F5E72 /* WPBlogSelectorButton.m in Sources */,
21016+
803D90F7292F0188007CC0D0 /* JetpackRedirector.swift in Sources */,
2101221017
3F09CCAA2428FF8300D00A8C /* ReaderTabView.swift in Sources */,
2101321018
9808655C203D079B00D58786 /* EpilogueUserInfoCell.swift in Sources */,
2101421019
08216FD41CDBF96000304BA7 /* MenuItemTypeSelectionView.m in Sources */,
@@ -22460,6 +22465,7 @@
2246022465
FABB20F72602FC2C00C8785C /* TopViewedPostStatsRecordValue+CoreDataProperties.swift in Sources */,
2246122466
C3C39B0826F50D3900B1238D /* WordPressSupportSourceTag+Editor.swift in Sources */,
2246222467
FEFC0F8A2731182C001F7F1D /* CommentService+Replies.swift in Sources */,
22468+
803D90F8292F0188007CC0D0 /* JetpackRedirector.swift in Sources */,
2246322469
FABB20F82602FC2C00C8785C /* BaseActivityListViewController.swift in Sources */,
2246422470
98E54FF3265C972900B4BE9A /* ReaderDetailLikesView.swift in Sources */,
2246522471
FABB20F92602FC2C00C8785C /* RequestAuthenticator.swift in Sources */,

0 commit comments

Comments
 (0)