1

I'm trying to present a sharing UIActivityViewController from a 3D touch menu action on the app icon on home screen, I'm doing the following :

-(void)application:(UIApplication *)application performActionForShortcutItem:(UIApplicationShortcutItem *)shortcutItem completionHandler:(void (^)(BOOL))completionHandler {
  completionHandler([self handleShortcutItem:shortcutItem]);
}

- (BOOL)handleShortcutItem:(UIApplicationShortcutItem *)shortcutItem {
  BOOL handled = NO;
  if ([shortcutItem.type containsString:@"share"]) {
    handled = YES;
    UIActivityViewController *activityVC =
    [[UIActivityViewController alloc] initWithActivityItems: @[ @"test" ] applicationActivities:nil];
    [self.window.rootViewController presentViewController:activityVC animated:YES completion:nil];
  }
  return handled;
}

This results is the app being launched and the UIActivityViewController displayed. What I'm trying to do is to display the UIActivityViewController without launching the app.

I saw this behaviour in popular apps like Booking and AirBnB.

Mosbah
  • 1,347
  • 1
  • 14
  • 28

1 Answers1

1

When you select any of the action from shortcut item it will immediately launch your app. Shortcut item main purpose is to show the user interested screen very quickly. You cannot achieve the expected case by using shortcut item.

Yogesh Mv
  • 1,041
  • 1
  • 6
  • 12