未验证 提交 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 ...@@ -18,107 +18,55 @@ NS_ASSUME_NONNULL_BEGIN
@protocol FlutterPluginRegistrar; @protocol FlutterPluginRegistrar;
@protocol FlutterPluginRegistry; @protocol FlutterPluginRegistry;
/** #pragma mark -
* A plugin registration callback. /***************************************************************************************************
* * Protocol for listener of events from the UIApplication, typically a FlutterPlugin.
* 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`.
*/ */
+ (void)setPluginRegistrantCallback:(FlutterPluginRegistrantCallback)callback; @protocol FlutterApplicationLifeCycleDelegate
@optional @optional
/** /**
* Called if this plugin has been registered to receive `FlutterMethodCall`s. * Called if this has been registered for `UIApplicationDelegate` callbacks.
*
* @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.
* *
* @return `NO` if this plugin vetoes application launch. * @return `NO` if this vetoes application launch.
*/ */
- (BOOL)application:(UIApplication*)application - (BOOL)application:(UIApplication*)application
didFinishLaunchingWithOptions:(NSDictionary*)launchOptions; 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 - (BOOL)application:(UIApplication*)application
willFinishLaunchingWithOptions:(NSDictionary*)launchOptions; 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; - (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; - (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; - (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; - (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; - (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 - (void)application:(UIApplication*)application
didRegisterUserNotificationSettings:(UIUserNotificationSettings*)notificationSettings didRegisterUserNotificationSettings:(UIUserNotificationSettings*)notificationSettings
...@@ -127,15 +75,15 @@ typedef void (*FlutterPluginRegistrantCallback)(NSObject<FlutterPluginRegistry>* ...@@ -127,15 +75,15 @@ typedef void (*FlutterPluginRegistrantCallback)(NSObject<FlutterPluginRegistry>*
ios(8.0, 10.0)); 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 - (void)application:(UIApplication*)application
didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken; 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 - (BOOL)application:(UIApplication*)application
didReceiveRemoteNotification:(NSDictionary*)userInfo didReceiveRemoteNotification:(NSDictionary*)userInfo
...@@ -160,25 +108,25 @@ typedef void (*FlutterPluginRegistrantCallback)(NSObject<FlutterPluginRegistry>* ...@@ -160,25 +108,25 @@ typedef void (*FlutterPluginRegistrantCallback)(NSObject<FlutterPluginRegistry>*
API_AVAILABLE(ios(10)); 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 - (BOOL)application:(UIApplication*)application
openURL:(NSURL*)url openURL:(NSURL*)url
options:(NSDictionary<UIApplicationOpenURLOptionsKey, id>*)options; 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; - (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 - (BOOL)application:(UIApplication*)application
openURL:(NSURL*)url openURL:(NSURL*)url
...@@ -186,9 +134,9 @@ typedef void (*FlutterPluginRegistrantCallback)(NSObject<FlutterPluginRegistry>* ...@@ -186,9 +134,9 @@ typedef void (*FlutterPluginRegistrantCallback)(NSObject<FlutterPluginRegistry>*
annotation:(id)annotation; 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 - (BOOL)application:(UIApplication*)application
performActionForShortcutItem:(UIApplicationShortcutItem*)shortcutItem performActionForShortcutItem:(UIApplicationShortcutItem*)shortcutItem
...@@ -196,33 +144,95 @@ typedef void (*FlutterPluginRegistrantCallback)(NSObject<FlutterPluginRegistry>* ...@@ -196,33 +144,95 @@ typedef void (*FlutterPluginRegistrantCallback)(NSObject<FlutterPluginRegistry>*
API_AVAILABLE(ios(9.0)); 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 - (BOOL)application:(UIApplication*)application
handleEventsForBackgroundURLSession:(nonnull NSString*)identifier handleEventsForBackgroundURLSession:(nonnull NSString*)identifier
completionHandler:(nonnull void (^)(void))completionHandler; 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 - (BOOL)application:(UIApplication*)application
performFetchWithCompletionHandler:(void (^)(UIBackgroundFetchResult result))completionHandler; 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 - (BOOL)application:(UIApplication*)application
continueUserActivity:(NSUserActivity*)userActivity continueUserActivity:(NSUserActivity*)userActivity
restorationHandler:(void (^)(NSArray*))restorationHandler; restorationHandler:(void (^)(NSArray*))restorationHandler;
@end @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 *Registration context for a single `FlutterPlugin`, providing a one stop shop
*for the plugin to access contextual information and register callbacks for *for the plugin to access contextual information and register callbacks for
*various application events. *various application events.
...@@ -312,7 +322,8 @@ typedef void (*FlutterPluginRegistrantCallback)(NSObject<FlutterPluginRegistry>* ...@@ -312,7 +322,8 @@ typedef void (*FlutterPluginRegistrantCallback)(NSObject<FlutterPluginRegistry>*
- (NSString*)lookupKeyForAsset:(NSString*)asset fromPackage:(NSString*)package; - (NSString*)lookupKeyForAsset:(NSString*)asset fromPackage:(NSString*)package;
@end @end
/** #pragma mark -
/***************************************************************************************************
* A registry of Flutter iOS plugins. * A registry of Flutter iOS plugins.
* *
* Plugins are identified by unique string keys, typically the name of the * Plugins are identified by unique string keys, typically the name of the
...@@ -357,12 +368,13 @@ typedef void (*FlutterPluginRegistrantCallback)(NSObject<FlutterPluginRegistry>* ...@@ -357,12 +368,13 @@ typedef void (*FlutterPluginRegistrantCallback)(NSObject<FlutterPluginRegistry>*
- (NSObject*)valuePublishedByPlugin:(NSString*)pluginKey; - (NSObject*)valuePublishedByPlugin:(NSString*)pluginKey;
@end @end
/** #pragma mark -
/***************************************************************************************************
* Implement this in the `UIAppDelegate` of your app to enable Flutter plugins to register * Implement this in the `UIAppDelegate` of your app to enable Flutter plugins to register
* themselves to the application life cycle events. * themselves to the application life cycle events.
*/ */
@protocol FlutterAppLifeCycleProvider @protocol FlutterAppLifeCycleProvider
- (void)addApplicationLifeCycleDelegate:(NSObject<FlutterPlugin>*)delegate; - (void)addApplicationLifeCycleDelegate:(NSObject<FlutterApplicationLifeCycleDelegate>*)delegate;
@end @end
NS_ASSUME_NONNULL_END; NS_ASSUME_NONNULL_END;
......
...@@ -21,7 +21,7 @@ FLUTTER_EXPORT ...@@ -21,7 +21,7 @@ FLUTTER_EXPORT
* *
* `delegate` will only referenced weakly. * `delegate` will only referenced weakly.
*/ */
- (void)addDelegate:(NSObject<FlutterPlugin>*)delegate; - (void)addDelegate:(NSObject<FlutterApplicationLifeCycleDelegate>*)delegate;
/** /**
* Calls all plugins registered for `UIApplicationDelegate` callbacks. * Calls all plugins registered for `UIApplicationDelegate` callbacks.
......
...@@ -19,20 +19,20 @@ static const SEL selectorsHandledByPlugins[] = { ...@@ -19,20 +19,20 @@ static const SEL selectorsHandledByPlugins[] = {
UIBackgroundTaskIdentifier _debugBackgroundTask; UIBackgroundTaskIdentifier _debugBackgroundTask;
// Weak references to registered plugins. // Weak references to registered plugins.
NSPointerArray* _pluginDelegates; NSPointerArray* _delegates;
} }
- (instancetype)init { - (instancetype)init {
if (self = [super init]) { if (self = [super init]) {
std::string cachePath = fml::paths::JoinPaths({getenv("HOME"), kCallbackCacheSubDir}); std::string cachePath = fml::paths::JoinPaths({getenv("HOME"), kCallbackCacheSubDir});
[FlutterCallbackCache setCachePath:[NSString stringWithUTF8String:cachePath.c_str()]]; [FlutterCallbackCache setCachePath:[NSString stringWithUTF8String:cachePath.c_str()]];
_pluginDelegates = [[NSPointerArray weakObjectsPointerArray] retain]; _delegates = [[NSPointerArray weakObjectsPointerArray] retain];
} }
return self; return self;
} }
- (void)dealloc { - (void)dealloc {
[_pluginDelegates release]; [_delegates release];
[super dealloc]; [super dealloc];
} }
...@@ -50,32 +50,32 @@ static BOOL isPowerOfTwo(NSUInteger x) { ...@@ -50,32 +50,32 @@ static BOOL isPowerOfTwo(NSUInteger x) {
} }
- (BOOL)hasPluginThatRespondsToSelector:(SEL)selector { - (BOOL)hasPluginThatRespondsToSelector:(SEL)selector {
for (id<FlutterPlugin> plugin in [_pluginDelegates allObjects]) { for (NSObject<FlutterApplicationLifeCycleDelegate>* delegate in [_delegates allObjects]) {
if (!plugin) { if (!delegate) {
continue; continue;
} }
if ([plugin respondsToSelector:selector]) { if ([delegate respondsToSelector:selector]) {
return YES; return YES;
} }
} }
return NO; return NO;
} }
- (void)addDelegate:(NSObject<FlutterPlugin>*)delegate { - (void)addDelegate:(NSObject<FlutterApplicationLifeCycleDelegate>*)delegate {
[_pluginDelegates addPointer:(__bridge void*)delegate]; [_delegates addPointer:(__bridge void*)delegate];
if (isPowerOfTwo([_pluginDelegates count])) { if (isPowerOfTwo([_delegates count])) {
[_pluginDelegates compact]; [_delegates compact];
} }
} }
- (BOOL)application:(UIApplication*)application - (BOOL)application:(UIApplication*)application
didFinishLaunchingWithOptions:(NSDictionary*)launchOptions { didFinishLaunchingWithOptions:(NSDictionary*)launchOptions {
for (id<FlutterPlugin> plugin in [_pluginDelegates allObjects]) { for (NSObject<FlutterApplicationLifeCycleDelegate>* delegate in [_delegates allObjects]) {
if (!plugin) { if (!delegate) {
continue; continue;
} }
if ([plugin respondsToSelector:_cmd]) { if ([delegate respondsToSelector:_cmd]) {
if (![plugin application:application didFinishLaunchingWithOptions:launchOptions]) { if (![delegate application:application didFinishLaunchingWithOptions:launchOptions]) {
return NO; return NO;
} }
} }
...@@ -86,12 +86,12 @@ static BOOL isPowerOfTwo(NSUInteger x) { ...@@ -86,12 +86,12 @@ static BOOL isPowerOfTwo(NSUInteger x) {
- (BOOL)application:(UIApplication*)application - (BOOL)application:(UIApplication*)application
willFinishLaunchingWithOptions:(NSDictionary*)launchOptions { willFinishLaunchingWithOptions:(NSDictionary*)launchOptions {
flutter::DartCallbackCache::LoadCacheFromDisk(); flutter::DartCallbackCache::LoadCacheFromDisk();
for (id<FlutterPlugin> plugin in [_pluginDelegates allObjects]) { for (NSObject<FlutterApplicationLifeCycleDelegate>* delegate in [_delegates allObjects]) {
if (!plugin) { if (!delegate) {
continue; continue;
} }
if ([plugin respondsToSelector:_cmd]) { if ([delegate respondsToSelector:_cmd]) {
if (![plugin application:application willFinishLaunchingWithOptions:launchOptions]) { if (![delegate application:application willFinishLaunchingWithOptions:launchOptions]) {
return NO; return NO;
} }
} }
...@@ -117,12 +117,12 @@ static BOOL isPowerOfTwo(NSUInteger x) { ...@@ -117,12 +117,12 @@ static BOOL isPowerOfTwo(NSUInteger x) {
"To reconnect, launch your application again via 'flutter run'"; "To reconnect, launch your application again via 'flutter run'";
}]; }];
#endif // FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_DEBUG #endif // FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_DEBUG
for (id<FlutterPlugin> plugin in _pluginDelegates) { for (NSObject<FlutterApplicationLifeCycleDelegate>* delegate in _delegates) {
if (!plugin) { if (!delegate) {
continue; continue;
} }
if ([plugin respondsToSelector:_cmd]) { if ([delegate respondsToSelector:_cmd]) {
[plugin applicationDidEnterBackground:application]; [delegate applicationDidEnterBackground:application];
} }
} }
} }
...@@ -131,45 +131,45 @@ static BOOL isPowerOfTwo(NSUInteger x) { ...@@ -131,45 +131,45 @@ static BOOL isPowerOfTwo(NSUInteger x) {
#if FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_DEBUG #if FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_DEBUG
[application endBackgroundTask:_debugBackgroundTask]; [application endBackgroundTask:_debugBackgroundTask];
#endif // FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_DEBUG #endif // FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_DEBUG
for (id<FlutterPlugin> plugin in _pluginDelegates) { for (NSObject<FlutterApplicationLifeCycleDelegate>* delegate in _delegates) {
if (!plugin) { if (!delegate) {
continue; continue;
} }
if ([plugin respondsToSelector:_cmd]) { if ([delegate respondsToSelector:_cmd]) {
[plugin applicationWillEnterForeground:application]; [delegate applicationWillEnterForeground:application];
} }
} }
} }
- (void)applicationWillResignActive:(UIApplication*)application { - (void)applicationWillResignActive:(UIApplication*)application {
for (id<FlutterPlugin> plugin in _pluginDelegates) { for (NSObject<FlutterApplicationLifeCycleDelegate>* delegate in _delegates) {
if (!plugin) { if (!delegate) {
continue; continue;
} }
if ([plugin respondsToSelector:_cmd]) { if ([delegate respondsToSelector:_cmd]) {
[plugin applicationWillResignActive:application]; [delegate applicationWillResignActive:application];
} }
} }
} }
- (void)applicationDidBecomeActive:(UIApplication*)application { - (void)applicationDidBecomeActive:(UIApplication*)application {
for (id<FlutterPlugin> plugin in _pluginDelegates) { for (NSObject<FlutterApplicationLifeCycleDelegate>* delegate in _delegates) {
if (!plugin) { if (!delegate) {
continue; continue;
} }
if ([plugin respondsToSelector:_cmd]) { if ([delegate respondsToSelector:_cmd]) {
[plugin applicationDidBecomeActive:application]; [delegate applicationDidBecomeActive:application];
} }
} }
} }
- (void)applicationWillTerminate:(UIApplication*)application { - (void)applicationWillTerminate:(UIApplication*)application {
for (id<FlutterPlugin> plugin in _pluginDelegates) { for (NSObject<FlutterApplicationLifeCycleDelegate>* delegate in _delegates) {
if (!plugin) { if (!delegate) {
continue; continue;
} }
if ([plugin respondsToSelector:_cmd]) { if ([delegate respondsToSelector:_cmd]) {
[plugin applicationWillTerminate:application]; [delegate applicationWillTerminate:application];
} }
} }
} }
...@@ -178,12 +178,12 @@ static BOOL isPowerOfTwo(NSUInteger x) { ...@@ -178,12 +178,12 @@ static BOOL isPowerOfTwo(NSUInteger x) {
#pragma GCC diagnostic ignored "-Wdeprecated-declarations" #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
- (void)application:(UIApplication*)application - (void)application:(UIApplication*)application
didRegisterUserNotificationSettings:(UIUserNotificationSettings*)notificationSettings { didRegisterUserNotificationSettings:(UIUserNotificationSettings*)notificationSettings {
for (id<FlutterPlugin> plugin in _pluginDelegates) { for (NSObject<FlutterApplicationLifeCycleDelegate>* delegate in _delegates) {
if (!plugin) { if (!delegate) {
continue; continue;
} }
if ([plugin respondsToSelector:_cmd]) { if ([delegate respondsToSelector:_cmd]) {
[plugin application:application didRegisterUserNotificationSettings:notificationSettings]; [delegate application:application didRegisterUserNotificationSettings:notificationSettings];
} }
} }
} }
...@@ -191,12 +191,13 @@ static BOOL isPowerOfTwo(NSUInteger x) { ...@@ -191,12 +191,13 @@ static BOOL isPowerOfTwo(NSUInteger x) {
- (void)application:(UIApplication*)application - (void)application:(UIApplication*)application
didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken { didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken {
for (id<FlutterPlugin> plugin in _pluginDelegates) { for (NSObject<FlutterApplicationLifeCycleDelegate>* delegate in _delegates) {
if (!plugin) { if (!delegate) {
continue; continue;
} }
if ([plugin respondsToSelector:_cmd]) { if ([delegate respondsToSelector:_cmd]) {
[plugin application:application didRegisterForRemoteNotificationsWithDeviceToken:deviceToken]; [delegate application:application
didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];
} }
} }
} }
...@@ -204,12 +205,12 @@ static BOOL isPowerOfTwo(NSUInteger x) { ...@@ -204,12 +205,12 @@ static BOOL isPowerOfTwo(NSUInteger x) {
- (void)application:(UIApplication*)application - (void)application:(UIApplication*)application
didReceiveRemoteNotification:(NSDictionary*)userInfo didReceiveRemoteNotification:(NSDictionary*)userInfo
fetchCompletionHandler:(void (^)(UIBackgroundFetchResult result))completionHandler { fetchCompletionHandler:(void (^)(UIBackgroundFetchResult result))completionHandler {
for (id<FlutterPlugin> plugin in _pluginDelegates) { for (NSObject<FlutterApplicationLifeCycleDelegate>* delegate in _delegates) {
if (!plugin) { if (!delegate) {
continue; continue;
} }
if ([plugin respondsToSelector:_cmd]) { if ([delegate respondsToSelector:_cmd]) {
if ([plugin application:application if ([delegate application:application
didReceiveRemoteNotification:userInfo didReceiveRemoteNotification:userInfo
fetchCompletionHandler:completionHandler]) { fetchCompletionHandler:completionHandler]) {
return; return;
...@@ -222,12 +223,12 @@ static BOOL isPowerOfTwo(NSUInteger x) { ...@@ -222,12 +223,12 @@ static BOOL isPowerOfTwo(NSUInteger x) {
#pragma GCC diagnostic ignored "-Wdeprecated-declarations" #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
- (void)application:(UIApplication*)application - (void)application:(UIApplication*)application
didReceiveLocalNotification:(UILocalNotification*)notification { didReceiveLocalNotification:(UILocalNotification*)notification {
for (id<FlutterPlugin> plugin in _pluginDelegates) { for (NSObject<FlutterApplicationLifeCycleDelegate>* delegate in _delegates) {
if (!plugin) { if (!delegate) {
continue; continue;
} }
if ([plugin respondsToSelector:_cmd]) { if ([delegate respondsToSelector:_cmd]) {
[plugin application:application didReceiveLocalNotification:notification]; [delegate application:application didReceiveLocalNotification:notification];
} }
} }
} }
...@@ -238,14 +239,14 @@ static BOOL isPowerOfTwo(NSUInteger x) { ...@@ -238,14 +239,14 @@ static BOOL isPowerOfTwo(NSUInteger x) {
withCompletionHandler: withCompletionHandler:
(void (^)(UNNotificationPresentationOptions options))completionHandler { (void (^)(UNNotificationPresentationOptions options))completionHandler {
if (@available(iOS 10.0, *)) { if (@available(iOS 10.0, *)) {
for (id<FlutterPlugin> plugin in _pluginDelegates) { for (NSObject<FlutterApplicationLifeCycleDelegate>* delegate in _delegates) {
if (!plugin) { if (!delegate) {
continue; continue;
} }
if ([plugin respondsToSelector:_cmd]) { if ([delegate respondsToSelector:_cmd]) {
[plugin userNotificationCenter:center [delegate userNotificationCenter:center
willPresentNotification:notification willPresentNotification:notification
withCompletionHandler:completionHandler]; withCompletionHandler:completionHandler];
} }
} }
} }
...@@ -254,12 +255,12 @@ static BOOL isPowerOfTwo(NSUInteger x) { ...@@ -254,12 +255,12 @@ static BOOL isPowerOfTwo(NSUInteger x) {
- (BOOL)application:(UIApplication*)application - (BOOL)application:(UIApplication*)application
openURL:(NSURL*)url openURL:(NSURL*)url
options:(NSDictionary<UIApplicationOpenURLOptionsKey, id>*)options { options:(NSDictionary<UIApplicationOpenURLOptionsKey, id>*)options {
for (id<FlutterPlugin> plugin in _pluginDelegates) { for (NSObject<FlutterApplicationLifeCycleDelegate>* delegate in _delegates) {
if (!plugin) { if (!delegate) {
continue; continue;
} }
if ([plugin respondsToSelector:_cmd]) { if ([delegate respondsToSelector:_cmd]) {
if ([plugin application:application openURL:url options:options]) { if ([delegate application:application openURL:url options:options]) {
return YES; return YES;
} }
} }
...@@ -268,12 +269,12 @@ static BOOL isPowerOfTwo(NSUInteger x) { ...@@ -268,12 +269,12 @@ static BOOL isPowerOfTwo(NSUInteger x) {
} }
- (BOOL)application:(UIApplication*)application handleOpenURL:(NSURL*)url { - (BOOL)application:(UIApplication*)application handleOpenURL:(NSURL*)url {
for (id<FlutterPlugin> plugin in _pluginDelegates) { for (NSObject<FlutterApplicationLifeCycleDelegate>* delegate in _delegates) {
if (!plugin) { if (!delegate) {
continue; continue;
} }
if ([plugin respondsToSelector:_cmd]) { if ([delegate respondsToSelector:_cmd]) {
if ([plugin application:application handleOpenURL:url]) { if ([delegate application:application handleOpenURL:url]) {
return YES; return YES;
} }
} }
...@@ -285,12 +286,12 @@ static BOOL isPowerOfTwo(NSUInteger x) { ...@@ -285,12 +286,12 @@ static BOOL isPowerOfTwo(NSUInteger x) {
openURL:(NSURL*)url openURL:(NSURL*)url
sourceApplication:(NSString*)sourceApplication sourceApplication:(NSString*)sourceApplication
annotation:(id)annotation { annotation:(id)annotation {
for (id<FlutterPlugin> plugin in _pluginDelegates) { for (NSObject<FlutterApplicationLifeCycleDelegate>* delegate in _delegates) {
if (!plugin) { if (!delegate) {
continue; continue;
} }
if ([plugin respondsToSelector:_cmd]) { if ([delegate respondsToSelector:_cmd]) {
if ([plugin application:application if ([delegate application:application
openURL:url openURL:url
sourceApplication:sourceApplication sourceApplication:sourceApplication
annotation:annotation]) { annotation:annotation]) {
...@@ -304,12 +305,12 @@ static BOOL isPowerOfTwo(NSUInteger x) { ...@@ -304,12 +305,12 @@ static BOOL isPowerOfTwo(NSUInteger x) {
- (void)application:(UIApplication*)application - (void)application:(UIApplication*)application
performActionForShortcutItem:(UIApplicationShortcutItem*)shortcutItem performActionForShortcutItem:(UIApplicationShortcutItem*)shortcutItem
completionHandler:(void (^)(BOOL succeeded))completionHandler NS_AVAILABLE_IOS(9_0) { completionHandler:(void (^)(BOOL succeeded))completionHandler NS_AVAILABLE_IOS(9_0) {
for (id<FlutterPlugin> plugin in _pluginDelegates) { for (NSObject<FlutterApplicationLifeCycleDelegate>* delegate in _delegates) {
if (!plugin) { if (!delegate) {
continue; continue;
} }
if ([plugin respondsToSelector:_cmd]) { if ([delegate respondsToSelector:_cmd]) {
if ([plugin application:application if ([delegate application:application
performActionForShortcutItem:shortcutItem performActionForShortcutItem:shortcutItem
completionHandler:completionHandler]) { completionHandler:completionHandler]) {
return; return;
...@@ -321,12 +322,12 @@ static BOOL isPowerOfTwo(NSUInteger x) { ...@@ -321,12 +322,12 @@ static BOOL isPowerOfTwo(NSUInteger x) {
- (BOOL)application:(UIApplication*)application - (BOOL)application:(UIApplication*)application
handleEventsForBackgroundURLSession:(nonnull NSString*)identifier handleEventsForBackgroundURLSession:(nonnull NSString*)identifier
completionHandler:(nonnull void (^)())completionHandler { completionHandler:(nonnull void (^)())completionHandler {
for (id<FlutterPlugin> plugin in _pluginDelegates) { for (NSObject<FlutterApplicationLifeCycleDelegate>* delegate in _delegates) {
if (!plugin) { if (!delegate) {
continue; continue;
} }
if ([plugin respondsToSelector:_cmd]) { if ([delegate respondsToSelector:_cmd]) {
if ([plugin application:application if ([delegate application:application
handleEventsForBackgroundURLSession:identifier handleEventsForBackgroundURLSession:identifier
completionHandler:completionHandler]) { completionHandler:completionHandler]) {
return YES; return YES;
...@@ -338,12 +339,12 @@ static BOOL isPowerOfTwo(NSUInteger x) { ...@@ -338,12 +339,12 @@ static BOOL isPowerOfTwo(NSUInteger x) {
- (BOOL)application:(UIApplication*)application - (BOOL)application:(UIApplication*)application
performFetchWithCompletionHandler:(void (^)(UIBackgroundFetchResult result))completionHandler { performFetchWithCompletionHandler:(void (^)(UIBackgroundFetchResult result))completionHandler {
for (id<FlutterPlugin> plugin in _pluginDelegates) { for (NSObject<FlutterApplicationLifeCycleDelegate>* delegate in _delegates) {
if (!plugin) { if (!delegate) {
continue; continue;
} }
if ([plugin respondsToSelector:_cmd]) { if ([delegate respondsToSelector:_cmd]) {
if ([plugin application:application performFetchWithCompletionHandler:completionHandler]) { if ([delegate application:application performFetchWithCompletionHandler:completionHandler]) {
return YES; return YES;
} }
} }
...@@ -354,12 +355,12 @@ static BOOL isPowerOfTwo(NSUInteger x) { ...@@ -354,12 +355,12 @@ static BOOL isPowerOfTwo(NSUInteger x) {
- (BOOL)application:(UIApplication*)application - (BOOL)application:(UIApplication*)application
continueUserActivity:(NSUserActivity*)userActivity continueUserActivity:(NSUserActivity*)userActivity
restorationHandler:(void (^)(NSArray*))restorationHandler { restorationHandler:(void (^)(NSArray*))restorationHandler {
for (id<FlutterPlugin> plugin in _pluginDelegates) { for (NSObject<FlutterApplicationLifeCycleDelegate>* delegate in _delegates) {
if (!plugin) { if (!delegate) {
continue; continue;
} }
if ([plugin respondsToSelector:_cmd]) { if ([delegate respondsToSelector:_cmd]) {
if ([plugin application:application if ([delegate application:application
continueUserActivity:userActivity continueUserActivity:userActivity
restorationHandler:restorationHandler]) { restorationHandler:restorationHandler]) {
return YES; return YES;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册