Skip to content

Remove legacy checkout-bridge in swift#251

Open
kiftio wants to merge 1 commit into
mainfrom
remove-obsolete-checkout-bridge
Open

Remove legacy checkout-bridge in swift#251
kiftio wants to merge 1 commit into
mainfrom
remove-obsolete-checkout-bridge

Conversation

@kiftio
Copy link
Copy Markdown
Contributor

@kiftio kiftio commented Jun 3, 2026

What changes are you making?

Remove the legacy Checkout Bridge, I don't believe we should be sending messages via window.MobileCheckoutSdk.dispatchMessage in this version of the kit.

If we intend to keep these messages, we'll need to incorporate them into the new protocol

How to test

n/a

Before you merge

Important

  • I've added tests to support my implementation
  • I have read and agree with the Contribution Guidelines
  • I have read and agree with the Code of Conduct
  • I've updated the relevant platform README (platforms/swift/README.md and/or platforms/android/README.md)

Releasing a new Swift version?
  • I have bumped the version in ShopifyCheckoutKit.podspec
  • I have bumped the version in platforms/swift/Sources/ShopifyCheckoutKit/ShopifyCheckoutKit.swift
  • I have updated platforms/swift/CHANGELOG.md
  • I have updated the SwiftPM/CocoaPods version snippets in platforms/swift/README.md (major version only)
Releasing a new Android version?
  • I have bumped the versionName in platforms/android/lib/build.gradle
  • I have updated platforms/android/CHANGELOG.md
  • I have updated the Gradle/Maven version snippets in platforms/android/README.md

Tip

See the Contributing documentation for the full release process per platform.

@kiftio kiftio requested a review from a team as a code owner June 3, 2026 11:33
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 3, 2026

React Native — Coverage Report

Lines Statements Branches Functions
Coverage: 92%
91.59% (316/345) 87.25% (178/204) 100% (82/82)

@kiftio kiftio changed the title remove legacy checkout-bridge Remove legacy checkout-bridge in swift Jun 3, 2026
@kieran-osgood-shopify
Copy link
Copy Markdown
Contributor

Approve of the fact we're removing the code relating to presented and instrumentation - was it necessary to move the rest of the CheckoutBridge into CheckoutWebview?

Is this because android has moved away from using a checkoutbridge class?

@kiftio
Copy link
Copy Markdown
Contributor Author

kiftio commented Jun 3, 2026

Approve of the fact we're removing the code relating to presented and instrumentation - was it necessary to move the rest of the CheckoutBridge into CheckoutWebview?

Is this because android has moved away from using a checkoutbridge class?

No! was a bit heavy handed, bringing it back

@kiftio kiftio force-pushed the remove-obsolete-checkout-bridge branch from 3bb618e to eca3130 Compare June 3, 2026 11:52
@kiftio kiftio marked this pull request as draft June 3, 2026 11:55
@kiftio kiftio force-pushed the remove-obsolete-checkout-bridge branch 2 times, most recently from 8446081 to 64ec0c4 Compare June 3, 2026 12:30
@kiftio kiftio marked this pull request as ready for review June 3, 2026 12:30
func test_init_withNilEntryPoint_shouldSetCorrectUserAgent() {
let viewController = CheckoutWebViewController(checkoutURL: url, entryPoint: nil)

let expectedUserAgent = CheckoutBridge.applicationName(entryPoint: nil)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure this line should change? The agent is set to CheckoutBridge.applicationName configuration.applicationNameForUserAgent = CheckoutBridge.applicationName(entryPoint: entryPoint)

class CheckoutBridgeTests: XCTestCase {
func testReturnsStandardUserAgent() {
let version = ShopifyCheckoutKit.version
XCTAssertEqual(CheckoutBridge.applicationName, "ShopifyCheckoutKit/\(version) (iOS;Swift \(SwiftVersion.current!))")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

applicationName wasn't deleted - should this test remain?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines +34 to +38
window.console.error('EmbeddedCheckoutProtocol.postMessage is not available.');
}
} catch (error) {
if (window && window.console && window.console.error) {
window.console.error('Failed to post message to checkout', error);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add some prefixes to these logs to make it obvious that they came from Checkout Kit

})();
"""

webView.evaluateJavaScript(script)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're still dispatching the evaluateJavascript we are missing a test case here
Feels like we could still do with a sure test on this - sendMessage has the same issue as before in that it is a sync method with an async body - if we add a completion handler arg to sendResponse and forward that to webView.evaluateJavascript(script, completionHandler) we can write a test without the wait for flake

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I was questioning whether we could live without testing the call to evaluateJavaScript, but we can add it if preferred

@kiftio kiftio force-pushed the remove-obsolete-checkout-bridge branch from 64ec0c4 to f82d17a Compare June 3, 2026 16:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants