Can we get any result or feedback when launched a link in UIWebview within an ipad application - ios

I developed an ipad app where in i have a situation where the user taps a button which redirects to a login page (UIWebView),The user enters his credentials and web page hits a server where the validation takes place and the browser is returned a feed back string (authorization).
Question:
Is there a provision to know the feedback string/data by the application? According to my knowledge as soon as a webView is launched our application has no info about the happenings on Webview.
I don't want to implement services in my application since the service provider says that the webpage redirects the user to app upon successful login.Which may be possible on a desktop,but in ipad application can the bowser/Webview redirect back to the application upon login and more ever i need the feedback string in my application.Can some one suggest how could i implement the same.Please correct me if i am going wrong...
TNQ

You can call Objective-C methods from UIWebView. This you can do by trapping your custom urls in the shouldStartLoadWithRequest: method. More details are here.

Related

Google Plus iPhone API sign in and share without leaving app

I have integrated the Google+ API in my App for login and sharing posts. Problem with it, is that everything requires you to leave the app and then come back (it uses URL schemes for this). This is not the expected behavior. I would like to know if there is a way to directly open up the login dialog within the my app it self without going to safari.
I really want to avoid going back and forth between safari and my app.
I just implemented same thing for my application. I have used Google's Sign In SDK. it will present Webview controller inside your app and let you login with your account, after that it will dismiss the Webview controller and call a delegate to get info for user.
Please read and follow the steps from this link,
https://developers.google.com/identity/sign-in/ios/
hope it answers the question.

Handling Custom URL Application Start in ios

We have link functionality in our web application that when clicked, browses to a page on our server that performs the following:
Tries to open the custom url to our ios application
If this fails, it redirects the user to our ios app store to download the app.
This actually all works perfectly well.
However, it creates a weird corner case, where after a user has done this and finished, if they come back sometime later and open their safari on the same phone, if our web link is still the active tab, it will redirect them again to our application.
The cause of this is fairly obvious, but we are struggling to come up with a solution for it. Is there any known to rectify this behavior, either through a different mechanism then I described for opening the application or through somehow killing the page simultaneously?

Control flow for a webservice-backed iOS App

I'm learning the basics of iOS development, and I'd like to make a simple application that connects to a web service. I've got a lot of experience on the web application side, so I'm comfortable with what kinds of requests the app needs to send/receive etc. The part I'm not sure about is what the big picture architecture of a service-backed mobile application looks like.
When my application runs, I have one major requirement: the user must authenticate into the web service. The web service can send back a token and the app can use this for all subsequent requests. I want the user to be able to log in once, and for the app to stay logged in (ie the token remains valid for that device) indefinitely unless they log out.
Until the user logs in the application should really just be a login screen. If they log out, the same. Otherwise, they don't need to see the login screen at all.
So my question is, what is the right way to structure this?
In AppDelegate, do I want to make a LoginViewController and set it to the rootViewController? Then if the user is logged in, push to the main view for the rest of the app?
Or do I want to initialize the main part of the app (for instance, a UITabBarController with a few views in it), and check for a token, and then display a modal login screen if no token is available?
What I'm not clear on is what the rootViewController should be for an application like this, and how the app should keep track of whether the user is logged in, and determine what screen to show when the app is opened.
If anyone can give me a high level overview of how such an app should be structured, I'd really appreciate it.
Thanks!
There isn't really a right way to do this, either flow could be appropriate for an application. If I had some UI or data that would be displayed if a user is not logged in then I would use that as the initial rootViewController and use a modal login dialog to force the user to login. On the other hand, if I had nothing to display until a user has logged in then I would setup the login view controller to be the initial rootViewController if the user is not currently logged in.
For keeping track of the user being logged in you should leverage NSUserDefaults to persist the authentication token. Then in the application:didFinishLaunchingWithOptions: call to your app delegate look for this token in NSUserDefaults (and possibly validate it with the server) then set the rootViewController as appropriate.

If a UIWebView displays a remote page with a username/password then can the native code tell if/when it has been validated?

I have a requirement for an app to communicate with a server, this communication is done using a proprietary http based protocol and the app uses NSUrlConnection for this.
However before the app can be used the user must first perform a one-off registration, and the requirement is that this is done by them logging onto a web page which will be downloaded and displayed in a UIWebView. As a UIWebView is used I no longer have access to the HTTP header/body nor the NSURLConnectionDelgate etc. for this part of things.
My question is, how can the app know if and when the user has successfully logged onto the web site?
It sounds like you want to implement some code in the connection:didReceiveAuthenticationChallenge: method of the NSURLConnectionDelegateProtocol. There's more information about how to respond to a challenge here.

iOS returning from safari (or another app)

My problem is the following: in my app, I need to switch to safari for a login; however, when the user is redirected to my app, I want a specific action to be executed. Is there a way to do that? ViewWillAppear doesn't work, since it's called only the first time the views shows up....
Thanks for the help :)
You could register your iOS app to handle URL scheme 'foo', then invoke or have a link pointing to 'foo://my_custom_launch_action' from your website. When your app launches, you may read the launch options and act accordingly.
I think the official Flickr app for iPhone implements this mechanism to authenticate users through Safari from outside the app.

Resources