Skip to content

Instantly share code, notes, and snippets.

@yur1xpp
Forked from CPDigitalDarkroom/open_shortcut.m
Created July 4, 2020 11:57
Show Gist options
  • Save yur1xpp/c31d238aefe3ac90ac12aaac05b664a0 to your computer and use it in GitHub Desktop.
Save yur1xpp/c31d238aefe3ac90ac12aaac05b664a0 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