feat(ios): Add UIScene life cycle support#378
Open
Gibbo97 wants to merge 1 commit intoDev-hwang:masterfrom
Open
feat(ios): Add UIScene life cycle support#378Gibbo97 wants to merge 1 commit intoDev-hwang:masterfrom
Gibbo97 wants to merge 1 commit intoDev-hwang:masterfrom
Conversation
Author
|
In addition, after moving to use the new flutter version this library is causing crashes when the app tries to start in the background. Ie when we have scheduled runs with workmanager, or when we try to share content into our app. These changes resolve all this |
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.
feat(ios): Add UIScene lifecycle support
Closes #376.
Apple requires all UIKit apps built with the latest SDK to adopt UIScene lifecycle. In UIScene apps,
applicationDidEnterBackgroundis never called, which prevented background app refresh from being scheduled. This adds the necessary UIScene support per the Flutter plugin migration guide.Changes:
SwiftFlutterForegroundTaskPluginnow conforms toFlutterSceneLifeCycleDelegateand registers itself viaregistrar.addSceneDelegate(instance)so it receives scene lifecycle callbackssceneDidEnterBackground(_:)added to schedule background app refresh in UIScene apps, mirroring whatapplicationDidEnterBackgrounddoes for non-UIScene apps — both coexist for backward compatibilityFlutterForegroundTaskEarlyRegistration +loadadded in the Obj-C layer to register theBGTaskSchedulerhandler at binary load time, before Flutter initialises — required for background launch scenarios where iOS wakes the app to service a refresh taskisBgTaskRegisteredguard added toregisterAppRefresh()to prevent a double-registration crash during the UIScene transition period, when host apps may invokeGeneratedPluginRegistrant.register(with:)from both the old and new template locations>=3.22.0to>=3.38.0, the version that introducedaddSceneDelegate