From 27fcb31df52ed99c1fa2279897af3391f852a04b Mon Sep 17 00:00:00 2001 From: Mikkel Nygaard Ravn Date: Wed, 10 May 2017 23:51:13 +0200 Subject: [PATCH] Forward openURL requests to plugins (flutter/engine#3679) --- .../ios/framework/Headers/FlutterPlugin.h | 14 ++++++++++++-- .../ios/framework/Source/FlutterAppDelegate.mm | 17 +++++++++++++++++ 2 files changed, 29 insertions(+), 2 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 59e0208da7..8daeaaf9b1 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 @@ -87,7 +87,7 @@ NS_ASSUME_NONNULL_BEGIN /** Called if this plugin has been registered for `UIApplicationDelegate` callbacks. - - Returns: `YES` if this plugin handles request. + - Returns: `YES` if this plugin handles the request. */ - (BOOL)application:(UIApplication*)application didReceiveRemoteNotification:(NSDictionary*)userInfo @@ -96,10 +96,20 @@ NS_ASSUME_NONNULL_BEGIN /** Called if this plugin has been registered for `UIApplicationDelegate` callbacks. - - Returns: `YES` if this plugin handles request. + - 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 + openURL:(NSURL*)url + sourceApplication:(NSString*)sourceApplication + annotation:(id)annotation; @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 cb237df4aa..657d5aeac6 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 @@ -167,6 +167,23 @@ return NO; } +- (BOOL)application:(UIApplication*)application + 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]) { + return YES; + } + } + } + return NO; +} + - (NSObject*)registrarForPlugin:(NSString*)pluginKey { NSAssert(self.pluginPublications[pluginKey] == nil, @"Duplicate plugin key: %@", pluginKey); self.pluginPublications[pluginKey] = [NSNull null];