Skip to content

Commit e780cb8

Browse files
[local_auth] Update iOS to Pigeon 13 (#5269)
Picks up several breaking changes, including the switch to unwrapped BOOL properties.
1 parent 6ad40b9 commit e780cb8

File tree

7 files changed

+124
-76
lines changed

7 files changed

+124
-76
lines changed

packages/local_auth/local_auth_ios/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 1.1.5
2+
3+
* Updates to Pigeon 13.
4+
15
## 1.1.4
26

37
* Adds pub topics to package metadata.

packages/local_auth/local_auth_ios/example/ios/RunnerTests/FLTLocalAuthPluginTests.m

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@ - (void)testSuccessfullAuthWithBiometrics {
7373
.andDo(backgroundThreadReplyCaller);
7474

7575
XCTestExpectation *expectation = [self expectationWithDescription:@"Result is called"];
76-
[plugin authenticateWithOptions:[FLAAuthOptions makeWithBiometricOnly:@YES
77-
sticky:@NO
78-
useErrorDialogs:@NO]
76+
[plugin authenticateWithOptions:[FLAAuthOptions makeWithBiometricOnly:YES
77+
sticky:NO
78+
useErrorDialogs:NO]
7979
strings:strings
8080
completion:^(FLAAuthResultDetails *_Nullable resultDetails,
8181
FlutterError *_Nullable error) {
@@ -111,9 +111,9 @@ - (void)testSuccessfullAuthWithoutBiometrics {
111111
.andDo(backgroundThreadReplyCaller);
112112

113113
XCTestExpectation *expectation = [self expectationWithDescription:@"Result is called"];
114-
[plugin authenticateWithOptions:[FLAAuthOptions makeWithBiometricOnly:@NO
115-
sticky:@NO
116-
useErrorDialogs:@NO]
114+
[plugin authenticateWithOptions:[FLAAuthOptions makeWithBiometricOnly:NO
115+
sticky:NO
116+
useErrorDialogs:NO]
117117
strings:strings
118118
completion:^(FLAAuthResultDetails *_Nullable resultDetails,
119119
FlutterError *_Nullable error) {
@@ -149,9 +149,9 @@ - (void)testFailedAuthWithBiometrics {
149149
.andDo(backgroundThreadReplyCaller);
150150

151151
XCTestExpectation *expectation = [self expectationWithDescription:@"Result is called"];
152-
[plugin authenticateWithOptions:[FLAAuthOptions makeWithBiometricOnly:@YES
153-
sticky:@NO
154-
useErrorDialogs:@NO]
152+
[plugin authenticateWithOptions:[FLAAuthOptions makeWithBiometricOnly:YES
153+
sticky:NO
154+
useErrorDialogs:NO]
155155
strings:strings
156156
completion:^(FLAAuthResultDetails *_Nullable resultDetails,
157157
FlutterError *_Nullable error) {
@@ -191,9 +191,9 @@ - (void)testFailedWithUnknownErrorCode {
191191
.andDo(backgroundThreadReplyCaller);
192192

193193
XCTestExpectation *expectation = [self expectationWithDescription:@"Result is called"];
194-
[plugin authenticateWithOptions:[FLAAuthOptions makeWithBiometricOnly:@NO
195-
sticky:@NO
196-
useErrorDialogs:@NO]
194+
[plugin authenticateWithOptions:[FLAAuthOptions makeWithBiometricOnly:NO
195+
sticky:NO
196+
useErrorDialogs:NO]
197197
strings:strings
198198
completion:^(FLAAuthResultDetails *_Nullable resultDetails,
199199
FlutterError *_Nullable error) {
@@ -229,9 +229,9 @@ - (void)testSystemCancelledWithoutStickyAuth {
229229
.andDo(backgroundThreadReplyCaller);
230230

231231
XCTestExpectation *expectation = [self expectationWithDescription:@"Result is called"];
232-
[plugin authenticateWithOptions:[FLAAuthOptions makeWithBiometricOnly:@NO
233-
sticky:@NO
234-
useErrorDialogs:@NO]
232+
[plugin authenticateWithOptions:[FLAAuthOptions makeWithBiometricOnly:NO
233+
sticky:NO
234+
useErrorDialogs:NO]
235235
strings:strings
236236
completion:^(FLAAuthResultDetails *_Nullable resultDetails,
237237
FlutterError *_Nullable error) {
@@ -267,9 +267,9 @@ - (void)testFailedAuthWithoutBiometrics {
267267
.andDo(backgroundThreadReplyCaller);
268268

269269
XCTestExpectation *expectation = [self expectationWithDescription:@"Result is called"];
270-
[plugin authenticateWithOptions:[FLAAuthOptions makeWithBiometricOnly:@NO
271-
sticky:@NO
272-
useErrorDialogs:@NO]
270+
[plugin authenticateWithOptions:[FLAAuthOptions makeWithBiometricOnly:NO
271+
sticky:NO
272+
useErrorDialogs:NO]
273273
strings:strings
274274
completion:^(FLAAuthResultDetails *_Nullable resultDetails,
275275
FlutterError *_Nullable error) {
@@ -310,9 +310,9 @@ - (void)testLocalizedFallbackTitle {
310310
.andDo(backgroundThreadReplyCaller);
311311

312312
XCTestExpectation *expectation = [self expectationWithDescription:@"Result is called"];
313-
[plugin authenticateWithOptions:[FLAAuthOptions makeWithBiometricOnly:@NO
314-
sticky:@NO
315-
useErrorDialogs:@NO]
313+
[plugin authenticateWithOptions:[FLAAuthOptions makeWithBiometricOnly:NO
314+
sticky:NO
315+
useErrorDialogs:NO]
316316
strings:strings
317317
completion:^(FLAAuthResultDetails *_Nullable resultDetails,
318318
FlutterError *_Nullable error) {
@@ -348,9 +348,9 @@ - (void)testSkippedLocalizedFallbackTitle {
348348
.andDo(backgroundThreadReplyCaller);
349349

350350
XCTestExpectation *expectation = [self expectationWithDescription:@"Result is called"];
351-
[plugin authenticateWithOptions:[FLAAuthOptions makeWithBiometricOnly:@NO
352-
sticky:@NO
353-
useErrorDialogs:@NO]
351+
[plugin authenticateWithOptions:[FLAAuthOptions makeWithBiometricOnly:NO
352+
sticky:NO
353+
useErrorDialogs:NO]
354354
strings:strings
355355
completion:^(FLAAuthResultDetails *_Nullable resultDetails,
356356
FlutterError *_Nullable error) {

packages/local_auth/local_auth_ios/ios/Classes/FLTLocalAuthPlugin.m

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ @implementation FLTLocalAuthPlugin
6060
+ (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar> *)registrar {
6161
FLTLocalAuthPlugin *instance = [[FLTLocalAuthPlugin alloc] init];
6262
[registrar addApplicationDelegate:instance];
63-
FLALocalAuthApiSetup([registrar messenger], instance);
63+
SetUpFLALocalAuthApi([registrar messenger], instance);
6464
}
6565

6666
- (instancetype)init {
@@ -86,9 +86,8 @@ - (void)authenticateWithOptions:(nonnull FLAAuthOptions *)options
8686
self.lastCallState = nil;
8787
context.localizedFallbackTitle = strings.localizedFallbackTitle;
8888

89-
LAPolicy policy = options.biometricOnly.boolValue
90-
? LAPolicyDeviceOwnerAuthenticationWithBiometrics
91-
: LAPolicyDeviceOwnerAuthentication;
89+
LAPolicy policy = options.biometricOnly ? LAPolicyDeviceOwnerAuthenticationWithBiometrics
90+
: LAPolicyDeviceOwnerAuthentication;
9291
if ([context canEvaluatePolicy:policy error:&authError]) {
9392
[context evaluatePolicy:policy
9493
localizedReason:strings.reason
@@ -208,7 +207,7 @@ - (void)handleAuthReplyWithSuccess:(BOOL)success
208207
[self handleError:error withOptions:options strings:strings completion:completion];
209208
return;
210209
case LAErrorSystemCancel:
211-
if ([options.sticky boolValue]) {
210+
if (options.sticky) {
212211
_lastCallState = [[FLAStickyAuthState alloc] initWithOptions:options
213212
strings:strings
214213
resultHandler:completion];
@@ -237,7 +236,7 @@ - (void)handleError:(NSError *)authError
237236
switch (authError.code) {
238237
case LAErrorPasscodeNotSet:
239238
case LAErrorBiometryNotEnrolled:
240-
if (options.useErrorDialogs.boolValue) {
239+
if (options.useErrorDialogs) {
241240
[self showAlertWithMessage:strings.goToSettingsDescription
242241
dismissButtonTitle:strings.cancelButton
243242
openSettingsButtonTitle:strings.goToSettingsButton

packages/local_auth/local_auth_ios/ios/Classes/messages.g.h

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright 2013 The Flutter Authors. All rights reserved.
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
4-
// Autogenerated from Pigeon (v9.2.5), do not edit directly.
4+
// Autogenerated from Pigeon (v13.0.0), do not edit directly.
55
// See also: https://pub.dev/packages/pigeon
66

77
#import <Foundation/Foundation.h>
@@ -27,12 +27,24 @@ typedef NS_ENUM(NSUInteger, FLAAuthResult) {
2727
FLAAuthResultErrorPasscodeNotSet = 4,
2828
};
2929

30+
/// Wrapper for FLAAuthResult to allow for nullability.
31+
@interface FLAAuthResultBox : NSObject
32+
@property(nonatomic, assign) FLAAuthResult value;
33+
- (instancetype)initWithValue:(FLAAuthResult)value;
34+
@end
35+
3036
/// Pigeon equivalent of the subset of BiometricType used by iOS.
3137
typedef NS_ENUM(NSUInteger, FLAAuthBiometric) {
3238
FLAAuthBiometricFace = 0,
3339
FLAAuthBiometricFingerprint = 1,
3440
};
3541

42+
/// Wrapper for FLAAuthBiometric to allow for nullability.
43+
@interface FLAAuthBiometricBox : NSObject
44+
@property(nonatomic, assign) FLAAuthBiometric value;
45+
- (instancetype)initWithValue:(FLAAuthBiometric)value;
46+
@end
47+
3648
@class FLAAuthStrings;
3749
@class FLAAuthOptions;
3850
@class FLAAuthResultDetails;
@@ -61,12 +73,12 @@ typedef NS_ENUM(NSUInteger, FLAAuthBiometric) {
6173
@interface FLAAuthOptions : NSObject
6274
/// `init` unavailable to enforce nonnull fields, see the `make` class method.
6375
- (instancetype)init NS_UNAVAILABLE;
64-
+ (instancetype)makeWithBiometricOnly:(NSNumber *)biometricOnly
65-
sticky:(NSNumber *)sticky
66-
useErrorDialogs:(NSNumber *)useErrorDialogs;
67-
@property(nonatomic, strong) NSNumber *biometricOnly;
68-
@property(nonatomic, strong) NSNumber *sticky;
69-
@property(nonatomic, strong) NSNumber *useErrorDialogs;
76+
+ (instancetype)makeWithBiometricOnly:(BOOL)biometricOnly
77+
sticky:(BOOL)sticky
78+
useErrorDialogs:(BOOL)useErrorDialogs;
79+
@property(nonatomic, assign) BOOL biometricOnly;
80+
@property(nonatomic, assign) BOOL sticky;
81+
@property(nonatomic, assign) BOOL useErrorDialogs;
7082
@end
7183

7284
@interface FLAAuthResultDetails : NSObject
@@ -117,7 +129,7 @@ NSObject<FlutterMessageCodec> *FLALocalAuthApiGetCodec(void);
117129
FlutterError *_Nullable))completion;
118130
@end
119131

120-
extern void FLALocalAuthApiSetup(id<FlutterBinaryMessenger> binaryMessenger,
132+
extern void SetUpFLALocalAuthApi(id<FlutterBinaryMessenger> binaryMessenger,
121133
NSObject<FLALocalAuthApi> *_Nullable api);
122134

123135
NS_ASSUME_NONNULL_END

packages/local_auth/local_auth_ios/ios/Classes/messages.g.m

Lines changed: 50 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,43 @@
11
// Copyright 2013 The Flutter Authors. All rights reserved.
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
4-
// Autogenerated from Pigeon (v9.2.5), do not edit directly.
4+
// Autogenerated from Pigeon (v13.0.0), do not edit directly.
55
// See also: https://pub.dev/packages/pigeon
66

77
#import "messages.g.h"
8+
9+
#if TARGET_OS_OSX
10+
#import <FlutterMacOS/FlutterMacOS.h>
11+
#else
812
#import <Flutter/Flutter.h>
13+
#endif
914

1015
#if !__has_feature(objc_arc)
1116
#error File requires ARC to be enabled.
1217
#endif
1318

19+
/// Possible outcomes of an authentication attempt.
20+
@implementation FLAAuthResultBox
21+
- (instancetype)initWithValue:(FLAAuthResult)value {
22+
self = [super init];
23+
if (self) {
24+
_value = value;
25+
}
26+
return self;
27+
}
28+
@end
29+
30+
/// Pigeon equivalent of the subset of BiometricType used by iOS.
31+
@implementation FLAAuthBiometricBox
32+
- (instancetype)initWithValue:(FLAAuthBiometric)value {
33+
self = [super init];
34+
if (self) {
35+
_value = value;
36+
}
37+
return self;
38+
}
39+
@end
40+
1441
static NSArray *wrapResult(id result, FlutterError *error) {
1542
if (error) {
1643
return @[
@@ -67,15 +94,10 @@ + (instancetype)makeWithReason:(NSString *)reason
6794
+ (FLAAuthStrings *)fromList:(NSArray *)list {
6895
FLAAuthStrings *pigeonResult = [[FLAAuthStrings alloc] init];
6996
pigeonResult.reason = GetNullableObjectAtIndex(list, 0);
70-
NSAssert(pigeonResult.reason != nil, @"");
7197
pigeonResult.lockOut = GetNullableObjectAtIndex(list, 1);
72-
NSAssert(pigeonResult.lockOut != nil, @"");
7398
pigeonResult.goToSettingsButton = GetNullableObjectAtIndex(list, 2);
74-
NSAssert(pigeonResult.goToSettingsButton != nil, @"");
7599
pigeonResult.goToSettingsDescription = GetNullableObjectAtIndex(list, 3);
76-
NSAssert(pigeonResult.goToSettingsDescription != nil, @"");
77100
pigeonResult.cancelButton = GetNullableObjectAtIndex(list, 4);
78-
NSAssert(pigeonResult.cancelButton != nil, @"");
79101
pigeonResult.localizedFallbackTitle = GetNullableObjectAtIndex(list, 5);
80102
return pigeonResult;
81103
}
@@ -84,20 +106,20 @@ + (nullable FLAAuthStrings *)nullableFromList:(NSArray *)list {
84106
}
85107
- (NSArray *)toList {
86108
return @[
87-
(self.reason ?: [NSNull null]),
88-
(self.lockOut ?: [NSNull null]),
89-
(self.goToSettingsButton ?: [NSNull null]),
90-
(self.goToSettingsDescription ?: [NSNull null]),
91-
(self.cancelButton ?: [NSNull null]),
92-
(self.localizedFallbackTitle ?: [NSNull null]),
109+
self.reason ?: [NSNull null],
110+
self.lockOut ?: [NSNull null],
111+
self.goToSettingsButton ?: [NSNull null],
112+
self.goToSettingsDescription ?: [NSNull null],
113+
self.cancelButton ?: [NSNull null],
114+
self.localizedFallbackTitle ?: [NSNull null],
93115
];
94116
}
95117
@end
96118

97119
@implementation FLAAuthOptions
98-
+ (instancetype)makeWithBiometricOnly:(NSNumber *)biometricOnly
99-
sticky:(NSNumber *)sticky
100-
useErrorDialogs:(NSNumber *)useErrorDialogs {
120+
+ (instancetype)makeWithBiometricOnly:(BOOL)biometricOnly
121+
sticky:(BOOL)sticky
122+
useErrorDialogs:(BOOL)useErrorDialogs {
101123
FLAAuthOptions *pigeonResult = [[FLAAuthOptions alloc] init];
102124
pigeonResult.biometricOnly = biometricOnly;
103125
pigeonResult.sticky = sticky;
@@ -106,22 +128,19 @@ + (instancetype)makeWithBiometricOnly:(NSNumber *)biometricOnly
106128
}
107129
+ (FLAAuthOptions *)fromList:(NSArray *)list {
108130
FLAAuthOptions *pigeonResult = [[FLAAuthOptions alloc] init];
109-
pigeonResult.biometricOnly = GetNullableObjectAtIndex(list, 0);
110-
NSAssert(pigeonResult.biometricOnly != nil, @"");
111-
pigeonResult.sticky = GetNullableObjectAtIndex(list, 1);
112-
NSAssert(pigeonResult.sticky != nil, @"");
113-
pigeonResult.useErrorDialogs = GetNullableObjectAtIndex(list, 2);
114-
NSAssert(pigeonResult.useErrorDialogs != nil, @"");
131+
pigeonResult.biometricOnly = [GetNullableObjectAtIndex(list, 0) boolValue];
132+
pigeonResult.sticky = [GetNullableObjectAtIndex(list, 1) boolValue];
133+
pigeonResult.useErrorDialogs = [GetNullableObjectAtIndex(list, 2) boolValue];
115134
return pigeonResult;
116135
}
117136
+ (nullable FLAAuthOptions *)nullableFromList:(NSArray *)list {
118137
return (list) ? [FLAAuthOptions fromList:list] : nil;
119138
}
120139
- (NSArray *)toList {
121140
return @[
122-
(self.biometricOnly ?: [NSNull null]),
123-
(self.sticky ?: [NSNull null]),
124-
(self.useErrorDialogs ?: [NSNull null]),
141+
@(self.biometricOnly),
142+
@(self.sticky),
143+
@(self.useErrorDialogs),
125144
];
126145
}
127146
@end
@@ -149,8 +168,8 @@ + (nullable FLAAuthResultDetails *)nullableFromList:(NSArray *)list {
149168
- (NSArray *)toList {
150169
return @[
151170
@(self.result),
152-
(self.errorMessage ?: [NSNull null]),
153-
(self.errorDetails ?: [NSNull null]),
171+
self.errorMessage ?: [NSNull null],
172+
self.errorDetails ?: [NSNull null],
154173
];
155174
}
156175
@end
@@ -239,12 +258,12 @@ - (FlutterStandardReader *)readerWithData:(NSData *)data {
239258
return sSharedObject;
240259
}
241260

242-
void FLALocalAuthApiSetup(id<FlutterBinaryMessenger> binaryMessenger,
261+
void SetUpFLALocalAuthApi(id<FlutterBinaryMessenger> binaryMessenger,
243262
NSObject<FLALocalAuthApi> *api) {
244263
/// Returns true if this device supports authentication.
245264
{
246265
FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc]
247-
initWithName:@"dev.flutter.pigeon.LocalAuthApi.isDeviceSupported"
266+
initWithName:@"dev.flutter.pigeon.local_auth_ios.LocalAuthApi.isDeviceSupported"
248267
binaryMessenger:binaryMessenger
249268
codec:FLALocalAuthApiGetCodec()];
250269
if (api) {
@@ -265,7 +284,7 @@ void FLALocalAuthApiSetup(id<FlutterBinaryMessenger> binaryMessenger,
265284
/// any biometrics are enrolled or not.
266285
{
267286
FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc]
268-
initWithName:@"dev.flutter.pigeon.LocalAuthApi.deviceCanSupportBiometrics"
287+
initWithName:@"dev.flutter.pigeon.local_auth_ios.LocalAuthApi.deviceCanSupportBiometrics"
269288
binaryMessenger:binaryMessenger
270289
codec:FLALocalAuthApiGetCodec()];
271290
if (api) {
@@ -286,7 +305,7 @@ void FLALocalAuthApiSetup(id<FlutterBinaryMessenger> binaryMessenger,
286305
/// without additional setup.
287306
{
288307
FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc]
289-
initWithName:@"dev.flutter.pigeon.LocalAuthApi.getEnrolledBiometrics"
308+
initWithName:@"dev.flutter.pigeon.local_auth_ios.LocalAuthApi.getEnrolledBiometrics"
290309
binaryMessenger:binaryMessenger
291310
codec:FLALocalAuthApiGetCodec()];
292311
if (api) {
@@ -307,7 +326,7 @@ void FLALocalAuthApiSetup(id<FlutterBinaryMessenger> binaryMessenger,
307326
/// [strings] for any UI.
308327
{
309328
FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc]
310-
initWithName:@"dev.flutter.pigeon.LocalAuthApi.authenticate"
329+
initWithName:@"dev.flutter.pigeon.local_auth_ios.LocalAuthApi.authenticate"
311330
binaryMessenger:binaryMessenger
312331
codec:FLALocalAuthApiGetCodec()];
313332
if (api) {

0 commit comments

Comments
 (0)