Skip to content

Instantly share code, notes, and snippets.

@neoighodaro
Forked from CPDigitalDarkroom/open_shortcut.m
Created April 5, 2020 10:46
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save neoighodaro/3b573e8f29d09d504d25cc1d3ba26570 to your computer and use it in GitHub Desktop.
Save neoighodaro/3b573e8f29d09d504d25cc1d3ba26570 to your computer and use it in GitHub Desktop.
Open an app shortcut programmatically
- (void)openShortcut:(SBSApplicationShortcutItem *)shortcutItem {
UIHandleApplicationShortcutAction *openAction = [[UIHandleApplicationShortcutAction alloc] initWithSBSShortcutItem:shortcutItem];
NSDictionary *activationOptions = @{
@"__ActivateSuspended" : [NSNumber numberWithBool:(shortcutItem.activationMode == 1)],
@"__Actions": @[
openAction
],
@"__PromptUnlockDevice" : [NSNumber numberWithBool:YES],
@"__LaunchOrigin": @"__SBLaunchOriginShortcutItem"
};
FBSOpenApplicationOptions *applicationOptions = [FBSOpenApplicationOptions optionsWithDictionary: activationOptions];
FBSOpenApplicationService *openService = [[FBSOpenApplicationService alloc] init];
[openService openApplication: shortcutItem.bundleIdentifierToLaunch withOptions:applicationOptions completion:nil];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment