未验证 提交 273f4cfe 编写于 作者: G gaaclarke 提交者: GitHub

Split out lifecycle protocol (#9922)

Split out lifecycle calls to plugins to their own protocol to clean up
FlutterPlugin and make the API slightly closer to Android.
上级 f41be3ea
......@@ -18,107 +18,55 @@ NS_ASSUME_NONNULL_BEGIN
@protocol FlutterPluginRegistrar;
@protocol FlutterPluginRegistry;
/**
* A plugin registration callback.
*
* Used for registering plugins with additional instances of
* `FlutterPluginRegistry`.
*
* @param registry The registry to register plugins with.
*/
typedef void (*FlutterPluginRegistrantCallback)(NSObject<FlutterPluginRegistry>* registry);
/**
* Implemented by the iOS part of a Flutter plugin.
*
* 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 <NSObject>
@required
/**
* Registers this plugin using the context information and callback registration
* methods exposed by the given registrar.
*
* The registrar is obtained from a `FlutterPluginRegistry` which keeps track of
* the identity of registered plugins and provides basic support for cross-plugin
* coordination.
*
* The caller of this method, a plugin registrant, is usually autogenerated by
* Flutter tooling based on declared plugin dependencies. The generated registrant
* asks the registry for a registrar for each plugin, and calls this method to
* allow the plugin to initialize itself and register callbacks with application
* objects available through the registrar protocol.
*
* @param registrar A helper providing application context and methods for
* registering callbacks.
*/
+ (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar>*)registrar;
@optional
/**
* Set a callback for registering plugins to an additional `FlutterPluginRegistry`,
* including headless `FlutterEngine` instances.
*
* This method is typically called from within an application's `AppDelegate` at
* startup to allow for plugins which create additional `FlutterEngine` instances
* to register the application's plugins.
*
* @param callback A callback for registering some set of plugins with a
* `FlutterPluginRegistry`.
#pragma mark -
/***************************************************************************************************
* Protocol for listener of events from the UIApplication, typically a FlutterPlugin.
*/
+ (void)setPluginRegistrantCallback:(FlutterPluginRegistrantCallback)callback;
@protocol FlutterApplicationLifeCycleDelegate
@optional
/**
* Called if this plugin has been registered to receive `FlutterMethodCall`s.
*
* @param call The method call command object.
* @param result A callback for submitting the result of the call.
*/
- (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result;
/**
* Called if this plugin has been registered for `UIApplicationDelegate` callbacks.
* Called if this has been registered for `UIApplicationDelegate` callbacks.
*
* @return `NO` if this plugin vetoes application launch.
* @return `NO` if this vetoes application launch.
*/
- (BOOL)application:(UIApplication*)application
didFinishLaunchingWithOptions:(NSDictionary*)launchOptions;
/**
* Called if this plugin has been registered for `UIApplicationDelegate` callbacks.
* Called if this has been registered for `UIApplicationDelegate` callbacks.
*
* @return `NO` if this plugin vetoes application launch.
* @return `NO` if this vetoes application launch.
*/
- (BOOL)application:(UIApplication*)application
willFinishLaunchingWithOptions:(NSDictionary*)launchOptions;
/**
* Called if this plugin has been registered for `UIApplicationDelegate` callbacks.
* Called if this has been registered for `UIApplicationDelegate` callbacks.
*/
- (void)applicationDidBecomeActive:(UIApplication*)application;
/**
* Called if this plugin has been registered for `UIApplicationDelegate` callbacks.
* Called if this has been registered for `UIApplicationDelegate` callbacks.
*/
- (void)applicationWillResignActive:(UIApplication*)application;
/**
* Called if this plugin has been registered for `UIApplicationDelegate` callbacks.
* Called if this has been registered for `UIApplicationDelegate` callbacks.
*/
- (void)applicationDidEnterBackground:(UIApplication*)application;
/**
* Called if this plugin has been registered for `UIApplicationDelegate` callbacks.
* Called if this has been registered for `UIApplicationDelegate` callbacks.
*/
- (void)applicationWillEnterForeground:(UIApplication*)application;
/**
Called if this plugin has been registered for `UIApplicationDelegate` callbacks.
Called if this has been registered for `UIApplicationDelegate` callbacks.
*/
- (void)applicationWillTerminate:(UIApplication*)application;
/**
* Called if this plugin has been registered for `UIApplicationDelegate` callbacks.
* Called if this has been registered for `UIApplicationDelegate` callbacks.
*/
- (void)application:(UIApplication*)application
didRegisterUserNotificationSettings:(UIUserNotificationSettings*)notificationSettings
......@@ -127,15 +75,15 @@ typedef void (*FlutterPluginRegistrantCallback)(NSObject<FlutterPluginRegistry>*
ios(8.0, 10.0));
/**
* Called if this plugin has been registered for `UIApplicationDelegate` callbacks.
* Called if this has been registered for `UIApplicationDelegate` callbacks.
*/
- (void)application:(UIApplication*)application
didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken;
/**
* Called if this plugin has been registered for `UIApplicationDelegate` callbacks.
* Called if this has been registered for `UIApplicationDelegate` callbacks.
*
* @return `YES` if this plugin handles the request.
* @return `YES` if this handles the request.
*/
- (BOOL)application:(UIApplication*)application
didReceiveRemoteNotification:(NSDictionary*)userInfo
......@@ -160,25 +108,25 @@ typedef void (*FlutterPluginRegistrantCallback)(NSObject<FlutterPluginRegistry>*
API_AVAILABLE(ios(10));
/**
* Called if this plugin has been registered for `UIApplicationDelegate` callbacks.
* Called if this has been registered for `UIApplicationDelegate` callbacks.
*
* @return `YES` if this plugin handles the request.
* @return `YES` if this handles the request.
*/
- (BOOL)application:(UIApplication*)application
openURL:(NSURL*)url
options:(NSDictionary<UIApplicationOpenURLOptionsKey, id>*)options;
/**
* Called if this plugin has been registered for `UIApplicationDelegate` callbacks.
* Called if this has been registered for `UIApplicationDelegate` callbacks.
*
* @return `YES` if this plugin handles the request.
* @return `YES` if this handles the request.
*/
- (BOOL)application:(UIApplication*)application handleOpenURL:(NSURL*)url;
/**
* Called if this plugin has been registered for `UIApplicationDelegate` callbacks.
* Called if this has been registered for `UIApplicationDelegate` callbacks.
*
* @return `YES` if this plugin handles the request.
* @return `YES` if this handles the request.
*/
- (BOOL)application:(UIApplication*)application
openURL:(NSURL*)url
......@@ -186,9 +134,9 @@ typedef void (*FlutterPluginRegistrantCallback)(NSObject<FlutterPluginRegistry>*
annotation:(id)annotation;
/**
* Called if this plugin has been registered for `UIApplicationDelegate` callbacks.
* Called if this has been registered for `UIApplicationDelegate` callbacks.
*
* @return `YES` if this plugin handles the request.
* @return `YES` if this handles the request.
*/
- (BOOL)application:(UIApplication*)application
performActionForShortcutItem:(UIApplicationShortcutItem*)shortcutItem
......@@ -196,33 +144,95 @@ typedef void (*FlutterPluginRegistrantCallback)(NSObject<FlutterPluginRegistry>*
API_AVAILABLE(ios(9.0));
/**
* Called if this plugin has been registered for `UIApplicationDelegate` callbacks.
* Called if this has been registered for `UIApplicationDelegate` callbacks.
*
* @return `YES` if this plugin handles the request.
* @return `YES` if this handles the request.
*/
- (BOOL)application:(UIApplication*)application
handleEventsForBackgroundURLSession:(nonnull NSString*)identifier
completionHandler:(nonnull void (^)(void))completionHandler;
/**
* Called if this plugin has been registered for `UIApplicationDelegate` callbacks.
* Called if this has been registered for `UIApplicationDelegate` callbacks.
*
* @return `YES` if this plugin handles the request.
* @return `YES` if this handles the request.
*/
- (BOOL)application:(UIApplication*)application
performFetchWithCompletionHandler:(void (^)(UIBackgroundFetchResult result))completionHandler;
/**
* Called if this plugin has been registered for `UIApplicationDelegate` callbacks.
* Called if this has been registered for `UIApplicationDelegate` callbacks.
*
* @return `YES` if this plugin handles the request.
* @return `YES` if this handles the request.
*/
- (BOOL)application:(UIApplication*)application
continueUserActivity:(NSUserActivity*)userActivity
restorationHandler:(void (^)(NSArray*))restorationHandler;
@end
#pragma mark -
/***************************************************************************************************
* A plugin registration callback.
*
* Used for registering plugins with additional instances of
* `FlutterPluginRegistry`.
*
* @param registry The registry to register plugins with.
*/
typedef void (*FlutterPluginRegistrantCallback)(NSObject<FlutterPluginRegistry>* registry);
#pragma mark -
/***************************************************************************************************
* Implemented by the iOS part of a Flutter plugin.
*
* 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 <NSObject, FlutterApplicationLifeCycleDelegate>
@required
/**
* Registers this plugin using the context information and callback registration
* methods exposed by the given registrar.
*
* The registrar is obtained from a `FlutterPluginRegistry` which keeps track of
* the identity of registered plugins and provides basic support for cross-plugin
* coordination.
*
* The caller of this method, a plugin registrant, is usually autogenerated by
* Flutter tooling based on declared plugin dependencies. The generated registrant
* asks the registry for a registrar for each plugin, and calls this method to
* allow the plugin to initialize itself and register callbacks with application
* objects available through the registrar protocol.
*
* @param registrar A helper providing application context and methods for
* registering callbacks.
*/
+ (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar>*)registrar;
@optional
/**
* Set a callback for registering plugins to an additional `FlutterPluginRegistry`,
* including headless `FlutterEngine` instances.
*
* This method is typically called from within an application's `AppDelegate` at
* startup to allow for plugins which create additional `FlutterEngine` instances
* to register the application's plugins.
*
* @param callback A callback for registering some set of plugins with a
* `FlutterPluginRegistry`.
*/
+ (void)setPluginRegistrantCallback:(FlutterPluginRegistrantCallback)callback;
@optional
/**
* Called if this plugin has been registered to receive `FlutterMethodCall`s.
*
* @param call The method call command object.
* @param result A callback for submitting the result of the call.
*/
- (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result;
@end
#pragma mark -
/***************************************************************************************************
*Registration context for a single `FlutterPlugin`, providing a one stop shop
*for the plugin to access contextual information and register callbacks for
*various application events.
......@@ -312,7 +322,8 @@ typedef void (*FlutterPluginRegistrantCallback)(NSObject<FlutterPluginRegistry>*
- (NSString*)lookupKeyForAsset:(NSString*)asset fromPackage:(NSString*)package;
@end
/**
#pragma mark -
/***************************************************************************************************
* A registry of Flutter iOS plugins.
*
* Plugins are identified by unique string keys, typically the name of the
......@@ -357,12 +368,13 @@ typedef void (*FlutterPluginRegistrantCallback)(NSObject<FlutterPluginRegistry>*
- (NSObject*)valuePublishedByPlugin:(NSString*)pluginKey;
@end
/**
#pragma mark -
/***************************************************************************************************
* Implement this in the `UIAppDelegate` of your app to enable Flutter plugins to register
* themselves to the application life cycle events.
*/
@protocol FlutterAppLifeCycleProvider
- (void)addApplicationLifeCycleDelegate:(NSObject<FlutterPlugin>*)delegate;
- (void)addApplicationLifeCycleDelegate:(NSObject<FlutterApplicationLifeCycleDelegate>*)delegate;
@end
NS_ASSUME_NONNULL_END;
......
......@@ -21,7 +21,7 @@ FLUTTER_EXPORT
*
* `delegate` will only referenced weakly.
*/
- (void)addDelegate:(NSObject<FlutterPlugin>*)delegate;
- (void)addDelegate:(NSObject<FlutterApplicationLifeCycleDelegate>*)delegate;
/**
* Calls all plugins registered for `UIApplicationDelegate` callbacks.
......
......@@ -19,20 +19,20 @@ static const SEL selectorsHandledByPlugins[] = {
UIBackgroundTaskIdentifier _debugBackgroundTask;
// Weak references to registered plugins.
NSPointerArray* _pluginDelegates;
NSPointerArray* _delegates;
}
- (instancetype)init {
if (self = [super init]) {
std::string cachePath = fml::paths::JoinPaths({getenv("HOME"), kCallbackCacheSubDir});
[FlutterCallbackCache setCachePath:[NSString stringWithUTF8String:cachePath.c_str()]];
_pluginDelegates = [[NSPointerArray weakObjectsPointerArray] retain];
_delegates = [[NSPointerArray weakObjectsPointerArray] retain];
}
return self;
}
- (void)dealloc {
[_pluginDelegates release];
[_delegates release];
[super dealloc];
}
......@@ -50,32 +50,32 @@ static BOOL isPowerOfTwo(NSUInteger x) {
}
- (BOOL)hasPluginThatRespondsToSelector:(SEL)selector {
for (id<FlutterPlugin> plugin in [_pluginDelegates allObjects]) {
if (!plugin) {
for (NSObject<FlutterApplicationLifeCycleDelegate>* delegate in [_delegates allObjects]) {
if (!delegate) {
continue;
}
if ([plugin respondsToSelector:selector]) {
if ([delegate respondsToSelector:selector]) {
return YES;
}
}
return NO;
}
- (void)addDelegate:(NSObject<FlutterPlugin>*)delegate {
[_pluginDelegates addPointer:(__bridge void*)delegate];
if (isPowerOfTwo([_pluginDelegates count])) {
[_pluginDelegates compact];
- (void)addDelegate:(NSObject<FlutterApplicationLifeCycleDelegate>*)delegate {
[_delegates addPointer:(__bridge void*)delegate];
if (isPowerOfTwo([_delegates count])) {
[_delegates compact];
}
}
- (BOOL)application:(UIApplication*)application
didFinishLaunchingWithOptions:(NSDictionary*)launchOptions {
for (id<FlutterPlugin> plugin in [_pluginDelegates allObjects]) {
if (!plugin) {
for (NSObject<FlutterApplicationLifeCycleDelegate>* delegate in [_delegates allObjects]) {
if (!delegate) {
continue;
}
if ([plugin respondsToSelector:_cmd]) {
if (![plugin application:application didFinishLaunchingWithOptions:launchOptions]) {
if ([delegate respondsToSelector:_cmd]) {
if (![delegate application:application didFinishLaunchingWithOptions:launchOptions]) {
return NO;
}
}
......@@ -86,12 +86,12 @@ static BOOL isPowerOfTwo(NSUInteger x) {
- (BOOL)application:(UIApplication*)application
willFinishLaunchingWithOptions:(NSDictionary*)launchOptions {
flutter::DartCallbackCache::LoadCacheFromDisk();
for (id<FlutterPlugin> plugin in [_pluginDelegates allObjects]) {
if (!plugin) {
for (NSObject<FlutterApplicationLifeCycleDelegate>* delegate in [_delegates allObjects]) {
if (!delegate) {
continue;
}
if ([plugin respondsToSelector:_cmd]) {
if (![plugin application:application willFinishLaunchingWithOptions:launchOptions]) {
if ([delegate respondsToSelector:_cmd]) {
if (![delegate application:application willFinishLaunchingWithOptions:launchOptions]) {
return NO;
}
}
......@@ -117,12 +117,12 @@ static BOOL isPowerOfTwo(NSUInteger x) {
"To reconnect, launch your application again via 'flutter run'";
}];
#endif // FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_DEBUG
for (id<FlutterPlugin> plugin in _pluginDelegates) {
if (!plugin) {
for (NSObject<FlutterApplicationLifeCycleDelegate>* delegate in _delegates) {
if (!delegate) {
continue;
}
if ([plugin respondsToSelector:_cmd]) {
[plugin applicationDidEnterBackground:application];
if ([delegate respondsToSelector:_cmd]) {
[delegate applicationDidEnterBackground:application];
}
}
}
......@@ -131,45 +131,45 @@ static BOOL isPowerOfTwo(NSUInteger x) {
#if FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_DEBUG
[application endBackgroundTask:_debugBackgroundTask];
#endif // FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_DEBUG
for (id<FlutterPlugin> plugin in _pluginDelegates) {
if (!plugin) {
for (NSObject<FlutterApplicationLifeCycleDelegate>* delegate in _delegates) {
if (!delegate) {
continue;
}
if ([plugin respondsToSelector:_cmd]) {
[plugin applicationWillEnterForeground:application];
if ([delegate respondsToSelector:_cmd]) {
[delegate applicationWillEnterForeground:application];
}
}
}
- (void)applicationWillResignActive:(UIApplication*)application {
for (id<FlutterPlugin> plugin in _pluginDelegates) {
if (!plugin) {
for (NSObject<FlutterApplicationLifeCycleDelegate>* delegate in _delegates) {
if (!delegate) {
continue;
}
if ([plugin respondsToSelector:_cmd]) {
[plugin applicationWillResignActive:application];
if ([delegate respondsToSelector:_cmd]) {
[delegate applicationWillResignActive:application];
}
}
}
- (void)applicationDidBecomeActive:(UIApplication*)application {
for (id<FlutterPlugin> plugin in _pluginDelegates) {
if (!plugin) {
for (NSObject<FlutterApplicationLifeCycleDelegate>* delegate in _delegates) {
if (!delegate) {
continue;
}
if ([plugin respondsToSelector:_cmd]) {
[plugin applicationDidBecomeActive:application];
if ([delegate respondsToSelector:_cmd]) {
[delegate applicationDidBecomeActive:application];
}
}
}
- (void)applicationWillTerminate:(UIApplication*)application {
for (id<FlutterPlugin> plugin in _pluginDelegates) {
if (!plugin) {
for (NSObject<FlutterApplicationLifeCycleDelegate>* delegate in _delegates) {
if (!delegate) {
continue;
}
if ([plugin respondsToSelector:_cmd]) {
[plugin applicationWillTerminate:application];
if ([delegate respondsToSelector:_cmd]) {
[delegate applicationWillTerminate:application];
}
}
}
......@@ -178,12 +178,12 @@ static BOOL isPowerOfTwo(NSUInteger x) {
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
- (void)application:(UIApplication*)application
didRegisterUserNotificationSettings:(UIUserNotificationSettings*)notificationSettings {
for (id<FlutterPlugin> plugin in _pluginDelegates) {
if (!plugin) {
for (NSObject<FlutterApplicationLifeCycleDelegate>* delegate in _delegates) {
if (!delegate) {
continue;
}
if ([plugin respondsToSelector:_cmd]) {
[plugin application:application didRegisterUserNotificationSettings:notificationSettings];
if ([delegate respondsToSelector:_cmd]) {
[delegate application:application didRegisterUserNotificationSettings:notificationSettings];
}
}
}
......@@ -191,12 +191,13 @@ static BOOL isPowerOfTwo(NSUInteger x) {
- (void)application:(UIApplication*)application
didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken {
for (id<FlutterPlugin> plugin in _pluginDelegates) {
if (!plugin) {
for (NSObject<FlutterApplicationLifeCycleDelegate>* delegate in _delegates) {
if (!delegate) {
continue;
}
if ([plugin respondsToSelector:_cmd]) {
[plugin application:application didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];
if ([delegate respondsToSelector:_cmd]) {
[delegate application:application
didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];
}
}
}
......@@ -204,12 +205,12 @@ static BOOL isPowerOfTwo(NSUInteger x) {
- (void)application:(UIApplication*)application
didReceiveRemoteNotification:(NSDictionary*)userInfo
fetchCompletionHandler:(void (^)(UIBackgroundFetchResult result))completionHandler {
for (id<FlutterPlugin> plugin in _pluginDelegates) {
if (!plugin) {
for (NSObject<FlutterApplicationLifeCycleDelegate>* delegate in _delegates) {
if (!delegate) {
continue;
}
if ([plugin respondsToSelector:_cmd]) {
if ([plugin application:application
if ([delegate respondsToSelector:_cmd]) {
if ([delegate application:application
didReceiveRemoteNotification:userInfo
fetchCompletionHandler:completionHandler]) {
return;
......@@ -222,12 +223,12 @@ static BOOL isPowerOfTwo(NSUInteger x) {
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
- (void)application:(UIApplication*)application
didReceiveLocalNotification:(UILocalNotification*)notification {
for (id<FlutterPlugin> plugin in _pluginDelegates) {
if (!plugin) {
for (NSObject<FlutterApplicationLifeCycleDelegate>* delegate in _delegates) {
if (!delegate) {
continue;
}
if ([plugin respondsToSelector:_cmd]) {
[plugin application:application didReceiveLocalNotification:notification];
if ([delegate respondsToSelector:_cmd]) {
[delegate application:application didReceiveLocalNotification:notification];
}
}
}
......@@ -238,14 +239,14 @@ static BOOL isPowerOfTwo(NSUInteger x) {
withCompletionHandler:
(void (^)(UNNotificationPresentationOptions options))completionHandler {
if (@available(iOS 10.0, *)) {
for (id<FlutterPlugin> plugin in _pluginDelegates) {
if (!plugin) {
for (NSObject<FlutterApplicationLifeCycleDelegate>* delegate in _delegates) {
if (!delegate) {
continue;
}
if ([plugin respondsToSelector:_cmd]) {
[plugin userNotificationCenter:center
willPresentNotification:notification
withCompletionHandler:completionHandler];
if ([delegate respondsToSelector:_cmd]) {
[delegate userNotificationCenter:center
willPresentNotification:notification
withCompletionHandler:completionHandler];
}
}
}
......@@ -254,12 +255,12 @@ static BOOL isPowerOfTwo(NSUInteger x) {
- (BOOL)application:(UIApplication*)application
openURL:(NSURL*)url
options:(NSDictionary<UIApplicationOpenURLOptionsKey, id>*)options {
for (id<FlutterPlugin> plugin in _pluginDelegates) {
if (!plugin) {
for (NSObject<FlutterApplicationLifeCycleDelegate>* delegate in _delegates) {
if (!delegate) {
continue;
}
if ([plugin respondsToSelector:_cmd]) {
if ([plugin application:application openURL:url options:options]) {
if ([delegate respondsToSelector:_cmd]) {
if ([delegate application:application openURL:url options:options]) {
return YES;
}
}
......@@ -268,12 +269,12 @@ static BOOL isPowerOfTwo(NSUInteger x) {
}
- (BOOL)application:(UIApplication*)application handleOpenURL:(NSURL*)url {
for (id<FlutterPlugin> plugin in _pluginDelegates) {
if (!plugin) {
for (NSObject<FlutterApplicationLifeCycleDelegate>* delegate in _delegates) {
if (!delegate) {
continue;
}
if ([plugin respondsToSelector:_cmd]) {
if ([plugin application:application handleOpenURL:url]) {
if ([delegate respondsToSelector:_cmd]) {
if ([delegate application:application handleOpenURL:url]) {
return YES;
}
}
......@@ -285,12 +286,12 @@ static BOOL isPowerOfTwo(NSUInteger x) {
openURL:(NSURL*)url
sourceApplication:(NSString*)sourceApplication
annotation:(id)annotation {
for (id<FlutterPlugin> plugin in _pluginDelegates) {
if (!plugin) {
for (NSObject<FlutterApplicationLifeCycleDelegate>* delegate in _delegates) {
if (!delegate) {
continue;
}
if ([plugin respondsToSelector:_cmd]) {
if ([plugin application:application
if ([delegate respondsToSelector:_cmd]) {
if ([delegate application:application
openURL:url
sourceApplication:sourceApplication
annotation:annotation]) {
......@@ -304,12 +305,12 @@ static BOOL isPowerOfTwo(NSUInteger x) {
- (void)application:(UIApplication*)application
performActionForShortcutItem:(UIApplicationShortcutItem*)shortcutItem
completionHandler:(void (^)(BOOL succeeded))completionHandler NS_AVAILABLE_IOS(9_0) {
for (id<FlutterPlugin> plugin in _pluginDelegates) {
if (!plugin) {
for (NSObject<FlutterApplicationLifeCycleDelegate>* delegate in _delegates) {
if (!delegate) {
continue;
}
if ([plugin respondsToSelector:_cmd]) {
if ([plugin application:application
if ([delegate respondsToSelector:_cmd]) {
if ([delegate application:application
performActionForShortcutItem:shortcutItem
completionHandler:completionHandler]) {
return;
......@@ -321,12 +322,12 @@ static BOOL isPowerOfTwo(NSUInteger x) {
- (BOOL)application:(UIApplication*)application
handleEventsForBackgroundURLSession:(nonnull NSString*)identifier
completionHandler:(nonnull void (^)())completionHandler {
for (id<FlutterPlugin> plugin in _pluginDelegates) {
if (!plugin) {
for (NSObject<FlutterApplicationLifeCycleDelegate>* delegate in _delegates) {
if (!delegate) {
continue;
}
if ([plugin respondsToSelector:_cmd]) {
if ([plugin application:application
if ([delegate respondsToSelector:_cmd]) {
if ([delegate application:application
handleEventsForBackgroundURLSession:identifier
completionHandler:completionHandler]) {
return YES;
......@@ -338,12 +339,12 @@ static BOOL isPowerOfTwo(NSUInteger x) {
- (BOOL)application:(UIApplication*)application
performFetchWithCompletionHandler:(void (^)(UIBackgroundFetchResult result))completionHandler {
for (id<FlutterPlugin> plugin in _pluginDelegates) {
if (!plugin) {
for (NSObject<FlutterApplicationLifeCycleDelegate>* delegate in _delegates) {
if (!delegate) {
continue;
}
if ([plugin respondsToSelector:_cmd]) {
if ([plugin application:application performFetchWithCompletionHandler:completionHandler]) {
if ([delegate respondsToSelector:_cmd]) {
if ([delegate application:application performFetchWithCompletionHandler:completionHandler]) {
return YES;
}
}
......@@ -354,12 +355,12 @@ static BOOL isPowerOfTwo(NSUInteger x) {
- (BOOL)application:(UIApplication*)application
continueUserActivity:(NSUserActivity*)userActivity
restorationHandler:(void (^)(NSArray*))restorationHandler {
for (id<FlutterPlugin> plugin in _pluginDelegates) {
if (!plugin) {
for (NSObject<FlutterApplicationLifeCycleDelegate>* delegate in _delegates) {
if (!delegate) {
continue;
}
if ([plugin respondsToSelector:_cmd]) {
if ([plugin application:application
if ([delegate respondsToSelector:_cmd]) {
if ([delegate application:application
continueUserActivity:userActivity
restorationHandler:restorationHandler]) {
return YES;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册