Skip to content

Migrate Swift sample from WKWebView to ASWebAuthenticationSession#511

Draft
markmur wants to merge 1 commit into
mainfrom
migrate-demo-to-aswebauthenticationsession
Draft

Migrate Swift sample from WKWebView to ASWebAuthenticationSession#511
markmur wants to merge 1 commit into
mainfrom
migrate-demo-to-aswebauthenticationsession

Conversation

@markmur

@markmur markmur commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

What changes are you making?

Migrate the CheckoutKitSwiftDemo customer account sign-in and sign-out flows from an app-owned WKWebView to ASWebAuthenticationSession.

This gives OAuth ownership to the system authentication UI and uses the shared browser session by default, allowing the demo to reuse existing Shopify browser state and authentication methods such as passkeys. The authentication session now receives its callback directly, so the customer account URL handling in SceneDelegate and the embedded login sheet are no longer needed.

The updated flow also:

  • accepts an explicit presentation anchor and exposes async sign-in/sign-out operations
  • validates the callback URL and OAuth state before exchanging the authorization code
  • distinguishes cancellation, invalid callbacks, and authorization failures
  • prevents multiple authentication sessions from running concurrently
  • performs interactive browser logout while always clearing the local session
  • resets the cart and invalidates Checkout Kit when authentication state changes
  • avoids logging token claims or customer information
  • form-encodes token requests correctly

This PR keeps the implementation scoped to the demo app. Moving the customer account functionality into a reusable SDK product is handled separately.

How to test

  1. Configure the Swift demo with a Customer Account API shop ID, client ID, and registered redirect URI.
  2. Build and launch CheckoutKitSwiftDemo.
  3. Tap Log in and then Sign In.
  4. Continue through the system authentication prompt and verify the account screen shows the authenticated state.
  5. Open checkout and verify the cart uses the authenticated customer account.
  6. Cancel a sign-in attempt and verify the demo returns without presenting an error.
  7. Tap Sign Out, complete the browser logout, and verify the local account and cart are cleared.
  8. Start sign-in again and verify the previous Shopify browser session has been logged out.

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 the SwiftPM/CocoaPods version snippets in platforms/swift/README.md (major version only)
Releasing a new Embedded Checkout Protocol version?
  • I have bumped embeddedCheckoutProtocolAndroid in platforms/android/gradle/libs.versions.toml
  • I have updated protocol/languages/kotlin/embedded-checkout-protocol/api/embedded-checkout-protocol.api if the public API changed
Releasing a new Android version?
  • I have bumped checkoutKitAndroid in platforms/android/gradle/libs.versions.toml
  • 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.

@github-actions github-actions Bot added the #gsd:50662 Rebase Checkout Kit on UCP label Jul 23, 2026
@markmur markmur changed the title Migrate from WKWebView to ASWebAuthenticationSession # Please enter the commit message for your changes. Lines starting # with '#' will be ignored, and an empty message aborts the commit. # # HEAD detached at 79208073 # Changes to be committed: # modified Migrate from WKWebView to ASWebAuthenticationSession Jul 23, 2026

markmur commented Jul 23, 2026

Copy link
Copy Markdown
Contributor Author

…he commit message for your changes. Lines starting # with '#' will be ignored, and an empty message aborts the

commit. # # HEAD detached at 7920807 # Changes to be committed: # modified:  platforms/swift/Samples/CheckoutKitSwiftDemo/CheckoutKitSwiftDemo/Sources/App/SceneDelegate.swift #
modified:  platforms/swift/Samples/CheckoutKitSwiftDemo/CheckoutKitSwiftDemo/Sources/Lib/KeychainHelper.swift # modified:
platforms/swift/Samples/CheckoutKitSwiftDemo/CheckoutKitSwiftDemo/Sources/Localizable.xcstrings # modified:
platforms/swift/Samples/CheckoutKitSwiftDemo/CheckoutKitSwiftDemo/Sources/Scenes/AccountView.swift # modified:
platforms/swift/Samples/CheckoutKitSwiftDemo/CheckoutKitSwiftDemo/Sources/Scenes/CustomerAccounts/CustomerAccountLoginView.swift # modified:
platforms/swift/Samples/CheckoutKitSwiftDemo/CheckoutKitSwiftDemo/Sources/Scenes/CustomerAccounts/CustomerAccountManager.swift #
@markmur
markmur force-pushed the migrate-demo-to-aswebauthenticationsession branch from c9738a9 to a1d8d89 Compare July 23, 2026 18:13
@markmur markmur changed the title Migrate from WKWebView to ASWebAuthenticationSession Migrate Swift sample from WKWebView to ASWebAuthenticationSession Jul 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

#gsd:50662 Rebase Checkout Kit on UCP

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant