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

Missing documentation how to use this with Typescript (ionic 2) #14

Closed
RoelRoel opened this issue Jan 5, 2017 · 4 comments
Closed

Missing documentation how to use this with Typescript (ionic 2) #14

RoelRoel opened this issue Jan 5, 2017 · 4 comments

Comments

@RoelRoel
Copy link

RoelRoel commented Jan 5, 2017

Are there Typescript typings available?
Now i'm getting a lot of Property 'cordova' does not exist on type 'Window' errors when trying to call window.cordova.plugins.firebase.analytics.*

@FdezRomero
Copy link
Contributor

Use declare var window; after your imports and Typescript won't complain anymore about properties inside window.

@Cempakers87
Copy link

@FdezRomero I use ionic 2 as well and have already followed your suggestion. When I build and emulate my project, there is no error. But if I run command ionic serve, it getting error like:
EXCEPTION: Uncaught (in promise): TypeError: Cannot read property 'plugins' of undefined

Please help.

@FdezRomero
Copy link
Contributor

@Cempakers87 that's because Cordova plugins normally don't run in the browser (there are a few exceptions).

It's good practice when you are using any plugin to check if the app is running in Cordova and that has initialized. Wrap your calls like this (assuming you already imported and injected Platform in the constructor):

if (this.platform.is('cordova')) {
  this.platform.ready().then(() => {
    // Put your plugin calls here
  });
}

@oddcb
Copy link

oddcb commented Jun 30, 2017

You are probably aware, but this plugin has been added to Ionic Native, so typings are available if you add the Ionic Native plugin.

http://ionicframework.com/docs/native/firebase-analytics/

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

5 participants