How could I make this Javascript get inside the web view?

Asked

Viewed 54 times

0

I’m making a web view of a site in Android studio, and this site has a button that makes the registration where I programmed the system on the site but it does not work in webview. How could I make this Javascript get inside the web view ?

This is the code I used on the site:

import wixUsers from 'wix-users';

import wixData from 'wix-data';

import wixLocation from 'wix-location';



$w.onReady( () => {

  if(wixUsers.currentUser.loggedIn) {

        $w("#loginButton").label = "Logout";

        $w("#profileButton").show();

  }

  else {

        $w("#loginButton").label = "Login";

        $w("#profileButton").hide();

  }

} );



export function 
loginButton_click(event) {

  // user is logged in

  if(wixUsers.currentUser.loggedIn) {

        // log the user out

        wixUsers.logout()

          .then( () => {

        // update buttons 
accordingly

            $w("#loginButton").label = "Login";


$w("#profileButton").hide();

        } );

  }

  // user is logged out

  else {

        let userId;

        let userEmail;



        // prompt the user to log in

        wixUsers.promptLogin( {"mode": "login"} )

          .then( (user) => {

            userId = user.id;

            return user.getEmail();

          } )

          .then( (email) => {

            // check if there is an item for the user in the collection

            userEmail = email;

            return wixData.query("profile")

              .eq("_id", userId)

              .find();

          } )

          .then( (results) => {

            // if an item for the user is not found

            if (results.items.length === 0) {

              // create an item

              const toInsert = {

                "_id": userId,

                "email": userEmail

              };

              // add the item to the collection


wixData.insert("profile", toInsert)

                .catch( (err) => {

                  console.log(err);

                } );

            }

            // update buttons accordingly

            $w("#loginButton").label = "Logout";


$w("#profileButton").show();

          } )

          .catch( (err) => {

            console.log(err);

          } );

  }

}



export function 
profileButton_click() {


 wixLocation.to(`/profile/${wixUsers.currentUser.id}`);

}
  • Already tried to enable javascript with webview.getSettings().setJavaScriptEnabled(true);?

  • already, but in versions of android less than 5.0.0 is not working. What I could do?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.