0
votes

I'm using an Ionic2 Angular2 setup with inappbrowser cordova plugin installed. According to documentation I have to use window.cordova.InAppBrowser.open("whatever)

However, window.cordova does not compile as the propery "cordova" does not exist on the Window type.

I've installed it by using cordova plugin add cordova-plugin-inappbrowser and the plugin was added succesfully in the plug-in folder.

What am I missing here?

3
How are you testing this (browser, emulator, device)? - ankur
Browser, but either way it doesn't matter because it doesn't compile. - Halaster
Have you found a solution yet? If not, could you please post your code and the exact error message? - ankur

3 Answers

0
votes

I did not double check that, but I guess the typings file does not contain the method window.cordova.InAppBrowser.open("whatever"). Write your own typing interface or use window.open()

0
votes

I'm not familiar with this but I solved this problem by installing typings :

npm install -g typings

typings install dt~cordova --save --global

https://forum.ionicframework.com/t/cannot-find-name-cordova/52650/3

But now InApp is missing ...

-1
votes

Cordova will not load in the browser. Your best option is to use a device to test and chrome/safari (depending on platform) dev tools to debug. You can also try an emulator depending on the plugins you are using, but there are some plugins that will not work properly in the emulator.

Also, be sure to wrap any cordova plugins in a device ready function such as:

document.addEventListener("deviceready", onDeviceReady, false);

function onDeviceReady() {
    // Now safe to use device APIs
}

or

$ionicPlatform.ready(function() {
    // your code
});

Reference: deviceready and $ionicPlatform.ready().