forked from tradle/react-native-local-auth
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRNPasscodeStatus.m
More file actions
62 lines (52 loc) · 1.43 KB
/
RNPasscodeStatus.m
File metadata and controls
62 lines (52 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
//
// RNPasscodeStatus.m
// RNPasscodeStatus
//
// Created by Mark Vayngrib on 12/27/15.
// Copyright © 2015 Tradle, Inc. All rights reserved.
//
#import "RNPasscodeStatus.h"
#import "UIDevice+PasscodeStatus.h"
@implementation RNPasscodeStatus
RCT_EXPORT_MODULE()
RCT_EXPORT_METHOD(get:(RCTResponseSenderBlock)callback)
{
UIDevice *device = [UIDevice currentDevice];
if (!device.passcodeStatusSupported) {
callback(@[@"passcode status not supported"]);
} else {
NSString* status = [RNPasscodeStatus getPasscodeStatusString:device.passcodeStatus];
callback(@[[NSNull null], status]);
}
}
- (NSDictionary *)constantsToExport
{
UIDevice *device = [UIDevice currentDevice];
BOOL supported = device.passcodeStatusSupported;
NSMutableDictionary* constants = [[NSMutableDictionary alloc] initWithDictionary:@{
@"supported": @(supported)
}];
if (supported) {
NSString* status = [RNPasscodeStatus getPasscodeStatusString:device.passcodeStatus];
[constants setObject:status forKey:@"status"];
}
return [NSDictionary dictionaryWithDictionary:constants];
}
+ (NSString *) getPasscodeStatusString:(LNPasscodeStatus) status
{
switch (status) {
case LNPasscodeStatusDisabled:
return @"disabled";
case LNPasscodeStatusEnabled:
return @"enabled";
case LNPasscodeStatusUnknown:
return @"unknown";
default:
return nil;
}
}
+ (BOOL) requiresMainQueueSetup
{
return NO;
}
@end