适用于iOS的移动Safari和应用程序的唯一标识符 [英] Unique Identifier for both mobile safari and in app in iOS

查看:570
本文介绍了适用于iOS的移动Safari和应用程序的唯一标识符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够唯一识别iPhone,以便我们的服务器可以使用一些自定义HTML进行响应。我希望能够在Safari和应用程序的嵌入式浏览器中识别手机。由于每个应用程序都是沙盒,因此cookie不起作用。

I'm looking to uniquely identify an iPhone so our server can respond with some custom html. I want to be able to identify the phone in Safari and in an embedded browser in the app. Since each application is sandboxed, cookies won't work.

谢谢

推荐答案

这实际上非常难。

您可以对应用进行编程,以便在首次打开时启动Mobile Safari并设置Cookie,然后重定向回应用使用自定义URL方案。

You could program the app so that it launches Mobile Safari when it first opens and sets a cookie, then redirects back to the app using a custom URL scheme.

这可能看起来很奇怪,但它实际上是Facebook的共享登录系统如何工作,它允许应用程序和浏览器突破他们的沙盒并共享相同的唯一cookie ID。

That may seem weird but it's actually how Facebook's shared login system works and it allows both the app and the browser to "break out" of their sandboxes and share the same unique cookie ID.

当然,除非您每次启动应用程序时都进行重定向,否则您不知道用户是否删除了cookie,可能会很烦人。

Of course you wouldn't know if the user had deleted the cookie unless you do the redirect every time the app launches, which might get annoying.

更新:

从iOS 9开始,您现在可以使用<$打开页面c $ c> SFSafariViewController 在你的应用程序内,而不是重定向到Safari应用程序。这仍然有点笨重,但可能比双应用程序切换更可取。

As of iOS 9, you can now open the page using SFSafariViewController inside your app instead of redirecting to the Safari app. This is still a bit clunky, but may be preferable to a double app switch.

这篇关于适用于iOS的移动Safari和应用程序的唯一标识符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆