Add UIScene lifecycle support (#6, #74)#77
Open
segidev wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Apple is requiring iOS apps to adopt the
UISceneDelegatelifecycle, and Flutter 3.38+ makes it the default for new and migrated apps (see docs.flutter.dev/to/uiscene-migration). Once a host app turns onUIApplicationSceneManifest, the existingapplication(_:open:)/application(_:didFinishLaunchingWithOptions:)hooks in this plugin are no-ops — share URLs never reach the Dart side.This PR teaches the plugin to participate in the new scene lifecycle.
What changed
SwiftFlutterSharingIntentPluginnow conforms toFlutterSceneLifeCycleDelegateand is registered viaregistrar.addSceneDelegate(instance)alongside the existingaddApplicationDelegate(instance)call, so the plugin keeps working under both lifecycles.scene(_:willConnectTo:options:)— captures the cold-launch share URL fromconnectionOptions.urlContexts/userActivitiesand primesinitialSharing.scene(_:openURLContexts:)— handles warm shares.scene(_:continue:)— handlesNSUserActivitycontinuations.Bool(truewhen the plugin consumed the URL) soFlutterSceneDelegateknows it doesn't need to forward the URL to the engine's deep-link channel.pubspec.yaml: bumped minimum Flutter to>=3.38.0and Dart SDK to>=3.10.0(required for theFlutterSceneLifeCycleDelegateprotocol).CHANGELOG.md: new2.1.0entry.README.md: short "UIScene lifecycle (Flutter 3.38+)" section under the iOS setup steps.Closes
Migration notes for host apps
The plugin handles share URLs natively under UIScene — no extra wiring needed for that. However, when an app adopts UIScene:
application(_:didFinishLaunchingWithOptions:)intodidInitializeImplicitFlutterEngine(_:)on aFlutterImplicitEngineDelegate-conformingAppDelegate.window.rootViewControlleris not available atdidFinishLaunchingtime anymore.application(_:open:)override that calledSwiftFlutterSharingIntentPlugin.instance.application(...), you can remove it — the newscene(_:openURLContexts:)does the equivalent.Testing
flutter test— 4/4 green). No Dart API surface changed.getInitialSharingreturns the file, share handler fires.getMediaStream.UIApplicationDelegatepath (verified by leavingaddApplicationDelegatein place).No new native test target was added —
UIScene,UISceneSession, andUIOpenURLContextcannot be constructed in XCTest, so the new scene callbacks are only manually verifiable.