-
Notifications
You must be signed in to change notification settings - Fork 6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Split out lifecycle protocol #9922
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 - | ||
/*************************************************************************************************** | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do these long lines do anything special with doxygen or something? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nope, they are ignored by doxygen. It's for the benefit of someone scrolling through the file to see breaks between the top level objects. |
||
* 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,69 +108,131 @@ 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 | ||
sourceApplication:(NSString*)sourceApplication | ||
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 | ||
completionHandler:(void (^)(BOOL succeeded))completionHandler | ||
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; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Man GitHub diffing is pretty crappy. But I'm assuming you're just copy pasting stuff around.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, just moved around.