Opening URL at startup

What method should I implement in my cocoa applet so that it opens a URL when it starts up? (http / https, in this case) Ive already implemented URL schemes, I just need to know how I can open my application for notification by URL.

Update: I'm sorry, I did not quite understand. My application is a browser that supports https / http urls, but can only open them when it starts. What can I do to implement open URL support in my application at startup?

+3
source share
4 answers

getURL, , URL- . , AppleEvent applicationWillFinishLaunching: not applicationDidFinishLaunching:. , .

+3

OS X, NSApp ( NSApplication ) applicationDidFinishLaunching: ( ). , NSWorkspace. :

// Your NSApp delegate
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
    [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"http://www.example.com/"]];
}
+8

. Apple getURL.

, , Apple Apple.

+2

, (, Safari) " " HTTP/HTTPS, .

  • .scriptSuite .scriptTerminology . Mac OS X, GetURL.

  • CFBundleURLTypes Info.plist, "URL-", .

  • Info.plist NSAppleScriptEnabled YES.

  • Add a new class to your application as a subclass of NSScriptCommand and implement the selector - (id) performDefaultImplementation. From this function, you will find the URL with a click in [self directParameter]. Pass this to your application URL handler!

Detailed information can be found in the article: http://www.xmldatabases.org/WK/blog/1154_Handling_URL_schemes_in_Cocoa.item

0
source

Source: https://habr.com/ru/post/1728353/


All Articles