Skip to content

Commit 4ed21f3

Browse files
authored
[V3] Add Venmo install check (#78)
* Add venmo scheme to the allowlist in info.plist. * Add URLOpenet protocol and uiapplication extension * Add Venmo installed validation and pass it to the user script. * Add docstring * Use internal instead of static * Remove bool description * Update CHANGELOG * Update README * Update V3 migration guide
1 parent 7c9305d commit 4ed21f3

File tree

8 files changed

+53
-1
lines changed

8 files changed

+53
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* Bump minimum supported deployment target to iOS 16+
55
* Require Xcode 16.2.0+ and Swift 5.10+
66
* Add the `prefersEphemeralWebBrowserSession` property to the `POPPopupBridge` initializer, which specifies whether to request a private authentication session from the browser.
7+
* Add validation to check if the Venmo app is installed on the device.
78

89
## 2.2.0 (2025-02-05)
910
* Require Xcode 15.0+ and Swift 5.9+ (per [App Store requirements](https://developer.apple.com/news/?id=khzvxn8a))

Demo/Demo/Info.plist

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,5 +58,9 @@
5858
<string>UIInterfaceOrientationLandscapeLeft</string>
5959
<string>UIInterfaceOrientationLandscapeRight</string>
6060
</array>
61+
<key>LSApplicationQueriesSchemes</key>
62+
<array>
63+
<string>com.venmo.touch.v2</string>
64+
</array>
6165
</dict>
6266
</plist>

PopupBridge.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
45CD0C2E2D664D140072C5A4 /* Date+MilisecondTimestamp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45CD0C2D2D664CF50072C5A4 /* Date+MilisecondTimestamp.swift */; };
1212
45CD0C302D6788A10072C5A4 /* Bundle+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45CD0C2F2D67888F0072C5A4 /* Bundle+Extension.swift */; };
1313
45CD0C322D6793FB0072C5A4 /* PopupBridgeAnalytics.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45CD0C312D6793F90072C5A4 /* PopupBridgeAnalytics.swift */; };
14+
45FC74C22D8347B500E50035 /* UIApplication+URLOpener.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45FC74C12D8347AA00E50035 /* UIApplication+URLOpener.swift */; };
1415
62D5EC522B9F753100D09C5D /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = 62D5EC512B9F753100D09C5D /* PrivacyInfo.xcprivacy */; };
1516
79DB9F7F53319F206CDE119E /* Pods_UnitTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 28245E4F1AC5126D54985D88 /* Pods_UnitTests.framework */; };
1617
800A09D82995F143003ED16E /* POPPopupBridge.swift in Sources */ = {isa = PBXBuildFile; fileRef = 800A09D72995F143003ED16E /* POPPopupBridge.swift */; };
@@ -34,6 +35,7 @@
3435
45CD0C2D2D664CF50072C5A4 /* Date+MilisecondTimestamp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Date+MilisecondTimestamp.swift"; sourceTree = "<group>"; };
3536
45CD0C2F2D67888F0072C5A4 /* Bundle+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Bundle+Extension.swift"; sourceTree = "<group>"; };
3637
45CD0C312D6793F90072C5A4 /* PopupBridgeAnalytics.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PopupBridgeAnalytics.swift; sourceTree = "<group>"; };
38+
45FC74C12D8347AA00E50035 /* UIApplication+URLOpener.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIApplication+URLOpener.swift"; sourceTree = "<group>"; };
3739
4EF7C7DDAB0B99FF28DD6541 /* Pods-UnitTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-UnitTests.debug.xcconfig"; path = "Target Support Files/Pods-UnitTests/Pods-UnitTests.debug.xcconfig"; sourceTree = "<group>"; };
3840
6003F58D195388D20070C39A /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
3941
6003F58F195388D20070C39A /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
@@ -163,6 +165,7 @@
163165
A775A08C1DEE4EF0009E67C2 /* PopupBridge */ = {
164166
isa = PBXGroup;
165167
children = (
168+
45FC74C12D8347AA00E50035 /* UIApplication+URLOpener.swift */,
166169
45CD0C2F2D67888F0072C5A4 /* Bundle+Extension.swift */,
167170
45CD0C2D2D664CF50072C5A4 /* Date+MilisecondTimestamp.swift */,
168171
45CD0C2B2D64F0810072C5A4 /* FPTIBatchData.swift */,
@@ -331,6 +334,7 @@
331334
800E789F29E09A2A00D1B0FC /* URLDetailsPayload.swift in Sources */,
332335
45CD0C302D6788A10072C5A4 /* Bundle+Extension.swift in Sources */,
333336
BEF9ED232A2A6A2C005D54AB /* PopupBridgeConstants.swift in Sources */,
337+
45FC74C22D8347B500E50035 /* UIApplication+URLOpener.swift in Sources */,
334338
800A09D82995F143003ED16E /* POPPopupBridge.swift in Sources */,
335339
BE8E37B62A17B79E00181FDA /* WebAuthenticationSession.swift in Sources */,
336340
45CD0C2C2D64F08F0072C5A4 /* FPTIBatchData.swift in Sources */,

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,16 @@ To integrate using Swift Package Manager, select File > Swift Packages > Add Pac
3737

3838
If you look at your app target, you will see that `PopupBridge` is automatically linked as a framework to your app (see General > Frameworks, Libraries, and Embedded Content).
3939

40+
### Allowlist Venmo URL scheme
41+
You must add the following to the queries schemes allowlist in your app's info.plist:
42+
43+
``` xml
44+
<key>LSApplicationQueriesSchemes</key>
45+
<array>
46+
<string>com.venmo.touch.v2</string>
47+
</array>
48+
```
49+
4050
Sample App
4151
-------
4252

Sources/PopupBridge/POPPopupBridge.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ public class POPPopupBridge: NSObject, WKScriptMessageHandler {
1313
private let messageHandlerName = "POPPopupBridge"
1414
private let hostName = "popupbridgev1"
1515
private let webView: WKWebView
16+
private let application: URLOpener = UIApplication.shared
1617
private var webAuthenticationSession: WebAuthenticationSession = WebAuthenticationSession()
1718

1819
private var returnBlock: ((URL) -> Void)? = nil
@@ -92,7 +93,8 @@ public class POPPopupBridge: NSObject, WKScriptMessageHandler {
9293
let javascript = PopupBridgeUserScript(
9394
scheme: PopupBridgeConstants.callbackURLScheme,
9495
scriptMessageHandlerName: messageHandlerName,
95-
host: hostName
96+
host: hostName,
97+
isVenmoInstalled: application.isVenmoAppInstalled()
9698
).rawJavascript
9799

98100
let script = WKUserScript(

Sources/PopupBridge/PopupBridgeUserScript.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ struct PopupBridgeUserScript {
55
let scheme: String
66
let scriptMessageHandlerName: String
77
let host: String
8+
let isVenmoInstalled: Bool
89

910
var rawJavascript: String {
1011
"""
@@ -15,6 +16,8 @@ struct PopupBridgeUserScript {
1516
return '\(scheme)://\(host)/';
1617
};
1718
19+
window.popupBridge.isVenmoInstalled = \(isVenmoInstalled);
20+
1821
window.popupBridge.open = function open(url) {
1922
window.webkit.messageHandlers.\(scriptMessageHandlerName)
2023
.postMessage({
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import UIKit
2+
3+
protocol URLOpener {
4+
5+
func isVenmoAppInstalled() -> Bool
6+
}
7+
8+
extension UIApplication: URLOpener {
9+
10+
/// Indicates whether the Venmo App is installed.
11+
func isVenmoAppInstalled() -> Bool {
12+
guard let venmoURL = URL(string: "com.venmo.touch.v2://") else {
13+
return false
14+
}
15+
return canOpenURL(venmoURL)
16+
}
17+
}

V3_MIGRATION.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,14 @@ See the [CHANGELOG](/CHANGELOG.md) for a complete list of changes. This migratio
55
## Supported Versions
66

77
v3 supports a minimum deployment target of iOS 16+. It requires Xcode 16.2.0+ and Swift 5.10+. If your application contains Objective-C code, the `Enable Modules` build setting must be set to `YES`.
8+
9+
## Venmo
10+
11+
### Allowlist Venmo URL scheme
12+
You must add the following to the queries schemes allowlist in your app's info.plist:
13+
14+
``` xml
15+
<key>LSApplicationQueriesSchemes</key>
16+
<array>
17+
<string>com.venmo.touch.v2</string>
18+
</array>

0 commit comments

Comments
 (0)