5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-03 20:10:00 +08:00
wails/v3/pkg/application/custom_protocol.m
2025-01-22 19:29:23 +11:00

20 lines
778 B
Objective-C

#include "CustomProtocol.h"
@implementation CustomProtocolSchemeHandler
+ (void)handleGetURLEvent:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent {
[event paramDescriptorForKeyword:keyDirectObject];
NSString *urlStr = [[event paramDescriptorForKeyword:keyDirectObject] stringValue];
HandleCustomProtocol((char*)[[[event paramDescriptorForKeyword:keyDirectObject] stringValue] UTF8String]);
}
@end
void StartCustomProtocolHandler(void) {
NSAppleEventManager *appleEventManager = [NSAppleEventManager sharedAppleEventManager];
[appleEventManager setEventHandler:[CustomProtocolSchemeHandler class]
andSelector:@selector(handleGetURLEvent:withReplyEvent:)
forEventClass:kInternetEventClass
andEventID: kAEGetURL];
}