Skip to content
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

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

Open
heblol opened this issue Oct 8, 2024 · 2 comments

Comments

@heblol
Copy link

heblol commented Oct 8, 2024

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
Copy link
Contributor

riderx commented Oct 15, 2024

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

@nasaleanhorea
Copy link

I had the same issue , for me the problem was that i was using v5 for @capacitor/cli to when npx cap sync , which is why the plugin wasn't getting fully implemented in the native code -> hence the error. After upgrading to @capacitor/cli v6 , everything worked as expected on both iOS and Android. With v5 it only worked on Android FYI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants