Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions v3/UNRELEASED_CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ After processing, the content will be moved to the main changelog and this file

## Added
<!-- New features, capabilities, or enhancements -->
Add universal link support for macOS by @APshenkin in [PR](https://github.com/wailsapp/wails/pull/4712)

## Changed
<!-- Changes in existing functionality -->
Expand Down
4 changes: 2 additions & 2 deletions v3/pkg/application/application_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -454,8 +454,8 @@ func HandleOpenFile(filePath *C.char) {
}
}

//export HandleCustomProtocol
func HandleCustomProtocol(urlCString *C.char) {
//export HandleOpenURL
func HandleOpenURL(urlCString *C.char) {
urlString := C.GoString(urlCString)
eventContext := newApplicationEventContext()
eventContext.setURL(urlString)
Expand Down
4 changes: 2 additions & 2 deletions v3/pkg/application/application_darwin_delegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@

extern void HandleOpenFile(char *);

// Declarations for Apple Event based custom URL handling
extern void HandleCustomProtocol(char*);
// Declarations for Apple Event based custom URL handling and universal link
extern void HandleOpenURL(char*);

@interface CustomProtocolSchemeHandler : NSObject
+ (void)handleGetURLEvent:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent;
Expand Down
14 changes: 12 additions & 2 deletions v3/pkg/application/application_darwin_delegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@ -(BOOL)application:(NSApplication *)sender openFile:(NSString *)filename
HandleOpenFile((char*)utf8FileName);
return YES;
}
- (BOOL)application:(NSApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray<id<NSUserActivityRestoring>> * _Nullable))restorationHandler {
if ([userActivity.activityType isEqualToString:NSUserActivityTypeBrowsingWeb]) {
NSURL *url = userActivity.webpageURL;
if (url) {
HandleOpenURL((char*)[[url absoluteString] UTF8String]);
return YES;
}
}
return NO;
}
// Create the applicationShouldTerminateAfterLastWindowClosed: method
- (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)theApplication
{
Expand Down Expand Up @@ -46,7 +56,7 @@ - (BOOL)applicationShouldHandleReopen:(NSNotification *)notification
if( hasListeners(EventApplicationShouldHandleReopen) ) {
processApplicationEvent(EventApplicationShouldHandleReopen, @{@"hasVisibleWindows": @(flag)});
}

return TRUE;
}
- (void)handleSecondInstanceNotification:(NSNotification *)note;
Expand Down Expand Up @@ -185,7 +195,7 @@ @implementation CustomProtocolSchemeHandler
+ (void)handleGetURLEvent:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent {
NSString *urlStr = [[event paramDescriptorForKeyword:keyDirectObject] stringValue];
if (urlStr) {
HandleCustomProtocol((char*)[urlStr UTF8String]);
HandleOpenURL((char*)[urlStr UTF8String]);
}
}
@end
Expand Down
Loading