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

时间:2022-02-13 02:05:14

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

1 个解决方案

#1


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:

您可以向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. 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).

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

#1


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:

您可以向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. 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).

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