簡體   English   中英

如何使用Twitter Digit Framework在iOS中使用OTP進行多用戶手機號碼身份驗證?

[英]How to make multiple user mobile number authentication using OTP in iOS using Twitter Digit Framework?

大家好,我正在使用我正在用戶會話應用程序中的應用程序中使用Objective-C,Parse和Twitters-Digits框架,這將允許采用一個用戶ID進行單個手機號碼驗證...我正在將其保存到Parse當前用戶的User Class中詳細信息。 當我使用帳戶登錄時,應用程序將允許我使用OTP進行移動驗證,但是當我注銷並使用另一個帳戶登錄時,應用程序將使用我存儲在iPhone鑰匙串中的現有用戶ID(移動電話號碼),當我登錄時如何處理情況有多個帳戶以采取多種條件,我的代碼如下:

- (void)verifyPhone:(id)sender {

    [[Digits sharedInstance] authenticateWithCompletion:^(DGTSession *session, NSError *error) {
        // Inspect session/error objects

        if (session.userID) {
            // TODO: associate the session userID with your user model

            PFUser *user = [PFUser currentUser];
            [user setObject:[NSNumber numberWithBool:YES] forKey:@"mobileverify"];
            [user saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
                if (succeeded) {


                    NSString *msg = [NSString stringWithFormat:@"Phone number: %@", session.phoneNumber];

                    UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"You are logged in!" message:msg preferredStyle:UIAlertControllerStyleAlert];

                    UIAlertAction *okAction = [UIAlertAction
                                               actionWithTitle:NSLocalizedString(@"OK", @"OK action")
                                               style:UIAlertActionStyleDefault
                                               handler:^(UIAlertAction *action)
                                               {
                                                   NSLog(@"Mobile Verification Status Saved Sucessfully.");

                                                   [verifyPhoneButton setTitle:@"Phone Verified" forState:UIControlStateNormal];
                                                   [verifyPhoneButton setEnabled:NO];
                                                   [verifyPhoneButton setTintColor:[UIColor blackColor]];

                                               }];

                    [alertController addAction:okAction];
                    [self presentViewController:alertController animated:YES completion:nil];


                }
                else {

                    NSLog(@"Error ==%@", error);
                }
            }];


        } else if (error) {

            NSLog(@"Authentication error: %@", error.localizedDescription);
        }


    }];    
}

我從蘋果文檔獲得了Twitter-Digits框架的解決方案

https://docs.fabric.io/appledocs/Digits/Classes/Digits.html

我只需要在注銷時通過以下行結束會話:

[[Digits sharedInstance] logOut];

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM