localStorage support?

Welcome! Forums Unity Plugins In-App Web Browser localStorage support?

Tagged: 

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #1048
    pezo1919
    Participant

    Hi!

    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,
    Zoltan

    #1049
    pezo1919
    Participant

    I forgot to mention I tried it on Pixel2 android emulator.

    I don’t know about iOS behaviour.

    #1066
    PiotrPiotr
    Keymaster

    What exactly is happening? Do you see any JS errors while using LocalStorage?

    #1070
    pezo1919
    Participant

    I 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?

    #1071
    PiotrPiotr
    Keymaster

    Thanks for those explanations.
    So it seems it does not support, although it should be really easy to add.

    Open iOSInAppBrowser.mm from Plugins/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 5 years, 10 months ago by PiotrPiotr.
    #1073
    pezo1919
    Participant

    Okay, 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.

    #1074
    PiotrPiotr
    Keymaster

    Sent patched version on your email. Let me know if that works for you.

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.