简体   繁体   English

设计:iOS“添加到主屏幕”

[英]Devise: iOS “Add to Home Screen”

When I open my web app on my iOS device, login and restart Safari, I am still logged in. 当我在iOS设备上打开我的网络应用程序,登录并重新启动Safari时,我仍然登录。

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? 有没有使用Devise gem的解决方法或者除了构建本机应用程序之外没有别的办法吗?

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: 您可以向DOM中添加一些内容,例如隐藏的div,以及用于登录用户所需的数据:

<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. 然后从javascript获取该div并使用其数据向您的后端发出经过身份验证的请求。 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). 当然,只有当您的用户在登录后将应用程序保存到主屏幕时才会起作用(并且您还应该在登录时重新加载页面)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM