apache / apache/cordova-plugin-inappbrowser
InAppBrowser plugin installation - ERROR ReferenceError: cordova is not defined
- Dominant language
- Java
- Stars
- 1.1k
- Forks
- 2.2k
- PR merge metrics
- No merged PRs in 30d
Description
# Bug Report
## Problem
### What is expected to happen?
I'm trying to get the InAppBrowser function up and working on my Ionic App. I'm following the steps on the page 'https://github.com/apache/cordova-plugin-inappbrowser.' The only installation step it says to do is run 'cordova plugin add cordova-plugin-inappbrowser.' Then it begins discussing basic operations on starting the inAppBrowser.
My code is
```
var ref = cordova.InAppBrowser.open('www.google.com', '_blank')
```
I would expect this to open up the Google website in my Ionic Lab Android platform emulator.
### What does actually happen?
Instead, I get the error: 'ERROR ReferenceError: cordova is not defined'. Someone else posted a similar question, and the suggested solution was to add a Script tag: ' ' to their index.html file. That didn't work for me - but I wonder why that was even suggested. I didn't install any other packages/run any other commands besides the 'cordova plugin add cordova-plugin-inappbrowser' stated at the top of the Github docs on the InAppBrowser page. What am I missing?
## Information
### Command or Code
```
cordova plugin add cordova-plugin-inappbrowser.
var ref = cordova.InAppBrowser.open('www.google.com', '_blank')
```
### Version information
```
Ionic:
Ionic CLI : 5.4.16 (/usr/local/lib/node_modules/ionic)
Ionic Framework : @ionic/angular 5.0.7
@angular-devkit/build-angular : 0.803.26
@angular-devkit/schematics : 8.3.26
@angular/cli : 8.3.26
@ionic/angular-toolkit : 2.2.0
Capacitor:
Capacitor CLI : 2.0.2
@capacitor/core : 2.0.2
Cordova:
Cordova CLI : 9.0.0 (cordova-lib@9.0.1)
Cordova Platforms : android 8.1.0, ios 5.1.1
Cordova Plugins : cordova-plugin-device 2.0.2 "Device"
cordova-plugin-inappbrowser 3.2.0 "InAppBrowser"
cordova-plugin-ionic-keyboard 2.2.0 "cordova-plugin-ionic-keyboard"
cordova-plugin-ionic-webview 4.2.1 "cordova-plugin-ionic-webview"
cordova-plugin-splashscreen 5.0.2 "Splashscreen"
cordova-plugin-statusbar 2.4.2 "StatusBar"
cordova-plugin-whitelist 1.3.3 "Whitelist"
Utility:
cordova-res : not installed
native-run : 1.0.0
System:
ios-sim : 8.0.2
NodeJS : v12.16.1 (/usr/local/bin/node)
npm : 6.14.3
OS : macOS Catalina
Xcode : Xcode 11.3.1 Build version 11C504
```
## Checklist
- [x] I searched for existing GitHub issues
- [ ] I updated all Cordova tooling to most recent version
- [x] I included all the necessary information above
Contributor guide
Research direction
Start with the InAppBrowser installation and usage documentation, then inspect the Ionic app's index.html and the reported cordova.InAppBrowser.open call in the Android emulator context. Reproduce the ReferenceError and determine whether the documented invocation applies to this setup; done means the cause and supported usage are clearly identified.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100