feat: Universal Links handler#2
Open
VasilyPolyuhovich wants to merge 11 commits into
Open
Conversation
Remove Router.handleUserActivity / SimpleRouter.handleUserActivity and the AppRouterBrowseWebActivityType constant. The wrapper saved 2 lines but coupled the library to a specific URL-delivery API (NSUserActivity) and duplicated a system constant. Public surface is now strictly URL-based. Consumers extract webpageURL themselves from .onContinueUserActivity and call navigate(toUniversalLink:), which also makes the library reusable for push payloads, share extensions, and any other URL source. README + UniversalLinkExample updated to show the 2-line integration. Test count: 57 -> 52 (5 handleUserActivity tests removed).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds native Universal Links (UL) handling to
AppRouterPlus, mirroring the existing custom-scheme deep-link API. Fully parameterized — no hard-coded domains/schemes/prefixes.New API:
UniversalLinkConfig— value type bundling allowedHosts / pathPrefix / allowedSchemesURLNavigationHelper.parseUniversalLink(...)— inline + config overloadsURLNavigationHelper.buildUniversalLink(...)— UL URL builder (with/without tab)Router.navigate(toUniversalLink:)— inline + config overloadsRouter.handleUserActivity(_:config:)—NSUserActivity(BrowseWeb) handlerSimpleRouter(plus backfillednavigate(to: URL)for custom-scheme parity)AppRouterBrowseWebActivityTypeconstant (avoids UIKit import for one constant)Key semantics:
allowedHosts(RFC 3986)/appstorevs/app)tabquery: LAST wins on multi-value (matches existingparse)deepPush + .replaceruns async on MainActor Task; returnstrueimmediatelyfalseon invalid input (no throws, no Result — matches existingnavigate(to: URL))Internal change:
Router.deepPushTovisibility relaxed fromprivatetointernalso the new extension can reuse it. No external API impact.Tests: First test target ever added to the library. 57 tests across 6 suites, all passing on iOS 18.5 simulator.
Docs: README section +
Examples/UniversalLinkExample.swift.Test Plan
xcodebuild -scheme AppRouterPlus -destination 'platform=iOS Simulator,name=iPhone 16,OS=18.5' test— expect 57/57 passingUniversalLinkExample.swiftintegration in a sample iOS app:myapp://home?tab=profile→ tab switches, home pushedhttps://example.com/profile?userId=42&tab=profile→ profile tab + profile screenNSUserActivity→handleUserActivityreturns falseExamples/UniversalLinkExample.swiftagainst the library to verify the public API surface is ergonomic