Welcome! › Forums › Unity Plugins › In-App Web Browser › localStorage support?
Tagged: localStorage
- This topic has 6 replies, 2 voices, and was last updated 6 years, 9 months ago by
Piotr.
-
AuthorPosts
-
April 30, 2018 at 10:38 pm #1048
pezo1919
ParticipantHi!
I’ve just bought your plugin and I’ve found it does not work as I expected. I have a webapp which uses localStorage, and I thought your plugin uses it as well.
Is there any way to workaround this? I think it would be crucial, there are lot of client side webapps out there which heavily use localStorage.
I have a game with many levels, the whole state (levels + currentlevelID + etc.) is stored in localStorage; and I want my user to at least continue the game on the latest level (which I store in localStorage).
Best Regards,
ZoltanApril 30, 2018 at 11:37 pm #1049pezo1919
ParticipantI forgot to mention I tried it on Pixel2 android emulator.
I don’t know about iOS behaviour.
May 5, 2018 at 12:35 pm #1066Piotr
KeymasterWhat exactly is happening? Do you see any JS errors while using LocalStorage?
May 5, 2018 at 1:45 pm #1070pezo1919
ParticipantI have a webapp on the web, which uses localStorage.
If I open it via iOS WKWebView, it can use localStorage, which means if I open the iOS app itself, when it loads up the webapp it will use the localStorage as well, so I can store state on client and use it in my webapp.
I want to do the same thing with your unity plugin -to unify ios and android platforms and use just one codebase to create a webview (and later show ads).
When I use your plugin, it can load up the webapp properly. But if I close the unity app with your plugin, when I reopen it – it loads the initial state of my webapp: which means it does not use localStorage.
“Do you see any JS errors while using LocalStorage?” – Unfortunately I don’t know your plugin, how can I find this out?
But my main question is: should it even work, aka. does your plugin support localStorage?
May 5, 2018 at 5:08 pm #1071Piotr
KeymasterThanks for those explanations.
So it seems it does not support, although it should be really easy to add.Open
iOSInAppBrowser.mm
fromPlugins/iOS
directory and add that line:
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"WebKitStoreWebDataForBackup"];
just after
_OpenInAppBrowser
declaration.So it should look like that:
void _OpenInAppBrowser(char *URL, struct DisplayOptions displayOptions) { [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"WebKitStoreWebDataForBackup"]; NSString *urlAsString = [NSString stringWithUTF8String:URL]; _ShowURLWithDisplayOptions(urlAsString, displayOptions); }
Let me know if that worked for you.
-
This reply was modified 6 years, 9 months ago by
Piotr.
May 5, 2018 at 5:10 pm #1073pezo1919
ParticipantOkay, thanks I will try it.
However, can you please help me with the Android version as well? As I mentioned above, I tried it on a Pixel XL 2 Simulator (with Android), and it didn’t worked.
May 5, 2018 at 5:24 pm #1074Piotr
KeymasterSent patched version on your email. Let me know if that works for you.
-
This reply was modified 6 years, 9 months ago by
-
AuthorPosts
- You must be logged in to reply to this topic.