Search code examples
iosiphonemessagetwo-factor-authenticationone-time-password

How to populate OTP from user's message box to application directly in iPhone?


I am working on an internet trading application with its mobile and iPhone applications available. With the recent market trend, we are working on including two-factor authentication. For that, we will be sending a one-time password as a sms on user's registered mobile number.

Is there a way,that the OTP can get automatically populated into application from user's message box in iPhone? What algorithm should I use to make my app read user's message box?

Thanks in advance:)


Solution

  • You can Access SMS from your app. So better make user to enter his contact number and send SMS to his mobile

    -(BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
    {
        if (!url) {
            UIApplication * yourapplication =[UIApplication sharedApplication];
            NSString *outputpath =@"appname://data/";
            NSURL *url =[NSURL URLWithString:outputpath];
            [yourapplication openURL:url];
            return NO;
        }
    
        NSUserDefaults *defaultString =[NSUserDefaults standardUserDefaults];
        NSString * commonString =[url absoluteString];
        if (commonString.length<=15) {
            //
        }
        else
        {
            [defaultString setObject:commonString forKey:@"urlString"];
        }
             //send info to the screen you need and can navigate
        return YES;
    }