From 0b24568ec1db73eb32691c1748c85674f658f03c 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 (#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 | 17 ++++++++--- .../framework/Source/FlutterAppDelegate.mm | 29 ++++++++++++++----- 2 files changed, 34 insertions(+), 12 deletions(-) diff --git a/shell/platform/darwin/ios/framework/Headers/FlutterPlugin.h b/shell/platform/darwin/ios/framework/Headers/FlutterPlugin.h index 8daeaaf9b..7176169b0 100644 --- a/shell/platform/darwin/ios/framework/Headers/FlutterPlugin.h +++ b/shell/platform/darwin/ios/framework/Headers/FlutterPlugin.h @@ -98,8 +98,17 @@ NS_ASSUME_NONNULL_BEGIN - Returns: `YES` if this plugin handles the request. */ +- (BOOL)application:(UIApplication*)application handleOpenURL:(NSURL*)url; + +/** + Called if this plugin has been registered for `UIApplicationDelegate` callbacks. + + - Returns: `YES` if this plugin handles the request. +*/ - (BOOL)application:(UIApplication*)application - handleOpenURL:(NSURL*)url; + openURL:(NSURL*)url + sourceApplication:(NSString*)sourceApplication + annotation:(id)annotation; /** Called if this plugin has been registered for `UIApplicationDelegate` callbacks. @@ -107,9 +116,9 @@ 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; + performActionForShortcutItem:(UIApplicationShortcutItem*)shortcutItem + completionHandler:(void (^)(BOOL succeeded))completionHandler; + @end /** diff --git a/shell/platform/darwin/ios/framework/Source/FlutterAppDelegate.mm b/shell/platform/darwin/ios/framework/Source/FlutterAppDelegate.mm index 813283b68..0da1bad32 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterAppDelegate.mm +++ b/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]; -- GitLab