I have a secure webView which shows the customer to Load his wallet . I pass secure information MPIN(like a one time password). There is problem with
@IBOutlet weak var loading: UIActivityIndicatorView!
@IBOutlet var lblLoading: UILabel!
@IBOutlet weak var mob_webview: UIWebView!
override func viewDidLoad()
{
super.viewDidLoad()
mob_webview.hidden = true
mob_webview.delegate=self
cmmn.createDatabase()
linkgot = cmmn.geturl()
link="http://*****************************************.jsp?"
let request = NSMutableURLRequest(URL: NSURL(string: link)!)
request.HTTPMethod = "POST"
let postString = "recharge_type=\(_catcode)&amount=\(_amountfiled_got)&mobileNo=\(cmmn.getPhoneNumber())&prePostLan=\(prePostLan)&stdCode=\(_stdCode)&accNo=\(accNo)&deduct_frm=B&rcMobileNum=\(_numberfiled_got)&mobOperator=\(_merch_code)&operator=\(_operatr)&rcType=\(_rec_type)&mpin=\(_mpin)"
request.HTTPBody = postString.dataUsingEncoding(NSUTF8StringEncoding)
let task = NSURLSession.sharedSession().dataTaskWithRequest(request) {
data, response, error in
if error != nil {
print("error=\(error)")
return
}
print("response = \(response)")
let responseString = NSString(data: data!, encoding: NSUTF8StringEncoding)
print("responseString = \(responseString)")
}
task.resume()
mob_webview.loadRequest(request)
// Do any additional setup after loading the view.
}
func webViewDidFinishLoad(webView_Pages: UIWebView)
{
mob_webview.hidden = false
loading.hidden = true
lblLoading.hidden=true
print("OK")
}
Response in server log:
In the server ,If the user types the MPIN wrong three times, he gets blocked. This is done based on the number of wrong MPIN hits in the server. For some reason my web view makes the request twice (i.e. Calls the link which loads the request twice),even though its loaded just once.Suppose if customer enter wrong MPIN and load the web view, The link is called twice he looses 2 chances to enter correct MPIN. The android version of our APP works correctly with a similar kind of request.Any reason for it?
I gone through apple reference document after reading your question. It says then webViewDidFinishLoad
is called after loading each frames in webview. Here is document
webViewDidFinishLoad: Sent after a web view finishes loading a frame.
Please check with server, that how many request is made for one run. it's 2 or one. Also want to know how many time your print statment in your code execute print("response = \(response)")
. As I don't console for this statement.
Found in your question you calls NSURLSession dataTaskWithRequest and also load request in web view. That might also problem for calling same thing twice. If you want to open request in webview don't use NSURLSession task request. Run it by commenting task.resume()
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With