如果已安装,是否强制在 Web Clip 中打开 URL?

发布于 2024-12-16 19:47:47 字数 449 浏览 4 评论 0原文

假设我有一个 Web 应用程序,它通过自定义 URL 方案调用本机应用程序,并且在本机应用程序完成其操作后,它通过打开回调 URL 返回到我的 Web 应用程序。

当我的网络应用程序在 Safari 中运行时,这一切都工作正常。但是,如果用户将 Web 应用程序保存到主屏幕(创建“Web Clip”)会发生什么?在这种情况下,它与常规 safari 运行在单独的进程中,并且具有单独的 cookie 和缓存。

因此,当本机应用程序尝试返回到 Web 应用程序时,URL 可能会由 Safari 打开,而不是由 Web Clip 打开,并且会话将会丢失。 (不仅仅是会话 - 所有页面状态,在一个丰富的基于 Javascript 的 Web 应用程序中,这些状态可能是很多具有非平凡启动时间的东西。)

这个假设正确吗?如果是这样,有什么办法可以解决吗?如果安装了,是否有某种方法可以让 iOS 尝试使用 Web Clip 打开 URL?

Let's say I have a web app that calls out to a native app via a custom URL scheme, and after the native app has done its thing it returns to my web app by opening a callback URL.

This all works fine when my web app is running in Safari. But what happens if a user saves the web app to the home screen (creating a "Web Clip")? In that case it runs in a separate process from regular safari, and has separate cookies and cache.

So when the native app tries to return to the web app, the URL will presumably get opened by Safari, not by the Web Clip, and the session will be lost. (And not just the session -- all the page state, which in a rich Javascript-based web app can be a lot of stuff with non-trivial startup time.)

Is this assumption correct? And if so, is there any way around it? Is there some way to get iOS to try to open the URL with a web clip if installed?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

少年亿悲伤 2024-12-23 19:47:47

为了在 iOS 上通过自定义 url 方案启动某些内容,您必须让应用程序通过应用程序内置的 Info.plist 注册此信息。

不可能让 webapp/webclip 在系统级别注册此信息。

因此,要回答您的主要问题,您不能这样做。

以下是有关 在本机应用程序中实现自定义 URL 方案

In order to have something launch via a custom url scheme on iOS, you must have an application register this information via the Info.plist built into the app.

It is not possible to have a webapp/webclip register this information system-level.

So, to answer your main question, you cannot do this.

Here is the information on implementing custom URL schemes in native applications.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文