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 b6c964c6b3..646ffa30d7 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 @@ -21,7 +21,7 @@ NS_ASSUME_NONNULL_BEGIN Defines a set of optional callback methods and a method to set up the plugin and register it to be called by other application components. */ -@protocol FlutterPlugin +@protocol FlutterPlugin @required /** Registers this plugin. @@ -130,12 +130,28 @@ NS_ASSUME_NONNULL_BEGIN completionHandler:(void (^)(BOOL succeeded))completionHandler API_AVAILABLE(ios(9.0)); +/** + Called if this plugin has been registered for `UIApplicationDelegate` callbacks. + + - Returns: `YES` if this plugin handles the request. + */ +- (BOOL)application:(UIApplication*)application + handleEventsForBackgroundURLSession:(nonnull NSString*)identifier + completionHandler:(nonnull void (^)())completionHandler; + +/** + Called if this plugin has been registered for `UIApplicationDelegate` callbacks. + + - Returns: `YES` if this plugin handles the request. + */ +- (BOOL)application:(UIApplication*)application + performFetchWithCompletionHandler:(void (^)(UIBackgroundFetchResult result))completionHandler; @end /** Registration context for a single `FlutterPlugin`. */ -@protocol FlutterPluginRegistrar +@protocol FlutterPluginRegistrar /** Returns a `FlutterBinaryMessenger` for creating Dart/iOS communication channels to be used by the plugin. @@ -211,7 +227,7 @@ NS_ASSUME_NONNULL_BEGIN Plugins are identified by unique string keys, typically the name of the plugin's main class. */ -@protocol FlutterPluginRegistry +@protocol FlutterPluginRegistry /** Returns a registrar for registering a plugin. 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 7198b9082a..a5132bf4ee 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 @@ -11,7 +11,7 @@ @property(readonly, nonatomic) NSMutableDictionary* pluginPublications; @end -@interface FlutterAppDelegateRegistrar : NSObject +@interface FlutterAppDelegateRegistrar : NSObject - (instancetype)initWithPlugin:(NSString*)pluginKey appDelegate:(FlutterAppDelegate*)delegate; @end @@ -210,6 +210,31 @@ } } +- (void)application:(UIApplication*)application + handleEventsForBackgroundURLSession:(nonnull NSString*)identifier + completionHandler:(nonnull void (^)())completionHandler { + for (id plugin in _pluginDelegates) { + if ([plugin respondsToSelector:_cmd]) { + if ([plugin application:application + handleEventsForBackgroundURLSession:identifier + completionHandler:completionHandler]) { + return; + } + } + } +} + +- (void)application:(UIApplication*)application + performFetchWithCompletionHandler:(void (^)(UIBackgroundFetchResult result))completionHandler { + for (id plugin in _pluginDelegates) { + if ([plugin respondsToSelector:_cmd]) { + if ([plugin application:application performFetchWithCompletionHandler:completionHandler]) { + return; + } + } + } +} + // TODO(xster): move when doing https://github.com/flutter/flutter/issues/3671. - (NSObject*)binaryMessenger { UIViewController* rootViewController = _window.rootViewController; @@ -286,11 +311,11 @@ } - (NSString*)lookupKeyForAsset:(NSString*)asset { - return [FlutterDartProject lookupKeyForAsset:asset]; + return [FlutterDartProject lookupKeyForAsset:asset]; } - (NSString*)lookupKeyForAsset:(NSString*)asset fromPackage:(NSString*)package { - return [FlutterDartProject lookupKeyForAsset:asset fromPackage:package]; + return [FlutterDartProject lookupKeyForAsset:asset fromPackage:package]; } @end