Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Tander

macrumors 6502a
Original poster
Oct 21, 2011
676
1
Johannesburg, South Africa
Hi Guys,

So I am busy experimenting with HTTP POST requests from an iOS app.

The idea is this:

1. User Fills in some details in a UITextField(s)
2. User taps confirm button
3. UIWebView comes up on screen
4. HTTP POST request is made to the server with details from the text fields.
5. Once server has received POST request and we get a "successful transaction" it redirects back to the app
6. UIWebView closes based on step five.

So the user cannot close the WebView. The WebView closes based on two statements

1. HTTP POST Request successful
2. HTTP POST request failed

So the UIWebView will always have a way to close.

Now I am able to complete steps 1,2 and 3.
I can figure out step 4 with some digging.

What I want to know - if it possible to have the UIWebView close based on a HTTP POST request? [self.myWebView removeFromSuperView} type of thing?

The big idea here is implementing 3D Secure into my app - however before I explore those avenue - I need to make sure I can close a UIWebView based on a HTTP POST request.

If the only way to close a UIWebView is by a button or navigation controller etc - then I can stop here in my request for 3D Secure. :(

Any advice?

Thanks all!
 

dantastic

macrumors 6502a
Jan 21, 2011
572
678
If you collect the info required for the request in text fields. Why do you need a web view?
 

Tander

macrumors 6502a
Original poster
Oct 21, 2011
676
1
Johannesburg, South Africa
If you collect the info required for the request in text fields. Why do you need a web view?

Because the text will be details of the Credit Card using to pay for goods - I then want to push those details to a merchant-plug-in (In our case - BankServ) to verify 3D Secure status. Then the user types in their OTP or Password for their CC and then if that is successful - the UIWebView should close and user should be back in the app and saying order was completed.

UIWebView should also close if the card was not verifited. So, HTTP POST requests are used for this sort of thing.

Now taking out credit card logics and all the 3D secure logic out of this question - the requirement are:

1. It must be a web browser (So, UiWebView)
2. The browser must close once done.

So I want to make a simple app that just sends some HTTP Post data to a server - I dont care what data it is - but it must come from text fields and then i want the UIWebView to close once it posts a HTTP POST request back from the server.

I wont be dealing with the credit card stuff and 3D secure stuff - I just want to see if UIWebView can be closed other than tapping a back or close button. It needs to close based on a condition..
 

dantastic

macrumors 6502a
Jan 21, 2011
572
678
What I'm saying is it's a bit .... arseways... taking the details in textfields, injecting the into and making the request from a webview. I see you might be tied down to some 3rd party solution here so fair enough...

You're looking for the uiwebview delegate webView:shouldStartLoadWithRequest:navigationType:
You will be able to check what's in the request and close the webview or do whatever else you want.
 

Tander

macrumors 6502a
Original poster
Oct 21, 2011
676
1
Johannesburg, South Africa
What I'm saying is it's a bit .... arseways... taking the details in textfields, injecting the into and making the request from a webview. I see you might be tied down to some 3rd party solution here so fair enough...

You're looking for the uiwebview delegate webView:shouldStartLoadWithRequest:navigationType:
You will be able to check what's in the request and close the webview or do whatever else you want.

To make life easier - could I close the UIWebView when the webpage within the webview is redirected?

I think maybe like a "listen" even (Like NSNotificationCenter) so to say something like..

If the webpage is redirected to xxyyyzz url - close the webview. So I could use the delegate as you say...

I appreciate the reply - will try this out tomorrow.
 

shah450

macrumors newbie
Jan 2, 2014
1
0
Though this discussion is very old, i would still interested to know the answer.

Did you find any solution? Have you achieved what you wanted to do? Please share.

My id is : shah450@gmail.com

Send me your id, we can discuss in detail if you don't mind. Thanks,
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.