7

When I open my web app on my iOS device, login and restart Safari, I am still logged in.

But when I add this page with "Add to Home Screen", each time I click the icon for that page, I have to login again.

Is there a workaround for this with the Devise gem or is there really no other way but building a native app?

karlingen
  • 13,800
  • 5
  • 43
  • 74
  • According to [this answer](http://stackoverflow.com/questions/21109615/ios7-safari-saving-to-home-screen-and-persist-token), it's not really possible anymore because the home screen web apps are sandboxed. – p4sh4 Aug 17 '15 at 06:43

1 Answers1

2

One thing you can try is the following.

You can add something to your DOM, for example hidden div, with the data you need to log user in:

<div id="authentication-div" data-user-id="5" data-user-key="abbbbaafff12899a9a">

Then you fetch that div from javascript and use its data to make authenticated request to your backend. Of course that will work only if your user saved your app to home screen after they have been signed in (and you should reload the page on sign in as well).

EugZol
  • 6,476
  • 22
  • 41
  • Isn't that a little insecure? It is almost like printing the users password on the page. – vigneshv Aug 28 '15 at 22:49
  • There is no option in iOS to literally save HTML of page and send it to someone. So that key could be accessible only from inside of page itself – looks pretty secure. – EugZol Aug 31 '15 at 15:19