@@ -31,12 +31,12 @@ the following:
3131To use the UIScene lifecycle with Flutter, migrate the following support:
3232* All Flutter apps that support iOS - See the [ migration guide for Flutter
3333 apps] ( /release/breaking-changes/uiscenedelegate/#migration-guide-for-flutter-apps )
34- * Flutter plugins that use iOS application lifecycle events - See the [ migration
35- guide for
36- plugins] ( /release/breaking-changes/uiscenedelegate/#migration-guide-for-flutter-plugins )
3734* Flutter embedded in iOS native apps - See the [ migration guide for adding
3835 Flutter to an existing
3936 app] ( /release/breaking-changes/uiscenedelegate/#migration-guide-for-adding-flutter-to-existing-app-add-to-app )
37+ * Flutter plugins that use iOS application lifecycle events - See the [ migration
38+ guide for
39+ plugins] ( /release/breaking-changes/uiscenedelegate/#migration-guide-for-flutter-plugins )
4040
4141Migrating to UIScene shifts the AppDelegate's role—the UI lifecycle is
4242now handled by the UISceneDelegate. The AppDelegate
@@ -269,121 +269,6 @@ For Objective-C projects, create a `SceneDelegate.h` and `SceneDelegate.m`:
269269Info.plist from ` FlutterSceneDelegate ` to
270270` $(PRODUCT_MODULE_NAME).SceneDelegate ` .
271271
272- ## Migration guide for Flutter plugins
273-
274- Not all plugins use lifecycle events. If your plugin does, though, you will
275- need to migrate to UIKit's scene-based lifecycle.
276-
277- 1 . Adopt the ` FlutterSceneLifeCycleDelegate ` protocol
278-
279- ``` swift diff
280- - public final class MyPlugin : NSObject , FlutterPlugin {
281- + public final class MyPlugin : NSObject , FlutterPlugin , FlutterSceneLifeCycleDelegate {
282- ```
283-
284- ```objc diff
285- - @interface MyPlugin : NSObject< FlutterPlugin>
286- + @interface MyPlugin : NSObject< FlutterPlugin, FlutterSceneLifeCycleDelegate>
287- ```
288-
289- 2 . Registers the plugin as a receiver of `UISceneDelegate` calls.
290-
291- To continue supporting apps that have not migrated to the UIScene lifecycle yet,
292- you might consider remaining registered to the App Delegate and keeping the App
293- Delegate events as well.
294-
295- ```swift diff
296- public static func register (with registrar : FlutterPluginRegistrar) {
297- ...
298- registrar.addApplicationDelegate (instance)
299- + registrar.addSceneDelegate (instance)
300- }
301- ```
302-
303- ```objc diff
304- + (void)registerWithRegistrar: (NSObject< FlutterPluginRegistrar> * )registrar {
305- ...
306- [registrar addApplicationDelegate: instance];
307- + [registrar addSceneDelegate: instance];
308- }
309- ```
310-
311- 3 . Add one or more of the following scene events that are needed for your
312- plugin.
313-
314- Most App Delegate UI events have a 1 - to- 1 replacement. To see details on each
315- event, visit Apple's documentation on
316- [UISceneDelegate]({{site.apple - dev}}/ documentation/ uikit/ uiscenedelegate)
317- and
318- [UIWindowSceneDelegate]({{site.apple - dev}}/ documentation/ uikit/ uiwindowscenedelegate).
319-
320-
321- ```swift
322- public func scene (
323- _ scene: UIScene,
324- willConnectTo session: UISceneSession,
325- options connectionOptions: UIScene.ConnectionOptions ?
326- ) -> Bool { }
327-
328- public func sceneDidDisconnect (_ scene : UIScene) { }
329-
330- public func sceneWillEnterForeground (_ scene : UIScene) { }
331-
332- public func sceneDidBecomeActive (_ scene : UIScene) { }
333-
334- public func sceneWillResignActive (_ scene : UIScene) { }
335-
336- public func sceneDidEnterBackground (_ scene : UIScene) { }
337-
338- public func scene (
339- _ scene : UIScene,
340- openURLContexts URLContexts : Set <UIOpenURLContext>
341- ) -> Bool { }
342-
343- public func scene (_ scene : UIScene, continue userActivity : NSUserActivity)
344- -> Bool { }
345-
346- public func windowScene (
347- _ windowScene : UIWindowScene,
348- performActionFor shortcutItem : UIApplicationShortcutItem,
349- completionHandler : @escaping (Bool ) -> Void
350- ) -> Bool { }
351- ```
352-
353- ```objc
354- - (BOOL)scene: (UIScene* )scene
355- willConnectToSession: (UISceneSession* )session
356- options: (nullable UISceneConnectionOptions* )connectionOptions;
357-
358- - (void)sceneDidDisconnect: (UIScene* )scene { }
359-
360- - (void)sceneWillEnterForeground: (UIScene* )scene { }
361-
362- - (void)sceneDidBecomeActive: (UIScene* )scene { }
363-
364- - (void)sceneWillResignActive: (UIScene* )scene { }
365-
366- - (void)sceneDidEnterBackground: (UIScene* )scene { }
367-
368- - (BOOL)scene: (UIScene* )scene openURLContexts: (NSSet< UIOpenURLContext*>* )URLContexts { }
369-
370- - (BOOL)scene: (UIScene* )scene continueUserActivity: (NSUserActivity* )userActivity { }
371-
372- - (BOOL)windowScene: (UIWindowScene* )windowScene
373- performActionForShortcutItem: (UIApplicationShortcutItem* )shortcutItem
374- completionHandler: (void (^ )(BOOL succeeded))completionHandler { }
375- ```
376-
377- 4 . Move launch logic from `application: willFinishLaunchingWithOptions: ` and
378- `application: didFinishLaunchingWithOptions: ` to
379- `scene: willConnectToSession: options: `.
380-
381- Despite `application: willFinishLaunchingWithOptions: ` and
382- `application: didFinishLaunchingWithOptions: ` not being deprecated, after
383- migrating to UIScene lifecycle, the launch options will be `nil `. Any logic
384- performed here related to the launch options should be moved to the
385- `scene: willConnectToSession: options: ` event.
386-
387272## Migration guide for adding Flutter to existing app (Add to App)
388273
389274Similar to the ` FlutterAppDelegate ` , the ` FlutterSceneDelgate ` is recommended
@@ -688,6 +573,137 @@ sceneLifeCycleDelegate.unregisterSceneLifeCycle(with: flutterEngine)
688573[self .sceneLifeCycleDelegate unregisterSceneLifeCycleWithFlutterEngine: self .flutterEngine];
689574```
690575
576+ ## Migration guide for Flutter plugins
577+
578+ Not all plugins use lifecycle events. If your plugin does, though, you will
579+ need to migrate to UIKit's scene- based lifecycle.
580+
581+ 1 . Update the Dart and Flutter SDK versions in your pubspec.yaml
582+
583+ ```yaml
584+ environment:
585+ sdk: ^ 3.10.0 - 290.1 .beta
586+ flutter: " >=3.38.0-0.1.pre"
587+ ```
588+
589+ ::: warning
590+ The below Flutter APIs are available in the 3.38.0 - 0.1 .pre beta, but are not
591+ yet available on stable. You might consider publishing a
592+ [prerelease](https :// dart.dev/tools/pub/publishing#publishing-prereleases) or
593+ [preview](https :// dart.dev/tools/pub/publishing#publish-preview-versions)
594+ version of your plugin to migrate early.
595+ :::
596+
597+ 2 . Adopt the `FlutterSceneLifeCycleDelegate` protocol
598+
599+ ```swift diff
600+ - public final class MyPlugin: NSObject, FlutterPlugin {
601+ + public final class MyPlugin : NSObject , FlutterPlugin , FlutterSceneLifeCycleDelegate {
602+ ```
603+
604+ ```objc diff
605+ - @interface MyPlugin : NSObject< FlutterPlugin>
606+ + @interface MyPlugin : NSObject< FlutterPlugin, FlutterSceneLifeCycleDelegate>
607+ ```
608+
609+ 3 . Registers the plugin as a receiver of `UISceneDelegate` calls.
610+
611+ To continue supporting apps that have not migrated to the UIScene lifecycle yet,
612+ you might consider remaining registered to the App Delegate and keeping the App
613+ Delegate events as well.
614+
615+ ```swift diff
616+ public static func register (with registrar : FlutterPluginRegistrar) {
617+ ...
618+ registrar.addApplicationDelegate (instance)
619+ + registrar.addSceneDelegate (instance)
620+ }
621+ ```
622+
623+ ```objc diff
624+ + (void)registerWithRegistrar: (NSObject< FlutterPluginRegistrar> * )registrar {
625+ ...
626+ [registrar addApplicationDelegate: instance];
627+ + [registrar addSceneDelegate: instance];
628+ }
629+ ```
630+
631+ 4 . Add one or more of the following scene events that are needed for your
632+ plugin.
633+
634+ Most App Delegate UI events have a 1 - to- 1 replacement. To see details for each
635+ event, visit Apple's documentation on
636+ [`UISceneDelegate`][] and [`UIWindowSceneDelegate`][].
637+
638+ [`UISceneDelegate`]: {{site.apple - dev}}/ documentation/ uikit/ uiscenedelegate
639+ [`UIWindowSceneDelegate`]: {{site.apple - dev}}/ documentation/ uikit/ uiwindowscenedelegate
640+
641+
642+ ```swift
643+ public func scene (
644+ _ scene : UIScene,
645+ willConnectTo session : UISceneSession,
646+ options connectionOptions : UIScene.ConnectionOptions?
647+ ) -> Bool { }
648+
649+ public func sceneDidDisconnect (_ scene : UIScene) { }
650+
651+ public func sceneWillEnterForeground (_ scene : UIScene) { }
652+
653+ public func sceneDidBecomeActive (_ scene : UIScene) { }
654+
655+ public func sceneWillResignActive (_ scene : UIScene) { }
656+
657+ public func sceneDidEnterBackground (_ scene : UIScene) { }
658+
659+ public func scene (
660+ _ scene : UIScene,
661+ openURLContexts URLContexts : Set <UIOpenURLContext>
662+ ) -> Bool { }
663+
664+ public func scene (_ scene : UIScene, continue userActivity : NSUserActivity)
665+ -> Bool { }
666+
667+ public func windowScene (
668+ _ windowScene : UIWindowScene,
669+ performActionFor shortcutItem : UIApplicationShortcutItem,
670+ completionHandler : @escaping (Bool ) -> Void
671+ ) -> Bool { }
672+ ```
673+
674+ ```objc
675+ - (BOOL)scene: (UIScene* )scene
676+ willConnectToSession: (UISceneSession* )session
677+ options: (nullable UISceneConnectionOptions* )connectionOptions { }
678+
679+ - (void)sceneDidDisconnect: (UIScene* )scene { }
680+
681+ - (void)sceneWillEnterForeground: (UIScene* )scene { }
682+
683+ - (void)sceneDidBecomeActive: (UIScene* )scene { }
684+
685+ - (void)sceneWillResignActive: (UIScene* )scene { }
686+
687+ - (void)sceneDidEnterBackground: (UIScene* )scene { }
688+
689+ - (BOOL)scene: (UIScene* )scene openURLContexts: (NSSet< UIOpenURLContext*>* )URLContexts { }
690+
691+ - (BOOL)scene: (UIScene* )scene continueUserActivity: (NSUserActivity* )userActivity { }
692+
693+ - (BOOL)windowScene: (UIWindowScene* )windowScene
694+ performActionForShortcutItem: (UIApplicationShortcutItem* )shortcutItem
695+ completionHandler: (void (^ )(BOOL succeeded))completionHandler { }
696+ ```
697+
698+ 5 . Move launch logic from `application: willFinishLaunchingWithOptions: ` and
699+ `application: didFinishLaunchingWithOptions: ` to
700+ `scene: willConnectToSession: options: `.
701+
702+ Despite `application: willFinishLaunchingWithOptions: ` and
703+ `application: didFinishLaunchingWithOptions: ` not being deprecated, after
704+ migrating to the `UIScene` lifecycle, the launch options will be `nil `. Any logic
705+ performed here related to the launch options should be moved to the
706+ `scene: willConnectToSession: options: ` event.
691707
692708## Bespoke FlutterViewController usage
693709
0 commit comments