From f38ab73dab7a29559ec3bd75dc4295f46b97e726 Mon Sep 17 00:00:00 2001 From: Mehmet Fidanboylu Date: Fri, 9 Jun 2017 17:55:48 -0700 Subject: [PATCH] Expose performActionForShortcutItem call to all registered plugins so we can handle quick actions (flutter/engine#3763) * Expose performActionForShortcutItem call to all registered plugins so we can handle quick actions * Should return BOOL not void * clang-formatted --- .../ios/framework/Headers/FlutterPlugin.h | 19 ++++++++---- .../framework/Source/FlutterAppDelegate.mm | 29 ++++++++++++++----- 2 files changed, 35 insertions(+), 13 deletions(-) diff --git a/engine/src/flutter/shell/platform/darwin/ios/framework/Headers/FlutterPlugin.h b/engine/src/flutter/shell/platform/darwin/ios/framework/Headers/FlutterPlugin.h index 8daeaaf9b1..7176169b07 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/framework/Headers/FlutterPlugin.h +++ b/engine/src/flutter/shell/platform/darwin/ios/framework/Headers/FlutterPlugin.h @@ -98,8 +98,7 @@ NS_ASSUME_NONNULL_BEGIN - Returns: `YES` if this plugin handles the request. */ -- (BOOL)application:(UIApplication*)application - handleOpenURL:(NSURL*)url; +- (BOOL)application:(UIApplication*)application handleOpenURL:(NSURL*)url; /** Called if this plugin has been registered for `UIApplicationDelegate` callbacks. @@ -107,9 +106,19 @@ NS_ASSUME_NONNULL_BEGIN - Returns: `YES` if this plugin handles the request. */ - (BOOL)application:(UIApplication*)application - openURL:(NSURL*)url - sourceApplication:(NSString*)sourceApplication - annotation:(id)annotation; + openURL:(NSURL*)url + sourceApplication:(NSString*)sourceApplication + annotation:(id)annotation; + +/** + Called if this plugin has been registered for `UIApplicationDelegate` callbacks. + + - Returns: `YES` if this plugin handles the request. +*/ +- (BOOL)application:(UIApplication*)application + performActionForShortcutItem:(UIApplicationShortcutItem*)shortcutItem + completionHandler:(void (^)(BOOL succeeded))completionHandler; + @end /** diff --git a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterAppDelegate.mm b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterAppDelegate.mm index 813283b682..0da1bad325 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterAppDelegate.mm +++ b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterAppDelegate.mm @@ -155,8 +155,7 @@ } } -- (BOOL)application:(UIApplication*)application - handleOpenURL:(NSURL*)url { +- (BOOL)application:(UIApplication*)application handleOpenURL:(NSURL*)url { for (id plugin in _pluginDelegates) { if ([plugin respondsToSelector:_cmd]) { if ([plugin application:application handleOpenURL:url]) { @@ -168,15 +167,15 @@ } - (BOOL)application:(UIApplication*)application - openURL:(NSURL*)url - sourceApplication:(NSString*)sourceApplication - annotation:(id)annotation { + openURL:(NSURL*)url + sourceApplication:(NSString*)sourceApplication + annotation:(id)annotation { for (id plugin in _pluginDelegates) { if ([plugin respondsToSelector:_cmd]) { if ([plugin application:application - openURL:url - sourceApplication:sourceApplication - annotation:annotation]) { + openURL:url + sourceApplication:sourceApplication + annotation:annotation]) { return YES; } } @@ -184,6 +183,20 @@ return NO; } +- (void)application:(UIApplication*)application + performActionForShortcutItem:(UIApplicationShortcutItem*)shortcutItem + completionHandler:(void (^)(BOOL succeeded))completionHandler { + for (id plugin in _pluginDelegates) { + if ([plugin respondsToSelector:_cmd]) { + if ([plugin application:application + performActionForShortcutItem:shortcutItem + completionHandler:completionHandler]) { + return; + } + } + } +} + - (NSObject*)registrarForPlugin:(NSString*)pluginKey { NSAssert(self.pluginPublications[pluginKey] == nil, @"Duplicate plugin key: %@", pluginKey); self.pluginPublications[pluginKey] = [NSNull null];