-
2 Aug 2012 1:45 AM #1
Unanswered: Application using localStorage with browser in incognito mode issue
Unanswered: Application using localStorage with browser in incognito mode issue
I'm using Sencha Touch 2 to build my mobile website version.
I've got an issue when browsing in Incognito Mode with Iphone Safari Mobile, Android native Browser and Android and Iphone Chrome.
In my App i've defined a store for users
that uses a model with localStorage proxy:Code:Ext.define('MyApp.store.UserLogin', { extend: 'Ext.data.Store', xtype:'userstore', config: { model: 'MyApp.model.UserForLogin' }, })
Code:Ext.define('MyApp.model.UserForLogin', { extend: 'Ext.data.Model', id: 'model-user', config: { identifier: 'uuid' , fields: ['myUserField1', 'myUserField2'], proxy: { type: 'localstorage', id : 'my-local-storage-id' }, } });
and, in my application definition and launcher:
Code:Ext.application({ name: 'MyApp', models: [ 'UserForLogin' ], stores: [ 'UserLogin' ], views: ['Main'], controllers: ['Home'], launch: function() { Ext.Viewport.add( Ext.create('MyApp.view.Main')); } })
When i open my application in normal mode, i can read / write user data using the store, but when i set Incognito (anonymous) mode in mobile browser, application throw this exception on startup:
QUOTA_EXCEEDED_ERR: DOM Exception 22: An attempt was made to add something to storage that exceeded the quota.
I read somewhere that max quota for local storage is 5MB, but, when i try to write something in local storage, it's every something less than 10k.
Sorry for my poor english....! My idea is to add store and model only if localStorage is supported, so i would like to check this somewhere...before main application definition, but i really don't know where..!
Any Help / Suggestion would be appreciate. Thanks You
-
2 Aug 2012 12:52 PM #2
I have this problem too, it basically prevents the app from loading at all in private mode.
-
3 Aug 2012 12:03 AM #3
my "bad" solution was this:
but i would prefer something better than this...Code:proxy: { type: (function() { try { var mod= 'MyApp-Test-LocalStorage'; localStorage.setItem(mod, mod); localStorage.removeItem(mod); return true; } catch(e) { return false; } }()) ? 'localstorage' : 'memory', id : 'MyApp-Logged-User' }
Work in Progress...
-
3 Aug 2012 10:29 AM #4Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,641
- Vote Rating
- 434
- Answers
- 3107
This is the same as private browsing in Safari to which we have an open internal bug reported by myself.
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
3 Aug 2012 1:28 PM #5
Thank You mitchellsimoens, I intercept Safari Bug with... try...catch
... Greetings from Roma!
-
16 Aug 2012 6:08 AM #6
My solution:
Code:checkPrivateMode: function(){ var storage, fail, uid; try { uid = new Date; (storage = window.localStorage).setItem(uid, uid); fail = storage.getItem(uid) != uid; storage.removeItem(uid); fail && (storage = false); } catch(e) { storage = false; } if (Ext.os.is.iOS && storage === false) { //private mode } }


Reply With Quote