"apple-mobile-web-app-capable" site switches to Mobile Safari after logout - ios

When running a mobile site in iOS full screen mode, using the "apple-mobile-web-app-capable" meta tag, I am using a combination of AJAX and synchronous page requests, including redirects, with success while the user is logged in.
However, when the user logs out and the session is destroyed, the iOS device leaves full screen mode and opens the login page in a Mobile Safari window.
Here is a common sequence of events:
User clicks button on Home Screen to launch mobile site in iOS full
screen mode
Server redirects user to login page for authentication (still in full screen)
User logs in, and is redirected back to mobile home (still in full screen)
User performs various actions, via GET and POST, some using AJAX and some not (still in full screen)
User hits logout button, which destroys session and redirects back to login page
Mobile Safari window opens to render login page this second time
I have tried 301, 302 and 303 redirects on logout success and nothing seems to change this behavior. It seems related to the user's session ending when running in full screen mode. I don't think this matters, but the security mechanism is implemented via Spring Security running on Tomcat.
Is there any way to prevent this behavior? I would prefer not to use a location.href client side redirect on logout.

You can cancel a links default behaviour by using jQuery's event delegation to assign a single, top-level event handler to all links on the page. When a click event is detected, we cancel the default behavior (which is to open in mobile Safari) and then manually change the window's location. This approach allows the page to be changed without breaking the iPhone standalone application experience.
http://www.bennadel.com/blog/2302-Preventing-Links-In-Standalone-iPhone-Applications-From-Opening-In-Mobile-Safari.htm
I was under the impression from running into this previously that any non-ajax/ javascript navigation would cause the app to jump into safari to serve the page

Related

OAUTH 2 not working on "standalone" HTML5 app vrs web app

I have a web app eg www.webapp.com that uses Google's OAUTH2 (gapi.authorize) (OAUTH2) to sign in users. It works from the desktop and mobile devices as long as I use the browser to navigate to the site.
PROBLEM: I can install it to the (eg "Add to Homescreen" on Android). But when I run it from the homescreen, the authentication/consent screen gets stuck on a blank page and a "connecting" message. My manifest.json file has display: standalone
I have to manually close the popup, and use the "Back" button on the phone to get back to the login screen. The response
token etc. are there as expected. Why is the popup screen not closing? How can it be forced to close without user intervention?

Safari on iPhone: Can I close the oauth browser tab?

I am using oauth to authenticate my iPhone-app's users. They click the login button and Safari opens to display the password entry page. Afterwards they are redirected using a custom url scheme, e.g. myapp://somethingsomething, which opens the application again (sending Safari into the background).
Can I close the browser tap during that redirect? Or directly afterwards via Javascript?
I ask because if my user imports a bording pass to his Passbook, Safari opens and logs my user in again, since the tab was still there.
Ok fixed by doing a setTimeout() call in JS before issuing the redirect. In the setTimeout() another redirect is executed: To a harmless page.

JQM 1.4 redirect user to page on app loaded

I've got a jquerymobile 1.4 application that has all the pages on the same html page (pages are broken into different divs).
What I'm looking for is an app-level initialiser event to subscribe to that allows me to do some logic checking (e.g. authentication status) and redirect them to a login page (say div#login) if necessary.
I've explored working with a popup, setting the login page to be dialog="true" and what I'm stuck with is how to redirect the user when the app first loads.
There's mobileinit and pagecontainercreate events. If I subscribe to the pagecontainercreate event then I can run a changePage function and that works, but then it transitions to the default page straight afterwards anyway.
As far as the ideal lifecycle:
mobile app finished loading -> show login dialog page -> init login page
What's happening now is:
pagecontainercreate -> show login dialog page -> close login dialog page and show home page automatically.

How to save my home page for offline support in UIWebView

I have an app that already develop in HTML.
We are rendering app in UIWebview using the server URL.
Everything working fine. But I want to cache the Login page for offline support.
So, If user kill the app and restart the device and open app in offline mode he will see only the blank page.
Is there any way to save the login page so that user will able to see the login page instead of blank page.

Facebook login doesn't work inside Twitter iOS App

I have a RoR / JQuery Mobile app that uses Facebook OAuth for authentication. It all works fine when accessing it via any normal browser on desktop and mobile with one exception.
If a user clicks a link to the app within the Twitter iOS app the home page loads within an internal webview. If the user then clicks 'Sign In with Facebook' the authentication seems to be successful but when Facebook redirects the user back to the app the page never loads. It just displays a blank page and the network indicator at the top of the screen just keeps spinning. If I close the web view and click the link again the page loads fine because the user has already authenticated.
Has any one else had problems with Facebook Auth inside the twitter app on iOS? Any suggestions on how I can resolve this problem? Is it possible this is just a bug with the Twitter app on iOS?
Thanks
I believe I found the solution. The facebook authentication process used a lot of redirects which I thought could be causing the problem (5 in total). After reviewing the process I realised I could remove one of the redirects and take the user directly to the page I wanted once they were authenticated.
www.example.com (link from the tweet)
www.example.com/auth/facebook (use clicks 'Login with Facebook')
1 - Redirect to: graph.facebook.com/oauth/authorize
2 - Redirect to: www.facebook.com/dialog/oauth
3 - Redirect to: www.example.com/auth/callback
4 - Redirect to: www.example.com/entry_path (This has now been removed)
5 - Redirect to: www.example.com/final_logged_in_path
The login process now works from within the Twitter iOS App.

Resources