Skip to content

feat(ios): Add UIScene life cycle support#378

Open
Gibbo97 wants to merge 1 commit intoDev-hwang:masterfrom
Gibbo97:UIScene-life-cycle-support
Open

feat(ios): Add UIScene life cycle support#378
Gibbo97 wants to merge 1 commit intoDev-hwang:masterfrom
Gibbo97:UIScene-life-cycle-support

Conversation

@Gibbo97
Copy link

@Gibbo97 Gibbo97 commented Mar 19, 2026

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, applicationDidEnterBackground is never called, which prevented background app refresh from being scheduled. This adds the necessary UIScene support per the Flutter plugin migration guide.

Changes:

  • SwiftFlutterForegroundTaskPlugin now conforms to FlutterSceneLifeCycleDelegate and registers itself via registrar.addSceneDelegate(instance) so it receives scene lifecycle callbacks
  • sceneDidEnterBackground(_:) added to schedule background app refresh in UIScene apps, mirroring what applicationDidEnterBackground does for non-UIScene apps — both coexist for backward compatibility
  • FlutterForegroundTaskEarlyRegistration +load added in the Obj-C layer to register the BGTaskScheduler handler at binary load time, before Flutter initialises — required for background launch scenarios where iOS wakes the app to service a refresh task
  • isBgTaskRegistered guard added to registerAppRefresh() to prevent a double-registration crash during the UIScene transition period, when host apps may invoke GeneratedPluginRegistrant.register(with:) from both the old and new template locations
  • Flutter minimum bumped from >=3.22.0 to >=3.38.0, the version that introduced addSceneDelegate

@Gibbo97
Copy link
Author

Gibbo97 commented Mar 19, 2026

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add UIScene life cycle support

1 participant