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.