From 9bc02314b0052324046acec0edd917fa75518180 Mon Sep 17 00:00:00 2001 From: gaaclarke <30870216+gaaclarke@users.noreply.github.com> Date: Fri, 19 Jul 2019 10:17:48 -0700 Subject: [PATCH] Split out lifecycle protocol (flutter/engine#9922) Split out lifecycle calls to plugins to their own protocol to clean up FlutterPlugin and make the API slightly closer to Android. --- .../ios/framework/Headers/FlutterPlugin.h | 314 +++++++++--------- .../FlutterPluginAppLifeCycleDelegate.h | 2 +- .../FlutterPluginAppLifeCycleDelegate.mm | 177 +++++----- 3 files changed, 253 insertions(+), 240 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 8d63dbc02c..95ec3adb2d 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 @@ -18,7 +18,160 @@ NS_ASSUME_NONNULL_BEGIN @protocol FlutterPluginRegistrar; @protocol FlutterPluginRegistry; +#pragma mark - +/*************************************************************************************************** + * Protocol for listener of events from the UIApplication, typically a FlutterPlugin. + */ +@protocol FlutterApplicationLifeCycleDelegate +@optional /** + * Called if this has been registered for `UIApplicationDelegate` callbacks. + * + * @return `NO` if this vetoes application launch. + */ +- (BOOL)application:(UIApplication*)application + didFinishLaunchingWithOptions:(NSDictionary*)launchOptions; + +/** + * Called if this has been registered for `UIApplicationDelegate` callbacks. + * + * @return `NO` if this vetoes application launch. + */ +- (BOOL)application:(UIApplication*)application + willFinishLaunchingWithOptions:(NSDictionary*)launchOptions; + +/** + * Called if this has been registered for `UIApplicationDelegate` callbacks. + */ +- (void)applicationDidBecomeActive:(UIApplication*)application; + +/** + * Called if this has been registered for `UIApplicationDelegate` callbacks. + */ +- (void)applicationWillResignActive:(UIApplication*)application; + +/** + * Called if this has been registered for `UIApplicationDelegate` callbacks. + */ +- (void)applicationDidEnterBackground:(UIApplication*)application; + +/** + * Called if this has been registered for `UIApplicationDelegate` callbacks. + */ +- (void)applicationWillEnterForeground:(UIApplication*)application; + +/** + Called if this has been registered for `UIApplicationDelegate` callbacks. + */ +- (void)applicationWillTerminate:(UIApplication*)application; + +/** + * Called if this has been registered for `UIApplicationDelegate` callbacks. + */ +- (void)application:(UIApplication*)application + didRegisterUserNotificationSettings:(UIUserNotificationSettings*)notificationSettings + API_DEPRECATED( + "See -[UIApplicationDelegate application:didRegisterUserNotificationSettings:] deprecation", + ios(8.0, 10.0)); + +/** + * Called if this has been registered for `UIApplicationDelegate` callbacks. + */ +- (void)application:(UIApplication*)application + didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken; + +/** + * Called if this has been registered for `UIApplicationDelegate` callbacks. + * + * @return `YES` if this handles the request. + */ +- (BOOL)application:(UIApplication*)application + didReceiveRemoteNotification:(NSDictionary*)userInfo + fetchCompletionHandler:(void (^)(UIBackgroundFetchResult result))completionHandler; + +/** + * Calls all plugins registered for `UIApplicationDelegate` callbacks. + */ +- (void)application:(UIApplication*)application + didReceiveLocalNotification:(UILocalNotification*)notification + API_DEPRECATED( + "See -[UIApplicationDelegate application:didReceiveLocalNotification:] deprecation", + ios(4.0, 10.0)); + +/** + * Calls all plugins registered for `UNUserNotificationCenterDelegate` callbacks. + */ +- (void)userNotificationCenter:(UNUserNotificationCenter*)center + willPresentNotification:(UNNotification*)notification + withCompletionHandler: + (void (^)(UNNotificationPresentationOptions options))completionHandler + API_AVAILABLE(ios(10)); + +/** + * Called if this has been registered for `UIApplicationDelegate` callbacks. + * + * @return `YES` if this handles the request. + */ +- (BOOL)application:(UIApplication*)application + openURL:(NSURL*)url + options:(NSDictionary*)options; + +/** + * Called if this has been registered for `UIApplicationDelegate` callbacks. + * + * @return `YES` if this handles the request. + */ +- (BOOL)application:(UIApplication*)application handleOpenURL:(NSURL*)url; + +/** + * Called if this has been registered for `UIApplicationDelegate` callbacks. + * + * @return `YES` if this handles the request. + */ +- (BOOL)application:(UIApplication*)application + openURL:(NSURL*)url + sourceApplication:(NSString*)sourceApplication + annotation:(id)annotation; + +/** + * Called if this has been registered for `UIApplicationDelegate` callbacks. + * + * @return `YES` if this handles the request. + */ +- (BOOL)application:(UIApplication*)application + performActionForShortcutItem:(UIApplicationShortcutItem*)shortcutItem + completionHandler:(void (^)(BOOL succeeded))completionHandler + API_AVAILABLE(ios(9.0)); + +/** + * Called if this has been registered for `UIApplicationDelegate` callbacks. + * + * @return `YES` if this handles the request. + */ +- (BOOL)application:(UIApplication*)application + handleEventsForBackgroundURLSession:(nonnull NSString*)identifier + completionHandler:(nonnull void (^)(void))completionHandler; + +/** + * Called if this has been registered for `UIApplicationDelegate` callbacks. + * + * @return `YES` if this handles the request. + */ +- (BOOL)application:(UIApplication*)application + performFetchWithCompletionHandler:(void (^)(UIBackgroundFetchResult result))completionHandler; + +/** + * Called if this has been registered for `UIApplicationDelegate` callbacks. + * + * @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 @@ -28,13 +181,14 @@ NS_ASSUME_NONNULL_BEGIN */ typedef void (*FlutterPluginRegistrantCallback)(NSObject* 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 +@protocol FlutterPlugin @required /** * Registers this plugin using the context information and callback registration @@ -75,154 +229,10 @@ typedef void (*FlutterPluginRegistrantCallback)(NSObject* * @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. - * - * @return `NO` if this plugin vetoes application launch. - */ -- (BOOL)application:(UIApplication*)application - didFinishLaunchingWithOptions:(NSDictionary*)launchOptions; - -/** - * Called if this plugin has been registered for `UIApplicationDelegate` callbacks. - * - * @return `NO` if this plugin vetoes application launch. - */ -- (BOOL)application:(UIApplication*)application - willFinishLaunchingWithOptions:(NSDictionary*)launchOptions; - -/** - * Called if this plugin has been registered for `UIApplicationDelegate` callbacks. - */ -- (void)applicationDidBecomeActive:(UIApplication*)application; - -/** - * Called if this plugin has been registered for `UIApplicationDelegate` callbacks. - */ -- (void)applicationWillResignActive:(UIApplication*)application; - -/** - * Called if this plugin has been registered for `UIApplicationDelegate` callbacks. - */ -- (void)applicationDidEnterBackground:(UIApplication*)application; - -/** - * Called if this plugin has been registered for `UIApplicationDelegate` callbacks. - */ -- (void)applicationWillEnterForeground:(UIApplication*)application; - -/** - Called if this plugin has been registered for `UIApplicationDelegate` callbacks. - */ -- (void)applicationWillTerminate:(UIApplication*)application; - -/** - * Called if this plugin has been registered for `UIApplicationDelegate` callbacks. - */ -- (void)application:(UIApplication*)application - didRegisterUserNotificationSettings:(UIUserNotificationSettings*)notificationSettings - API_DEPRECATED( - "See -[UIApplicationDelegate application:didRegisterUserNotificationSettings:] deprecation", - ios(8.0, 10.0)); - -/** - * Called if this plugin has been registered for `UIApplicationDelegate` callbacks. - */ -- (void)application:(UIApplication*)application - didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken; - -/** - * Called if this plugin has been registered for `UIApplicationDelegate` callbacks. - * - * @return `YES` if this plugin handles the request. - */ -- (BOOL)application:(UIApplication*)application - didReceiveRemoteNotification:(NSDictionary*)userInfo - fetchCompletionHandler:(void (^)(UIBackgroundFetchResult result))completionHandler; - -/** - * Calls all plugins registered for `UIApplicationDelegate` callbacks. - */ -- (void)application:(UIApplication*)application - didReceiveLocalNotification:(UILocalNotification*)notification - API_DEPRECATED( - "See -[UIApplicationDelegate application:didReceiveLocalNotification:] deprecation", - ios(4.0, 10.0)); - -/** - * Calls all plugins registered for `UNUserNotificationCenterDelegate` callbacks. - */ -- (void)userNotificationCenter:(UNUserNotificationCenter*)center - willPresentNotification:(UNNotification*)notification - withCompletionHandler: - (void (^)(UNNotificationPresentationOptions options))completionHandler - API_AVAILABLE(ios(10)); - -/** - * Called if this plugin has been registered for `UIApplicationDelegate` callbacks. - * - * @return `YES` if this plugin handles the request. - */ -- (BOOL)application:(UIApplication*)application - openURL:(NSURL*)url - options:(NSDictionary*)options; - -/** - * Called if this plugin has been registered for `UIApplicationDelegate` callbacks. - * - * @return `YES` if this plugin handles the request. - */ -- (BOOL)application:(UIApplication*)application handleOpenURL:(NSURL*)url; - -/** - * Called if this plugin has been registered for `UIApplicationDelegate` callbacks. - * - * @return `YES` if this plugin handles the request. - */ -- (BOOL)application:(UIApplication*)application - openURL:(NSURL*)url - sourceApplication:(NSString*)sourceApplication - annotation:(id)annotation; - -/** - * Called if this plugin has been registered for `UIApplicationDelegate` callbacks. - * - * @return `YES` if this plugin handles the request. - */ -- (BOOL)application:(UIApplication*)application - performActionForShortcutItem:(UIApplicationShortcutItem*)shortcutItem - completionHandler:(void (^)(BOOL succeeded))completionHandler - API_AVAILABLE(ios(9.0)); - -/** - * Called if this plugin has been registered for `UIApplicationDelegate` callbacks. - * - * @return `YES` if this plugin 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. - * - * @return `YES` if this plugin handles the request. - */ -- (BOOL)application:(UIApplication*)application - performFetchWithCompletionHandler:(void (^)(UIBackgroundFetchResult result))completionHandler; - -/** - * Called if this plugin has been registered for `UIApplicationDelegate` callbacks. - * - * @return `YES` if this plugin handles the request. - */ -- (BOOL)application:(UIApplication*)application - continueUserActivity:(NSUserActivity*)userActivity - restorationHandler:(void (^)(NSArray*))restorationHandler; @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* - (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* - (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*)delegate; +- (void)addApplicationLifeCycleDelegate:(NSObject*)delegate; @end NS_ASSUME_NONNULL_END; diff --git a/engine/src/flutter/shell/platform/darwin/ios/framework/Headers/FlutterPluginAppLifeCycleDelegate.h b/engine/src/flutter/shell/platform/darwin/ios/framework/Headers/FlutterPluginAppLifeCycleDelegate.h index b791d907a5..38b1e49fe7 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/framework/Headers/FlutterPluginAppLifeCycleDelegate.h +++ b/engine/src/flutter/shell/platform/darwin/ios/framework/Headers/FlutterPluginAppLifeCycleDelegate.h @@ -21,7 +21,7 @@ FLUTTER_EXPORT * * `delegate` will only referenced weakly. */ -- (void)addDelegate:(NSObject*)delegate; +- (void)addDelegate:(NSObject*)delegate; /** * Calls all plugins registered for `UIApplicationDelegate` callbacks. diff --git a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterPluginAppLifeCycleDelegate.mm b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterPluginAppLifeCycleDelegate.mm index d13214801c..d8c147f990 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterPluginAppLifeCycleDelegate.mm +++ b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterPluginAppLifeCycleDelegate.mm @@ -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 plugin in [_pluginDelegates allObjects]) { - if (!plugin) { + for (NSObject* delegate in [_delegates allObjects]) { + if (!delegate) { continue; } - if ([plugin respondsToSelector:selector]) { + if ([delegate respondsToSelector:selector]) { return YES; } } return NO; } -- (void)addDelegate:(NSObject*)delegate { - [_pluginDelegates addPointer:(__bridge void*)delegate]; - if (isPowerOfTwo([_pluginDelegates count])) { - [_pluginDelegates compact]; +- (void)addDelegate:(NSObject*)delegate { + [_delegates addPointer:(__bridge void*)delegate]; + if (isPowerOfTwo([_delegates count])) { + [_delegates compact]; } } - (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions { - for (id plugin in [_pluginDelegates allObjects]) { - if (!plugin) { + for (NSObject* 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 plugin in [_pluginDelegates allObjects]) { - if (!plugin) { + for (NSObject* 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 plugin in _pluginDelegates) { - if (!plugin) { + for (NSObject* 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 plugin in _pluginDelegates) { - if (!plugin) { + for (NSObject* 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 plugin in _pluginDelegates) { - if (!plugin) { + for (NSObject* 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 plugin in _pluginDelegates) { - if (!plugin) { + for (NSObject* 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 plugin in _pluginDelegates) { - if (!plugin) { + for (NSObject* 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 plugin in _pluginDelegates) { - if (!plugin) { + for (NSObject* 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 plugin in _pluginDelegates) { - if (!plugin) { + for (NSObject* 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 plugin in _pluginDelegates) { - if (!plugin) { + for (NSObject* 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 plugin in _pluginDelegates) { - if (!plugin) { + for (NSObject* 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 plugin in _pluginDelegates) { - if (!plugin) { + for (NSObject* 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*)options { - for (id plugin in _pluginDelegates) { - if (!plugin) { + for (NSObject* 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 plugin in _pluginDelegates) { - if (!plugin) { + for (NSObject* 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 plugin in _pluginDelegates) { - if (!plugin) { + for (NSObject* 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 plugin in _pluginDelegates) { - if (!plugin) { + for (NSObject* 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 plugin in _pluginDelegates) { - if (!plugin) { + for (NSObject* 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 plugin in _pluginDelegates) { - if (!plugin) { + for (NSObject* 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 plugin in _pluginDelegates) { - if (!plugin) { + for (NSObject* 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;