

iOSでau WALLETというアプリに、Touch IDを利用する認証画面があります。  
そこで直接パスコードを入力してロックを解除することもできます。

ここでTouch IDから出す「パスコード直接入力ビュー」とはカスタマイズで実装したものですか？  
iPhoneのシステムロック画面ですか？

ネットで色々調べましたがシステムのロック画面を呼び出す方法はなさそうです。

＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝  
テスト用で実装したソースを共有致します。  
参照：  
[参照1]<https://developer.apple.com/library/ios/samplecode/KeychainTouchID/Introduction/Intro.html>  
[参照2]<https://www.secsign.com/fingerprint-validation-as-an-alternative-to-
passcodes/>

[code]

    // show the authentication UI with our reason string
    LAContext *context = [[LAContext alloc] init];
    __block  NSString *msg;
    
    [context evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics localizedReason:NSLocalizedString(@"UNLOCK_ACCESS_TO_LOCKED_FATURE", nil) reply:
     ^(BOOL success, NSError *authenticationError) {
         if (success) {
             msg =[NSString stringWithFormat:NSLocalizedString(@"EVALUATE_POLICY_SUCCESS", nil)];
         } else {
             msg = [NSString stringWithFormat:NSLocalizedString(@"EVALUATE_POLICY_WITH_ERROR", nil), authenticationError.localizedDescription];
    
             if (authenticationError.code == LAErrorUserFallback) {
    
                 // The identifier and service name together will uniquely identify the keychain entry.
                 NSString * keychainItemIdentifier = @"fingerprintKeychainEntry";
                 NSString * keychainItemServiceName = @"com.secsign.secsign";
    
                 // Determine a string which the device will display in the fingerprint view explaining the reason for the fingerprint scan.
                 NSString * secUseOperationPrompt = @"Authenticate for server login";
    
                 // The keychain operation shall be performed by the global queue. Otherwise it might just nothing happen.
                 dispatch_async(dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^(void) {
    
                     // Create the keychain query attributes using the values from the first part of the code.
                     NSMutableDictionary * query = [[NSMutableDictionary alloc] initWithObjectsAndKeys:
                                                    (__bridge id)(kSecClassGenericPassword), kSecClass,
                                                    keychainItemIdentifier, kSecAttrAccount,
                                                    keychainItemServiceName, kSecAttrService,
                                                    secUseOperationPrompt, kSecUseOperationPrompt,
                                                    nil];
    
                     // Start the query and the fingerprint scan and/or device passcode validation
                     CFTypeRef result = nil;
                     OSStatus userPresenceStatus = SecItemCopyMatching((__bridge CFDictionaryRef)query, &result);
    
                     // Ignore the found content of the key chain entry (the dummy password) and only evaluate the return code.
                     if (noErr == userPresenceStatus)
                     {
                         NSLog(@"Fingerprint or device passcode validated.");
                     }
                     else
                     {
                         NSLog(@"Fingerprint or device passcode could not be validated. Status %d.", (int) userPresenceStatus);
                     }
    
                     // To process the result at this point there would be a call to delegate method which 
                     // would do its work like GUI operations in the main queue. That means it would start
                     // with something like:
                     //   dispatch_async(dispatch_get_main_queue(), ^{
                 });
             }
         }
         [self printResult:self.textView message:msg];
     }];
    
[/code]


CC BY-SA 3.0
2015-01-09T01:39:12.977
4317
2015-01-09T14:55:19.477
2015-01-09T14:55:19.477
724
5853
question
ios objective-c
au WALLETのように、Touch IDダイアログからパスコード入力画面に移れるようにするには


ロック画面を表示するのではなく、以下のように、[LocalAuthentication](https://developer.apple.com/library/prerelease/ios/documentation/LocalAuthentication/Reference/LocalAuthentication_Framework/index.html)
Frameworkを使います。

例はUIButtonをStoryBoardにおいた時の実装で、不必要な部分は省いてあります。

[code]

    @import LocalAuthentication;
    @implementation ViewController
    
    - (IBAction)buttonTouchUpInside:(id)sender {
      LAContext *context = [LAContext new];
      NSError *error;
      if([context canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error: &error]) {
        [context evaluatePolicy: LAPolicyDeviceOwnerAuthenticationWithBiometrics
            localizedReason:@"指紋認証"
                  reply:^(BOOL success, NSError *error){
                    if (success) {
                      NSLog(@"Success");
                    } else {
                      NSLog(@"An Auth Error Occurred: %@", error);
                    }
                  }];
      } else {
        NSLog(@"An Error Occurred: %@", error);
      }
    }
    
[/code]

localizedReasonに設定した文字列が、指紋認証画面に表示されます。

なお、シミュレータでは動作確認できませんので、実機に転送して試してください。


CC BY-SA 3.0
2015-01-09T03:26:57.203
4319
2015-01-09T03:26:57.203
351
4317
answer