繁体   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