Flutter iOS Embedder
FlutterPluginSceneLifeCycleDelegate Class Reference

#import <FlutterSceneLifeCycle.h>

Inheritance diagram for FlutterPluginSceneLifeCycleDelegate:
<FlutterSceneLifeCycleEngineRegistration>

Instance Methods

(void) - scene:willConnectToSession:options:
 
(void) - sceneDidDisconnect:
 
(void) - sceneWillEnterForeground:
 
(void) - sceneDidBecomeActive:
 
(void) - sceneWillResignActive:
 
(void) - sceneDidEnterBackground:
 
(void) - scene:openURLContexts:
 
(void) - scene:continueUserActivity:
 
(void) - windowScene:performActionForShortcutItem:completionHandler:
 
(void) - updateFlutterManagedEnginesInScene:
 
(void) - scene:willConnectToSession:flutterEngine:options:
 
(NSArray *) - allEngines
 
- Instance Methods inherited from <FlutterSceneLifeCycleEngineRegistration>
(BOOL) - registerSceneLifeCycleWithFlutterEngine:
 
(BOOL) - unregisterSceneLifeCycleWithFlutterEngine:
 

Properties

UISceneConnectionOptions * connectionOptions
 
NSPointerArray * flutterManagedEngines
 
NSPointerArray * developerManagedEngines
 

Detailed Description

Forwards UISceneDelegate and UIWindowSceneDelegate callbacks to plugins that register for them.

This class is responsible for receiving UISceneDelegate and UIWindowSceneDelegate callbacks and forwarding them to any plugins.

Definition at line 149 of file FlutterSceneLifeCycle.h.

Method Documentation

◆ allEngines

- (NSArray*) allEngines

◆ scene:continueUserActivity:

- (void) scene: (UIScene*)  scene
continueUserActivity: (NSUserActivity*)  userActivity 

Calls all plugins registered for UIWindowScene callbacks in order of registration until a plugin handles the request.

Definition at line 36 of file FlutterSceneLifeCycle.mm.

323  :(UIScene*)scene continueUserActivity:(NSUserActivity*)userActivity {
324  [self updateFlutterManagedEnginesInScene:scene];
325 
326  // Track engines that had this event handled by a plugin.
327  NSMutableSet<FlutterEngine*>* enginesHandledByPlugin = [NSMutableSet set];
328  for (FlutterEngine* engine in [self allEngines]) {
329  if ([engine.sceneLifeCycleDelegate scene:scene continueUserActivity:userActivity]) {
330  [enginesHandledByPlugin addObject:engine];
331  }
332  }
333 
334  // If no plugins handled this, give the application fallback a chance to handle it.
335  if (enginesHandledByPlugin.count == 0) {
336  if ([[self applicationLifeCycleDelegate] sceneFallbackContinueUserActivity:userActivity]) {
337  // If the application fallback handles it, don't do any deeplinking.
338  return;
339  }
340  }
341 
342  // For any engine that was not handled by a plugin, do deeplinking.
343  for (FlutterEngine* engine in [self allEngines]) {
344  if ([enginesHandledByPlugin containsObject:engine]) {
345  continue;
346  }
347  [self handleDeeplink:userActivity.webpageURL flutterEngine:engine relayToSystemIfUnhandled:YES];
348  }
349 }

◆ scene:openURLContexts:

- (void) scene: (UIScene*)  scene
openURLContexts: (NSSet<UIOpenURLContext*>*)  URLContexts 

Calls all plugins registered for UIWindowScene callbacks in order of registration until a plugin handles the request.

Definition at line 36 of file FlutterSceneLifeCycle.mm.

289  :(UIScene*)scene openURLContexts:(NSSet<UIOpenURLContext*>*)URLContexts {
290  [self updateFlutterManagedEnginesInScene:scene];
291 
292  // Track engines that had this event handled by a plugin.
293  NSMutableSet<FlutterEngine*>* enginesHandledByPlugin = [NSMutableSet set];
294  for (FlutterEngine* engine in [self allEngines]) {
295  if ([engine.sceneLifeCycleDelegate scene:scene openURLContexts:URLContexts]) {
296  [enginesHandledByPlugin addObject:engine];
297  }
298  }
299 
300  // If no plugins handled this, give the application fallback a chance to handle it.
301  if (enginesHandledByPlugin.count == 0) {
302  if ([[self applicationLifeCycleDelegate] sceneFallbackOpenURLContexts:URLContexts]) {
303  // If the application fallback handles it, don't do any deeplinking.
304  return;
305  }
306  }
307 
308  // For any engine that was not handled by a plugin, do deeplinking.
309  for (FlutterEngine* engine in [self allEngines]) {
310  if ([enginesHandledByPlugin containsObject:engine]) {
311  continue;
312  }
313  for (UIOpenURLContext* urlContext in URLContexts) {
314  if ([self handleDeeplink:urlContext.URL flutterEngine:engine relayToSystemIfUnhandled:NO]) {
315  break;
316  }
317  }
318  }
319 }

◆ scene:willConnectToSession:flutterEngine:options:

- (void) scene: (UIScene *)  scene
willConnectToSession: (UISceneSession *)  session
flutterEngine: (FlutterEngine *)  engine
options: (UISceneConnectionOptions *)  connectionOptions 

◆ scene:willConnectToSession:options:

- (void) scene: (UIScene*)  scene
willConnectToSession: (UISceneSession*)  session
options: (UISceneConnectionOptions*)  connectionOptions 

Calls all plugins registered for UIWindowScene callbacks in order of registration until a plugin handles the request.

Definition at line 36 of file FlutterSceneLifeCycle.mm.

191  :(UIScene*)scene
192  willConnectToSession:(UISceneSession*)session
193  options:(UISceneConnectionOptions*)connectionOptions {
194  self.connectionOptions = connectionOptions;
195  if ([scene.delegate conformsToProtocol:@protocol(UIWindowSceneDelegate)]) {
196  NSObject<UIWindowSceneDelegate>* sceneDelegate =
197  (NSObject<UIWindowSceneDelegate>*)scene.delegate;
198  if ([sceneDelegate.window.rootViewController isKindOfClass:[FlutterViewController class]]) {
199  FlutterViewController* rootViewController =
200  (FlutterViewController*)sceneDelegate.window.rootViewController;
201  [self addFlutterManagedEngine:rootViewController.engine];
202  }
203  }
204 
205  [self updateFlutterManagedEnginesInScene:scene];
206 
207  for (FlutterEngine* engine in [self allEngines]) {
208  [self scene:scene willConnectToSession:session flutterEngine:engine options:connectionOptions];
209  }
210 }

◆ sceneDidBecomeActive:

- (void) sceneDidBecomeActive: (UIScene*)  scene

Definition at line 36 of file FlutterSceneLifeCycle.mm.

261  :(UIScene*)scene {
262  [self updateFlutterManagedEnginesInScene:scene];
263  for (FlutterEngine* engine in [self allEngines]) {
264  [engine.sceneLifeCycleDelegate sceneDidBecomeActive:scene];
265  }
266  [[self applicationLifeCycleDelegate] sceneDidBecomeActiveFallback];
267 }

◆ sceneDidDisconnect:

- (void) sceneDidDisconnect: (UIScene*)  scene

Definition at line 36 of file FlutterSceneLifeCycle.mm.

243  :(UIScene*)scene {
244  [self updateFlutterManagedEnginesInScene:scene];
245  for (FlutterEngine* engine in [self allEngines]) {
246  [engine.sceneLifeCycleDelegate sceneDidDisconnect:scene];
247  }
248  // There is no application equivalent for this event and therefore no fallback.
249 }

◆ sceneDidEnterBackground:

- (void) sceneDidEnterBackground: (UIScene*)  scene

Definition at line 36 of file FlutterSceneLifeCycle.mm.

279  :(UIScene*)scene {
280  [self updateFlutterManagedEnginesInScene:scene];
281  for (FlutterEngine* engine in [self allEngines]) {
282  [engine.sceneLifeCycleDelegate sceneDidEnterBackground:scene];
283  }
284  [[self applicationLifeCycleDelegate] sceneDidEnterBackgroundFallback];
285 }

◆ sceneWillEnterForeground:

- (void) sceneWillEnterForeground: (UIScene*)  scene

Definition at line 36 of file FlutterSceneLifeCycle.mm.

253  :(UIScene*)scene {
254  [self updateFlutterManagedEnginesInScene:scene];
255  for (FlutterEngine* engine in [self allEngines]) {
256  [engine.sceneLifeCycleDelegate sceneWillEnterForeground:scene];
257  }
258  [[self applicationLifeCycleDelegate] sceneWillEnterForegroundFallback];
259 }

◆ sceneWillResignActive:

- (void) sceneWillResignActive: (UIScene*)  scene

Definition at line 36 of file FlutterSceneLifeCycle.mm.

271  :(UIScene*)scene {
272  [self updateFlutterManagedEnginesInScene:scene];
273  for (FlutterEngine* engine in [self allEngines]) {
274  [engine.sceneLifeCycleDelegate sceneWillResignActive:scene];
275  }
276  [[self applicationLifeCycleDelegate] sceneWillResignActiveFallback];
277 }

◆ updateFlutterManagedEnginesInScene:

- (void) updateFlutterManagedEnginesInScene: (UIScene *)  scene

◆ windowScene:performActionForShortcutItem:completionHandler:

- (void) windowScene: (UIWindowScene*)  windowScene
performActionForShortcutItem: (UIApplicationShortcutItem*)  shortcutItem
completionHandler: (void(^)(BOOL succeeded))  completionHandler 

Calls all plugins registered for UIWindowScene callbacks in order of registration until a plugin handles the request.

Definition at line 36 of file FlutterSceneLifeCycle.mm.

409  :(UIWindowScene*)windowScene
410  performActionForShortcutItem:(UIApplicationShortcutItem*)shortcutItem
411  completionHandler:(void (^)(BOOL succeeded))completionHandler {
412  [self updateFlutterManagedEnginesInScene:windowScene];
413 
414  BOOL handledByPlugin = NO;
415  for (FlutterEngine* engine in [self allEngines]) {
416  BOOL result = [engine.sceneLifeCycleDelegate windowScene:windowScene
417  performActionForShortcutItem:shortcutItem
418  completionHandler:completionHandler];
419  if (result) {
420  handledByPlugin = YES;
421  }
422  }
423  if (!handledByPlugin) {
424  [[self applicationLifeCycleDelegate]
425  sceneFallbackPerformActionForShortcutItem:shortcutItem
426  completionHandler:completionHandler];
427  }
428 }

Property Documentation

◆ connectionOptions

- (UISceneConnectionOptions*) connectionOptions
readwritenonatomicstrong

Provided by category FlutterPluginSceneLifeCycleDelegate(Test).

Definition at line 13 of file FlutterSceneLifeCycle_Test.h.

◆ developerManagedEngines

- (NSPointerArray*) developerManagedEngines
readwritenonatomicstrong

Provided by category FlutterPluginSceneLifeCycleDelegate(Test).

Definition at line 15 of file FlutterSceneLifeCycle_Test.h.

◆ flutterManagedEngines

- (NSPointerArray*) flutterManagedEngines
readwritenonatomicstrong

Provided by category FlutterPluginSceneLifeCycleDelegate(Test).

Definition at line 14 of file FlutterSceneLifeCycle_Test.h.


The documentation for this class was generated from the following files: