Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[local_auth] Migrate iOS to Pigeon #3974

Merged
merged 15 commits into from
May 19, 2023
Merged
Show file tree
Hide file tree
Changes from 9 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
3 changes: 2 additions & 1 deletion packages/local_auth/local_auth_ios/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## NEXT
## 1.1.3

* Migrates internal implementation to Pigeon.
* Updates minimum supported SDK version to Flutter 3.3/Dart 2.18.

## 1.1.2
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@

#import <Flutter/Flutter.h>

@interface FLTLocalAuthPlugin : NSObject <FlutterPlugin>
#import "messages.g.h"

@interface FLTLocalAuthPlugin : NSObject <FlutterPlugin, FLALocalAuthApi>
@end
293 changes: 150 additions & 143 deletions packages/local_auth/local_auth_ios/ios/Classes/FLTLocalAuthPlugin.m

Large diffs are not rendered by default.

123 changes: 123 additions & 0 deletions packages/local_auth/local_auth_ios/ios/Classes/messages.g.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Autogenerated from Pigeon (v9.2.5), do not edit directly.
// See also: https://pub.dev/packages/pigeon

#import <Foundation/Foundation.h>

@protocol FlutterBinaryMessenger;
@protocol FlutterMessageCodec;
@class FlutterError;
@class FlutterStandardTypedData;

NS_ASSUME_NONNULL_BEGIN

/// Possible outcomes of an authentication attempt.
typedef NS_ENUM(NSUInteger, FLAAuthResult) {
/// The user authenticated successfully.
FLAAuthResultSuccess = 0,
/// The user failed to successfully authenticate.
FLAAuthResultFailure = 1,
/// The authentication system was not available.
FLAAuthResultErrorNotAvailable = 2,
/// No biometrics are enrolled.
FLAAuthResultErrorNotEnrolled = 3,
/// No passcode is set.
FLAAuthResultErrorPasscodeNotSet = 4,
};

/// Pigeon equivalent of the subset of BiometricType used by iOS.
typedef NS_ENUM(NSUInteger, FLAAuthBiometric) {
stuartmorgan marked this conversation as resolved.
Show resolved Hide resolved
FLAAuthBiometricFace = 0,
FLAAuthBiometricFingerprint = 1,
};

@class FLAAuthStrings;
@class FLAAuthOptions;
@class FLAAuthResultDetails;
@class FLAAuthBiometricWrapper;

/// Pigeon version of IOSAuthMessages, plus the authorization reason.
///
/// See auth_messages_ios.dart for details.
@interface FLAAuthStrings : NSObject
/// `init` unavailable to enforce nonnull fields, see the `make` class method.
- (instancetype)init NS_UNAVAILABLE;
+ (instancetype)makeWithReason:(NSString *)reason
lockOut:(NSString *)lockOut
goToSettingsButton:(NSString *)goToSettingsButton
goToSettingsDescription:(NSString *)goToSettingsDescription
cancelButton:(NSString *)cancelButton
localizedFallbackTitle:(nullable NSString *)localizedFallbackTitle;
@property(nonatomic, copy) NSString *reason;
@property(nonatomic, copy) NSString *lockOut;
@property(nonatomic, copy) NSString *goToSettingsButton;
@property(nonatomic, copy) NSString *goToSettingsDescription;
@property(nonatomic, copy) NSString *cancelButton;
@property(nonatomic, copy, nullable) NSString *localizedFallbackTitle;
@end

@interface FLAAuthOptions : NSObject
/// `init` unavailable to enforce nonnull fields, see the `make` class method.
- (instancetype)init NS_UNAVAILABLE;
+ (instancetype)makeWithBiometricOnly:(NSNumber *)biometricOnly
sticky:(NSNumber *)sticky
useErrorDialgs:(NSNumber *)useErrorDialgs;
@property(nonatomic, strong) NSNumber *biometricOnly;
@property(nonatomic, strong) NSNumber *sticky;
@property(nonatomic, strong) NSNumber *useErrorDialgs;
@end

@interface FLAAuthResultDetails : NSObject
/// `init` unavailable to enforce nonnull fields, see the `make` class method.
- (instancetype)init NS_UNAVAILABLE;
+ (instancetype)makeWithValue:(FLAAuthResult)value
errorMessage:(nullable NSString *)errorMessage
errorDetails:(nullable NSString *)errorDetails;
/// The result of authenticating.
@property(nonatomic, assign) FLAAuthResult value;
/// A system-provided error message, if any.
@property(nonatomic, copy, nullable) NSString *errorMessage;
/// System-provided error details, if any.
@property(nonatomic, copy, nullable) NSString *errorDetails;
@end

@interface FLAAuthBiometricWrapper : NSObject
/// `init` unavailable to enforce nonnull fields, see the `make` class method.
- (instancetype)init NS_UNAVAILABLE;
+ (instancetype)makeWithValue:(FLAAuthBiometric)value;
@property(nonatomic, assign) FLAAuthBiometric value;
@end

/// The codec used by FLALocalAuthApi.
NSObject<FlutterMessageCodec> *FLALocalAuthApiGetCodec(void);

@protocol FLALocalAuthApi
/// Returns true if this device supports authentication.
///
/// @return `nil` only when `error != nil`.
- (nullable NSNumber *)isDeviceSupportedWithError:(FlutterError *_Nullable *_Nonnull)error;
/// Returns true if this device can support biometric authentication, whether
/// any biometrics are enrolled or not.
///
/// @return `nil` only when `error != nil`.
- (nullable NSNumber *)deviceCanSupportBiometricsWithError:(FlutterError *_Nullable *_Nonnull)error;
/// Returns the biometric types that are enrolled, and can thus be used
/// without additional setup.
///
/// @return `nil` only when `error != nil`.
- (nullable NSArray<FLAAuthBiometricWrapper *> *)getEnrolledBiometricsWithError:
(FlutterError *_Nullable *_Nonnull)error;
/// Attempts to authenticate the user with the provided [options], and using
/// [strings] for any UI.
- (void)authenticateWithOptions:(FLAAuthOptions *)options
strings:(FLAAuthStrings *)strings
completion:(void (^)(FLAAuthResultDetails *_Nullable,
FlutterError *_Nullable))completion;
@end

extern void FLALocalAuthApiSetup(id<FlutterBinaryMessenger> binaryMessenger,
NSObject<FLALocalAuthApi> *_Nullable api);

NS_ASSUME_NONNULL_END
Loading