Forward openURL requests to plugins (flutter/engine#3679)

This commit is contained in:
Mikkel Nygaard Ravn
2017-05-10 23:51:13 +02:00
committed by GitHub
parent 498a9da159
commit 27fcb31df5
2 changed files with 29 additions and 2 deletions

View File

@@ -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
/**

View File

@@ -167,6 +167,23 @@
return NO;
}
- (BOOL)application:(UIApplication*)application
openURL:(NSURL*)url
sourceApplication:(NSString*)sourceApplication
annotation:(id)annotation {
for (id<FlutterPlugin> plugin in _pluginDelegates) {
if ([plugin respondsToSelector:_cmd]) {
if ([plugin application:application
openURL:url
sourceApplication:sourceApplication
annotation:annotation]) {
return YES;
}
}
}
return NO;
}
- (NSObject<FlutterPluginRegistrar>*)registrarForPlugin:(NSString*)pluginKey {
NSAssert(self.pluginPublications[pluginKey] == nil, @"Duplicate plugin key: %@", pluginKey);
self.pluginPublications[pluginKey] = [NSNull null];