2011-11-23 46 views
0

我有一个全屏运行的webapp,通过ajax与数据库交互。iOS WebApp - 记住保存设备

有没有办法让我可以得到一个设备的“签名”或“ID”来存储每个设备?

基本上我有一个“保存项目”选项,他们将被保存到一个唯一的ID。我无法使用多个设备的IP地址,或者使用3G服务。任何其他想法? (不要用户认证)。

我可以将数组保存在清单文件中并访问它吗?

谢谢

+0

请参阅http://stackoverflow.com/questions/1968323/get-iphone-id-in-web-app。然而,即使你有一个原生的'空壳'应用程序,只有一个webview加载你的网站(如链接建议),你需要一种方法来生成一个唯一的设备标识符,苹果最近(从iOS5开始)弃用获取设备标识符的旧方法(通过'[[UIDevice mainDevice] uniqueIdentifier]')。官方的建议是识别用户,而不是设备。 –

回答

0

我使用html5的本地存储解决了这个问题。

我用

var salt=Math.floor(Math.random()*10000); //makes random salt 
var randomId=Math.floor(Math.random()*20000); //makes another random number 
randomId = salt+(salt*randomId); //makes the id even more random to avoid dupes 
localStorange.setItem('deviceId',randomId); //sets a local variable that can be accessed by localStorage.getItem('deviceId'); and cross-refrenced with a $.get from a database to load the saves. 
$.post("saveDeviceId.php?id="+randomId); //saves the new id to the database 

这是我如何解决它无论如何,除非有人有一个更有效的方法?