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

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-18 13:38:53

问题


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:)


回答1:


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;
}



回答2:


Straight Forward answer NO

It is not possible to read SMS programmatically as of now as applications in iOS are sandboxed, which means you can not read anything from user's phone outside of your application.




回答3:


You can not access to the users SMS inbox, this would be a real privacy issue.

What you can do is register your own app schema, with your app can be opened. The you can do something like myApp://register/<OTP>, you can then pick up this URL and take the OTP from the URL and use it. Just use the URL in your SMS and iOS will do the rest.

You can parse the app URL in - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation in your app delegate.



来源:https://stackoverflow.com/questions/20901801/how-to-populate-otp-from-users-message-box-to-application-directly-in-iphone

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!