I am creating a website that has login with firebase google authentication. It's working fine in all browsers. But when I add this website in my app as webview it does not work.
website showing this error:
This operation is not supported in the environment this application is running on. "location.protocol" must be http, https or chrome-extension and web storage must be enabled.
here some code bellow:
javascript code:
function login(){
console.log('login called');
function newLoginHappend(user){
if(user){
model_questions(user);
}else{
var provider = new firebase.auth.GoogleAuthProvider();
firebase.auth().signInWithPopup(provider).then(function(result) {
// This gives you a Google Access Token. You can use it to access the Google API.
var token = result.credential.accessToken;
// The signed-in user info.
var user = result.user;
// ...
}).catch(function(error) {
// Handle Errors here.
var errorCode = error.code;
var errorMessage = error.message;
// The email of the user's account used.
var email = error.email;
// The firebase.auth.AuthCredential type that was used.
var credential = error.credential;
// ...
});
}
}
firebase.auth().onAuthStateChanged(newLoginHappend);
}
window.onload = login();
webview code:
WebSettings webSettings =webView.getSettings();
webSettings.setJavaScriptEnabled(true);
webView.setWebViewClient(new WebViewClient());
webView.loadUrl("https://mahmud-cse16.github.io/CBAP_Handout/");
Is there any way or technique to solve this problem?? if you have any idea then share with us please.
thanks
Try enabling DOM Storage for the webview
WebSettings webSettings = myWebView.getSettings();
webSettings.setDomStorageEnabled(true); // localStorage
Sets whether the DOM storage API is enabled. The default value is false.