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

in-app-browser: error WEBPACK_IMPORTED_MODULE_2__.InAppBrowser.create is not a function #4754

Open
Homand-Cindy opened this issue Apr 9, 2024 · 5 comments

Comments

@Homand-Cindy
Copy link

I am using the InAppBrowser plugin in my Ionic/Angular standalone application and when the create function is called, I get this error:
awesome_cordova_plugins_in_app_browser_ngx__WEBPACK_IMPORTED_MODULE_2_.InAppBrowser.create is not a function

This is my code:

import { InAppBrowser, InAppBrowserObject } from '@awesome-cordova-plugins/in-app-browser/ngx';
let browser: InAppBrowserObject = InAppBrowser.create(url, '_blank', "location=no,clearsessioncache=yes,clearcache=yes");

I've already searched the forums but I can't find another developer who has the same error. Can you help me, please?

@MaximBelov
Copy link
Contributor

MaximBelov commented Apr 17, 2024

import { InAppBrowser, InAppBrowserObject, InAppBrowserOptions } from '@awesome-cordova-plugins/in-app-browser/ngx';

class InAppBrowserService{
  private browser: InAppBrowserObject;

  constructor( private readonly inAppBrowser: InAppBrowser  ) {}
  
  private async openWithInAppBrowser(url: string, config: InAppBrowserOptions) {
     this.browser = this.inAppBrowser.create(url, '_blank', config);
     ....
  }
}

  
  

@Homand-Cindy
Copy link
Author

Thank you for your response.
It's not possible to add InAppBrowser in the constructor, I have this error:
"InAppBrowser' refers to a value, but is being used as a type here."
I use the version 6.7.0 with cordova-plugin-inappbrowser 6.0.0.

@MaximBelov
Copy link
Contributor

please provide your package.json

@Homand-Cindy
Copy link
Author

package.json

@MaximBelov
Copy link
Contributor

Maybe the current version does not support the latest angular 17+
I can't check it now; maybe later

Suggestions for now:

  1. Use non-angular version (without ngx)
    import { InAppBrowser, InAppBrowserObject } from '@awesome-cordova-plugins/in-app-browser';

2 Do not use @awesome-cordova-plugins/in-app-browser and create service for wrap cordova-plugin-inappbrowser plugin

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

2 participants