简体   繁体   English

如何将 Infobip 短信网关集成到我的项目中以及如何在 iOS Swift 中实现两因素身份验证

[英]How to integrate Infobip sms gateway into my project and how to implement two factor authentication in iOS Swift

Here I have the doubt about how to integrate the Infobip SMS gateway into iOS Swift project.在这里我对如何将Infobip SMS网关集成到iOS Swift项目中存在疑问。 I am new in iOS Swift, so I have no clarity in this concept.我是 iOS Swift 的新手,所以我不清楚这个概念。

How to check the condition to receive the SMS for the registered mobile number in app like Whatsapp.如何在应用程序(如 Whatsapp)中检查接收已注册手机号码的短信的条件。 Here I give what I am tried in my project.在这里,我给出了我在项目中尝试过的内容。

var post:NSString = "username=\(self.appDelegate.username)&password=\(self.appDelegate.password)&gsm=\(self.appDelegate.gsm)&text=\(self.appDelegate.text)&recipients=\(self.appDelegate.recipients)&sender=\(self.appDelegate.sender)"

    NSLog("PostData: %@",post);

    var url1:NSURL = NSURL(string: "http://api.infobip.com/api/v3/sendsms/json")!

    var postData:NSData = post.dataUsingEncoding(NSASCIIStringEncoding)!

    var postLength:NSString = String( postData.length )

    var request:NSMutableURLRequest = NSMutableURLRequest(URL: url1)
    request.HTTPMethod = "POST"
    request.HTTPBody = postData
    request.setValue(postLength, forHTTPHeaderField: "Content-Length")
    request.setValue("application/x-www-form-urlencoded", forHTTPHeaderField: "Content-Type")
    request.setValue("application/json", forHTTPHeaderField: "Accept")


    var reponseError: NSError?
    var response: NSURLResponse?

    var urlData: NSData? = NSURLConnection.sendSynchronousRequest(request, returningResponse:&response, error:&reponseError)

    if ( urlData != nil ) {
        let res = response as NSHTTPURLResponse!;

        NSLog("Response code: %ld", res.statusCode);

        if (res.statusCode >= 200 && res.statusCode < 300)
        {
            var responseData:NSString  = NSString(data:urlData!, encoding:NSUTF8StringEncoding)!

            NSLog("Response ==> %@", responseData);

            var error: NSError?

            let jsonData:NSDictionary = NSJSONSerialization.JSONObjectWithData(urlData!, options:NSJSONReadingOptions.MutableContainers , error: &error) as NSDictionary


            let status: NSString? = jsonData.objectForKey("status") as? NSString
            let tmp: NSString? = "success"
            let tmm: NSString? = "already register"

            NSLog("Success: %ld", status!);

            if(status == "success")
            {
                NSLog("Login SUCCESS");

                let VerificationcodeViewController = self.storyboard?.instantiateViewControllerWithIdentifier("verificationcodeViewController") as UIViewController

                self.navigationController?.pushViewController(VerificationcodeViewController, animated: true)
            }else if(status == "already register")
            {
                NSLog("Login failed");
                var alertView:UIAlertView = UIAlertView()
                alertView.title = " Already Exists"
                alertView.message = "Enter a new mail id"
                alertView.delegate = self
                alertView.addButtonWithTitle("OK")
                alertView.show()
            }

            else {

                NSLog("Login failed1");
                var alertView:UIAlertView = UIAlertView()
                alertView.title = " Wrong Email"
                alertView.message = "Invalid Email"
                alertView.delegate = self
                alertView.addButtonWithTitle("OK")
                alertView.show()
            }

        } else {

            NSLog("Login failed2");

        }
    } else {

        NSLog("Login failed3");
    }

I believe that you need 2FA library , instead of pure SMS send!我相信你需要2FA库,而不是纯短信发送!

Here is details what is 2FA and how it works .以下是什么是2FA及其工作原理的详细信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在iOS应用程序中实现“双重身份验证”? - How to implement “Two factor authentication” in iOS application? 如何在快速的iOS中集成Tez支付网关? - How to integrate Tez payment gateway in swift iOS? 如何在iOS(swift)项目中集成Paytm支付网关? 无法创建PGMerchantConfiguration的对象 - How to integrate Paytm payment gateway in iOS(swift) project? Unable to create object of PGMerchantConfiguration 如何在swift项目中集成PayUMoney iOS SDK? - How to integrate PayUMoney iOS SDK in swift project? 如何将Unity集成到Swift 3 iOS项目中 - How to integrate Unity into a Swift 3 iOS project 如何在 iOS 中使用 swift 集成支付网关 Paytm? - How to integrate payment gateway Paytm using swift in iOS? 如何将unity ios项目集成到本机ios swift项目中? - How to integrate the unity ios project into native ios swift project? Swift-如何使用将SwiftValidator集成到我的项目中 - Swift - How to use integrate SwiftValidator into my project 如何在我的iOS / Swift项目中调用我的AWS API Gateway REST API - How to invoke my AWS API Gateway REST API in my iOS / Swift project 检查 iCloud 是否有双因素身份验证? 斯威夫特/iOS - Check if iCloud has two-factor authentication? Swift/iOS
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM