Skip to content

Localstorage is 'null' in android webview #5288

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
nmongiya opened this issue Jan 18, 2018 · 2 comments
Closed

Localstorage is 'null' in android webview #5288

nmongiya opened this issue Jan 18, 2018 · 2 comments

Comments

@nmongiya
Copy link

I am trying to load a webpage for login in webview. That webpage uses localstoage to save password in case of 'Remeber Me'
That is working fine on web and ios but on android I am getting the below error

Uncaught TypeError: Cannot read property 'getItem' of null
That seems localstorage is null in case of android webview.

Which platform(s) does your issue occur on?

Android

Please provide the following version numbers that your issue occurs with:

"nativescript": {
"id": "org.fcs.FreshTracker",
"tns-ios": {
"version": "3.4.1"
},
"tns-android": {
"version": "3.4.1"
}
},
nativescript-pro-ui": "^3.3.0",
tns-core-modules": "~3.4.0",

I have checked on stackoverflow in found the pointer that I might need to enable setDomStorageEnabled(true)

For that I have tried
this.webview.android.getSettings().setDomStorageEnabled(true); but that is not able to access getSetiing as this.webview.android comes as undefined.
I have also tried
android.webkit.WebView.getSettings() but getSettings is not a function.

@nmongiya
Copy link
Author

We can close the issue, as I found the workaround. I was looking for .webview.android.getSettings().setDomStorageEnabled(true) in ngAfterViewInit but it seems it takes time to load so I am doing that in webview loaded function.
Ref: NativeScript/nativescript-angular#848

@lock
Copy link

lock bot commented Aug 27, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked and limited conversation to collaborators Aug 27, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant