Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions packages/local_auth/local_auth_darwin/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 2.0.2

* Improves compatibility with UIScene.
* Updates minimum supported SDK version to Flutter 3.38/Dart 3.10.

## 2.0.1

* Updates to Pigeon 26.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,13 @@ public final class LocalAuthPlugin: NSObject, FlutterPlugin, LocalAuthApi, @unch
public static func register(with registrar: FlutterPluginRegistrar) {
let instance = LocalAuthPlugin(
contextFactory: DefaultAuthContextFactory())
// Register for both application and scene delegates for backward compatibility.
// Apps using UIScene lifecycle will receive sceneDidBecomeActive,
// while apps not yet migrated will receive applicationDidBecomeActive.
registrar.addApplicationDelegate(instance)
#if os(iOS)
registrar.addSceneDelegate(instance)
#endif
// Workaround for https://github.com/flutter/flutter/issues/118103.
#if os(iOS)
let messenger = registrar.messenger()
Expand Down Expand Up @@ -249,18 +255,36 @@ public final class LocalAuthPlugin: NSObject, FlutterPlugin, LocalAuthApi, @unch
))
}

private func retryStickyAuth() {
if let lastCallState = self.lastCallState {
authenticate(
options: lastCallState.options,
strings: lastCallState.strings,
completion: lastCallState.resultHandler)
}
}

// MARK: App delegate

// This method is called when the app is resumed from the background only on iOS
// These methods are called when the app is resumed from the background only on iOS.
// Both are kept for backward compatibility: sceneDidBecomeActive for apps using UIScene lifecycle,
// and applicationDidBecomeActive for apps that haven't migrated yet.
#if os(iOS)
@MainActor
public func sceneDidBecomeActive(_ scene: UIScene) {
retryStickyAuth()
}

@MainActor
public func applicationDidBecomeActive(_ application: UIApplication) {
if let lastCallState = self.lastCallState {
authenticate(
options: lastCallState.options,
strings: lastCallState.strings,
completion: lastCallState.resultHandler)
}
retryStickyAuth()
}
#endif // os(iOS)

}

// MARK: - FlutterSceneLifeCycleDelegate

#if os(iOS)
extension LocalAuthPlugin: FlutterSceneLifeCycleDelegate {}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
#import <Flutter/Flutter.h>
#import <UIKit/UIKit.h>

@interface AppDelegate : FlutterAppDelegate
// FlutterImplicitEngineDelegate is required for UIScene lifecycle.
// It provides a callback (didInitializeImplicitFlutterEngine:) that fires
// after the Flutter engine is ready, which is when plugins should be registered.
@interface AppDelegate : FlutterAppDelegate <FlutterImplicitEngineDelegate>

@end
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@ @implementation AppDelegate

- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[GeneratedPluginRegistrant registerWithRegistry:self];
// Override point for customization after application launch.
return [super application:application didFinishLaunchingWithOptions:launchOptions];
}

- (void)didInitializeImplicitFlutterEngine:(NSObject<FlutterImplicitEngineBridge> *)engineBridge {
[GeneratedPluginRegistrant registerWithRegistry:engineBridge.pluginRegistry];
}

@end
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,26 @@
<true/>
<key>UIApplicationSupportsIndirectInputEvents</key>
<true/>
<key>UIApplicationSceneManifest</key>
<dict>
<key>UIApplicationSupportsMultipleScenes</key>
<false/>
<key>UISceneConfigurations</key>
<dict>
<key>UIWindowSceneSessionRoleApplication</key>
<array>
<dict>
<key>UISceneClassName</key>
<string>UIWindowScene</string>
<key>UISceneDelegateClassName</key>
<string>FlutterSceneDelegate</string>
<key>UISceneConfigurationName</key>
<string>flutter</string>
<key>UISceneStoryboardFile</key>
<string>Main</string>
</dict>
</array>
</dict>
</dict>
</dict>
</plist>
6 changes: 3 additions & 3 deletions packages/local_auth/local_auth_darwin/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ name: local_auth_darwin
description: iOS implementation of the local_auth plugin.
repository: https://github.com/flutter/packages/tree/main/packages/local_auth/local_auth_darwin
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+local_auth%22
version: 2.0.1
version: 2.0.2

environment:
sdk: ^3.9.0
flutter: ">=3.35.0"
sdk: ^3.10.0
flutter: ">=3.38.0"

flutter:
plugin:
Expand Down
Loading