Browse files

Call the main app's scheme twice.

Once to launch the app and again with `launchedAtLogin`.
  • Loading branch information...
1 parent 584f4cf commit 126d5ecd352c7af19fb4690627c39a9019f3f043 @kgn committed Apr 23, 2012
Showing with 8 additions and 0 deletions.
  1. +6 −0 LaunchAtLoginHelper/LLHAppDelegate.m
  2. +2 −0
@@ -12,8 +12,14 @@
@implementation LLHAppDelegate
- (void)applicationDidFinishLaunching:(NSNotification *)notification{
+ // Call the scheme to launch the app
NSString *scheme = [NSString stringWithFormat:@"%@://", LLURLScheme];
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:scheme]];
+ // Call the app again this time with `launchedAtLogin` so it knows how it was launched
+ NSString *schemeLaunchedAtLogin =
+ [NSString stringWithFormat:@"%@://launchedAtLogin", LLURLScheme];
+ [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:schemeLaunchedAtLogin]];
[NSApp terminate:self];
@@ -2,6 +2,8 @@ When creating a sandboxed app `LSSharedFileListInsertItemURL` can no longer be u
A lot of research was put into this helper app. For example [Apple's docs]( state that `LSRegisterURL` should be used to register the helper app, however this never seemed to work and after further digging it turns out this is a [typo in the docs]( Many examples I found online used `NSWorkspace launchApplication:` to launch the main app, however this was blocked by sandboxing so a url scheme is used instead.
+**LaunchAtLoginHelper** calls the main app's scheme twice, once to launchg the app and then again with `launchedAtLogin` so the main app can know if it has been launched at login. For example [Play by Play]( uses this to hide the app if it was launched at login.
This project contains a [sample app]( to demonstrate how the main app should be configured and how to setup a checkbox to enable and disable launching at login.
# How to use

0 comments on commit 126d5ec

Please sign in to comment.