Reputation: 25
On iOS:
Is it possible to share data on the client side between a page on mobile safari and a page on a WebView (native app) ?
Both pages on the exact same domain.
So far i tired webSQL and localStorage and they seem to keep the data in a separate DBs even though its the exact same link.
I dont mind using WebSQL/indexDB, localStorage, cookie, appCache, Kung Fu, whatever!
Your help is highly appreciated :)
Thanks
Upvotes: 1
Views: 3498
Reputation: 69047
I don't think you can share data on the client side between Mobile Safari and an app embedding an UIWebView
. Indeed, they are two apps hosted in different sandboxes. (For general information about sandboxing, read here). If this were possible, you could have your app compromise Safari security, which is definitely not desirable.
What you could do is store data on the server side by using cookies. You should provide more details about what you are trying to do in order to provide some concrete example, but the general idea here is that you identify your user session uniquely, then use this unique identifier both from the UIWebView
and Mobile Safari. Then you can make the UIWebView
and Mobile Safari communicate like this:
from UIWebView
to Mobile Safari: you can open a URL in Mobile Safari and have that URL encode the user identifier so that Safari will get access to the same user data;
in Mobile Safari: use a custom URL scheme (e.g.: "myapp://xxxxxxx") and make your app register itself as a handler for that URL scheme; also, encode the user identifier within the URL so your app knows which data to request.
I hope this hints can give you an idea about how to design your app.
Upvotes: 2