-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
V2 - Add universal link support for macOS #4693
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
base: master
Are you sure you want to change the base?
Conversation
WalkthroughAdds macOS universal link handling: AppDelegate now continues NSUserActivity of type BrowsingWeb, extracts the URL and forwards it to a renamed native handler Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant macOS
participant AppDelegate
participant ObjC as CustomProtocol
participant Go as Frontend
User->>macOS: Open universal link
macOS->>AppDelegate: continueUserActivity(_:restorationHandler:)
rect rgb(230,245,255)
Note over AppDelegate: Check activity.type == BrowsingWeb
AppDelegate->>AppDelegate: Extract NSURL, get absoluteString
end
alt BrowsingWeb
AppDelegate->>ObjC: Call HandleOpenURL(c-string)
ObjC->>Go: cgo exported HandleOpenURL -> openUrlBuffer
Go-->>ObjC: ack/queued
ObjC-->>AppDelegate: return YES
else Other activity
AppDelegate-->>macOS: return NO
end
AppDelegate-->>macOS: return result
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20–30 minutes
Suggested labels
Suggested reviewers
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
✅ Files skipped from review due to trivial changes (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
v2/internal/frontend/desktop/darwin/CustomProtocol.m (1)
5-9: Clean up redundant code.Lines 5 and 7 contain unused code. Line 5 extracts the event parameter but discards the result, and line 7 stores the URL string in
urlStrbut line 9 duplicates the extraction instead of using the variable.Apply this diff to simplify:
+ (void)handleGetURLEvent:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent { - [event paramDescriptorForKeyword:keyDirectObject]; - - NSString *urlStr = [[event paramDescriptorForKeyword:keyDirectObject] stringValue]; - - HandleOpenURL((char*)[[[event paramDescriptorForKeyword:keyDirectObject] stringValue] UTF8String]); + NSString *urlStr = [[event paramDescriptorForKeyword:keyDirectObject] stringValue]; + HandleOpenURL((char*)[urlStr UTF8String]); }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
v2/internal/frontend/desktop/darwin/AppDelegate.m(2 hunks)v2/internal/frontend/desktop/darwin/CustomProtocol.h(1 hunks)v2/internal/frontend/desktop/darwin/CustomProtocol.m(1 hunks)v2/internal/frontend/desktop/darwin/frontend.go(1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: APshenkin
Repo: wailsapp/wails PR: 4484
File: v2/internal/frontend/utils/urlValidator.go:25-31
Timestamp: 2025-08-08T13:15:20.339Z
Learning: In Wails v2 (PR wailsapp/wails#4484), for BrowserOpenURL URL validation (v2/internal/frontend/utils/urlValidator.go), maintainers (APshenkin) prefer not to restrict schemes to an http/https allowlist because supported schemes may vary. The allowlist suggestion is declined; continue with the existing denylist approach and generic validation.
🧬 Code graph analysis (1)
v2/internal/frontend/desktop/darwin/CustomProtocol.h (1)
v2/internal/frontend/desktop/darwin/frontend.go (1)
HandleOpenURL(522-525)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
- GitHub Check: Run Go Tests (ubuntu-24.04, 1.23)
- GitHub Check: Run Go Tests (ubuntu-22.04, 1.23)
- GitHub Check: Run Go Tests (windows-latest, 1.23)
- GitHub Check: Run Go Tests (macos-latest, 1.23)
- GitHub Check: semgrep-cloud-platform/scan
🔇 Additional comments (4)
v2/internal/frontend/desktop/darwin/AppDelegate.m (2)
12-12: LGTM!The import of
CustomProtocol.his necessary to access theHandleOpenURLfunction and follows the existing pattern in this file.
23-32: LGTM! Correct implementation of universal links support.The method correctly implements Apple's universal links pattern:
- Checks for
NSUserActivityTypeBrowsingWebactivity type- Extracts the URL from
webpageURLproperty- Converts to absolute string and passes to the handler
- Returns appropriate boolean values
The memory management and error handling follow the same safe pattern as the existing
openFile:method.v2/internal/frontend/desktop/darwin/CustomProtocol.h (1)
6-6: LGTM! Consistent rename across the codebase.The function signature rename from
HandleCustomProtocoltoHandleOpenURLis consistent with the changes infrontend.go,CustomProtocol.m, andAppDelegate.m. The more generic name appropriately reflects that it now handles both custom protocol URLs and universal links.v2/internal/frontend/desktop/darwin/frontend.go (1)
521-525: LGTM! Consistent rename with appropriate unified handling.The function rename from
HandleCustomProtocoltoHandleOpenURLaligns with the changes in the Objective-C bridge. The implementation correctly maintains the same processing for both custom protocol URLs and universal links, forwarding them throughopenUrlBufferto theMac.OnUrlOpencallback.
|



Description
Provides support for universal links on macOS. https://developer.apple.com/documentation/xcode/supporting-universal-links-in-your-app
Wails already had support for custom scheme deeplinks, however to support universal links it requires additional handling in AppDelegate
Type of change
Please select the option that is relevant.
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration using
wails doctor.Test Configuration
Checklist:
website/src/pages/changelog.mdxwith details of this PRSummary by CodeRabbit
New Features
Documentation