I\'m looking after some Obj-C sample code for a dynamic UIApplicationShortCutItem
.
Basically, I have three static UIApplicationShortcutItems
an
Here's how to detect if the app was launched with a quick shortcut in Objective-c.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
UIApplicationShortcutItem *shortcutItem = [launchOptions objectForKey:UIApplicationLaunchOptionsShortcutItemKey];
if(shortcutItem){
[self handleShortCutItem:shortcutItem];
}
}
- (void)handleShortCutItem:(UIApplicationShortcutItem *)shortcutItem {
if([shortcutItem.type isEqualToString:@"takePhotoAction"]){
//ACTION HERE
}
}
To detect the type of shortcut selected while the app is running in the background.
- (void)application:(UIApplication *)application performActionForShortcutItem:(UIApplicationShortcutItem *)shortcutItem completionHandler:(void (^)(BOOL))completionHandler {
NSLog(@"%@", shortcutItem.type);
if([shortcutItem.type isEqualToString:@"takePhotoAction"]){
//ACTION HERE
}
}