iOS スタンドアロン Web アプリ (などを使用) でいくつかの単純なデータを保持する必要があるだけですapple-mobile-web-app-capable
。データは、ユーザーがサイトにアクセスしたときに定義され、などに保存されlocalStorage.name
ます。同じページは「ホーム画面に保存されます」が、そこに着くと、出力localStorage.name
などは返されますundefined
。
Safari に戻りますが、Safari はまだ情報を認識しています。ラップトップの開発者コンソールでそれを取得しても、すべてのデータを取得できます。別のページではなく、別のドメインなどは言うまでもありません。私が読んだすべてのことlocalStorage
は、Safari とスタンドアロン アプリの間で共有する必要があることを示しています (そのデータを変更するための小さな注意事項があります)。私は何が欠けていますか?
コードの要点は次のとおりです。
if (!window.navigator.standalone) {
// show Safari content
if (localStorage.name != void 0 && localStorage.var2 != void 0) {
// show normal, "add this to your home screen" language -
// this screen shows properly
} else {
// show "We weren't passed our variables" language
}
} else {
// Show standalone/offline content
if (localStorage.name != void 0 && localStorage.var2 != void 0) {
// Show normal standalone app content using localStorage variables.
// I'm not seeing this.
} else {
// Show "error" text, which is what I'm getting
document.body.removeChild(document.getElementById('container'));
var helper = document.createElement('section')
helper.id="helper"
helper.innerHTML = '<h1>Sorry</h1>'
+ '<p>There seems to be a problem with the app.</p>'
+ '<pre>'
+ " Name: " + localStorage.name + "\n"
+ " var2: " + localStorage.var21 + "\n"
+ '</pre>';
document.body.insertBefore(helper,document.body.firstChild)
}
}
なんといっても、私は iOS 6.1 です。したがって、それは「古い」問題であってはなりません。私は何を間違っていますか?