2011-11-23 42 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 

這是我如何解決它無論如何,除非有人有一個更有效的方法?