Skip to content

Commit

Permalink
Merge branch 'main' into fix-nscoding
Browse files Browse the repository at this point in the history
# Conflicts:
#	CHANGELOG.md
  • Loading branch information
jaxdesmarais committed Jan 31, 2025
2 parents 923e22d + f5db1d0 commit cef957d
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Braintree iOS SDK Release Notes

## unreleased
* BraintreeVenmo
* Allow universal links to be set without a return URL scheme (fixes #1505)
* BraintreeCore
* Update to use `NSSecureCoding` protocol (fixes #1508)

Expand Down
14 changes: 10 additions & 4 deletions Sources/BraintreeVenmo/BTVenmoClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,20 @@ import BraintreeCore
apiClient.sendAnalyticsEvent(BTVenmoAnalytics.tokenizeStarted, isVaultRequest: shouldVault, linkType: linkType)
let returnURLScheme = BTAppContextSwitcher.sharedInstance._returnURLScheme

if returnURLScheme.isEmpty {
if (universalLink?.absoluteString.isEmpty == true || universalLink?.absoluteString == nil) && returnURLScheme.isEmpty {
NSLog(
"%@ Venmo requires a return URL scheme to be configured via [BTAppContextSwitcher setReturnURLScheme:]",
"%@ Venmo requires a return URL scheme or universal link to be configured.",
BTLogLevelDescription.string(for: .critical)
)
notifyFailure(with: BTVenmoError.appNotAvailable, completion: completion)
notifyFailure(
with: BTVenmoError.invalidReturnURL("Venmo requires a return URL scheme or universal link to be configured."),
completion: completion
)
return
} else if let bundleIdentifier = bundle.bundleIdentifier, !returnURLScheme.hasPrefix(bundleIdentifier) {
} else if
let bundleIdentifier = bundle.bundleIdentifier,
!returnURLScheme.hasPrefix(bundleIdentifier)
&& (universalLink?.absoluteString.isEmpty == true || universalLink?.absoluteString == nil) {
NSLog(
// swiftlint:disable:next line_length
"%@ Venmo requires [BTAppContextSwitcher setReturnURLScheme:] to be configured to begin with your app's bundle ID (%@). Currently, it is set to (%@)",
Expand Down
14 changes: 14 additions & 0 deletions UnitTests/BraintreeVenmoTests/BTVenmoClient_Tests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,20 @@ class BTVenmoClient_Tests: XCTestCase {
let venmoClient = BTVenmoClient(apiClient: mockAPIClient)
BTAppContextSwitcher.sharedInstance.returnURLScheme = ""

let expectation = expectation(description: "authorization callback")
venmoClient.tokenize(venmoRequest) { venmoAccount, error in
guard let error = error as NSError? else { return }
XCTAssertEqual(error.domain, BTVenmoError.errorDomain)
XCTAssertEqual(error.code, BTVenmoError.invalidReturnURL("").errorCode)
expectation.fulfill()
}

waitForExpectations(timeout: 2)
}

func testTokenizeVenmoAccount_whenReturnURLSchemeAndUniversalLinkIsNil_andCallsBackWithError() {
let venmoClient = BTVenmoClient(apiClient: mockAPIClient)

let expectation = expectation(description: "authorization callback")
venmoClient.tokenize(venmoRequest) { venmoAccount, error in
guard let error = error as NSError? else {return}
Expand Down

0 comments on commit cef957d

Please sign in to comment.