Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Sample: MobileBuyIntegration] Handle Universal Links #243

Merged
merged 2 commits into from
Nov 13, 2024

Conversation

markmur
Copy link
Contributor

@markmur markmur commented Nov 13, 2024

What changes are you making?

Handle universal links in app, providing configuration settings to enable/disable different routes.


Before you merge

Important


Checklist for releasing a new version
  • I have bumped the version number in the podspec file.
  • I have bumped the version number in the README.
  • I have added a Changelog entry.

Tip

See the Contributing documentation for instructions on how to publish a new version of the library.

@markmur markmur self-assigned this Nov 13, 2024
@markmur markmur force-pushed the markmur/sample-universal-links branch 2 times, most recently from ad5ff11 to ee09b29 Compare November 13, 2024 11:22
@markmur markmur marked this pull request as ready for review November 13, 2024 11:22
@markmur markmur requested a review from a team as a code owner November 13, 2024 11:22
Comment on lines 82 to 115
func scene(_ scene: UIScene, continue userActivity: NSUserActivity) {
guard userActivity.activityType == NSUserActivityTypeBrowsingWeb,
let incomingURL = userActivity.webpageURL else {
return
}

handleUniversalLink(url: incomingURL)
}

func handleUniversalLink(url: URL) {
guard let host = url.host, host == appConfiguration.storefrontDomain else { return }
let storefrontUrl = StorefrontURL(from: url)

switch true {
/// Checkout URLs
case appConfiguration.universalLinks.checkout && storefrontUrl.isCheckout() && !storefrontUrl.isThankYouPage():
presentCheckout(url)
/// Cart URLs
case appConfiguration.universalLinks.cart && storefrontUrl.isCart():
navigateToCart()
/// Product URLs
case appConfiguration.universalLinks.products:
if let slug = storefrontUrl.getProductSlug() {
navigateToProduct(with: slug)
}
/// Open everything else in Safari
default:
UIApplication.shared.open(url)
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the 🧃

@markmur markmur force-pushed the markmur/sample-universal-links branch 3 times, most recently from 74c9b64 to bd62e4a Compare November 13, 2024 11:49
@markmur markmur requested a review from anulind November 13, 2024 11:50
@markmur markmur force-pushed the markmur/sample-universal-links branch from bd62e4a to a68c6cb Compare November 13, 2024 12:06
@markmur markmur merged commit 2a403dd into main Nov 13, 2024
6 checks passed
@markmur markmur deleted the markmur/sample-universal-links branch November 13, 2024 12:32
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.

2 participants