Cap-go / capacitor-inappbrowser

Capacitor plugin in app browser with urlChangeEvent
MIT License
71 stars 53 forks source link

Using the InAppBrowser.open({url: "https://test.com"}) gives {"code":"UNIMPLEMENTED"} #211

Open heblol opened 1 month ago

heblol commented 1 month ago

Hi there!

I just saw this fantastic plugin, however, it's not working for me? Trying to do the following:

await InAppBrowser.open({ url: "http://google.com" })
        .then((result) => {
          console.log("result opening browser", result);
        })
        .catch((error) => {
          console.error("error opening browser", error);
        });

Using the openWebView function gave the same error (await InAppBrowser.openWebView(...))

However, it gives me the error: ⚡️ [error] - error opening browser {"code":"UNIMPLEMENTED"}

I tried no to await the InAppBrowser.open(...), but that gave me no response at all.

Any idea what's going on?

iOS: (virtual) Iphone 16 - IOS 18.0 capacitorjs version: 6.1.2

using it with ReactJs

Full component:

import { Button, Card, CardContent, TextField } from "@mui/material";
import { Title } from "../../components";
import { useState } from "react";
import { InAppBrowser } from "@capgo/inappbrowser";
import { Capacitor } from "@capacitor/core";

export default function RecipeURLImport() {
  const [recipeURL, setRecipeURL] = useState<string>("");

  async function openBrowser() {
    console.log("clicked on open browser");
    if (Capacitor.isNativePlatform()) {
      console.log("trying to open the browser?");
      await InAppBrowser.open({ url: "http://google.com" })
        .then((result) => {
          console.log("result opening browser", result);
        })
        .catch((error) => {
          console.error("error opening browser", error);
        });
      console.log("after opening browser??");
      InAppBrowser.addListener("browserPageLoaded", () => {
        console.log("browserPageLoaded");
      });

      InAppBrowser.addListener("messageFromWebview", (event) => {
        console.log("messageFromWebview", event);
      });

      InAppBrowser.addListener("urlChangeEvent", (event) => {
        console.log("urlChangeEvent", event);
      });

      InAppBrowser.addListener("confirmBtnClicked", (event) => {
        console.log("confirmBtnClicked", event);
      });
    } else {
      console.log("trying to open it using the window.open");
      window.open("https://dansen.nl");
    }
  }

  return (
    <Card>
      <CardContent>
        <Title>Import recipe using an URL</Title>
        <Button
          onClick={() => {
            openBrowser();
          }}
        >
          Open browser
        </Button>
      </CardContent>
    </Card>
  );
}

Thank you in advance!

riderx commented 1 month ago

Hello did you cap sync ? it's seems weird like the native code didn't arrive in your app code