Finally, I managed to use my non-native plugin very easily :
1) Just do the usual :
cordova plugin add <repo/name>
2) and use your plugin
window.plugins.yourplugin.someMethod()
In order to access to “window.plugins
” with TypeScript you have to add a definition :
in :
typings/globals/window/index.d.ts
(create “window
” folder and “index.d.ts
” file)
and write in index.d.ts
:
interface Window {
plugins: any;
}
This allows you to use “window.plugins” with typescript.
Don’t forget to call your plugin after the device is ready with platform.ready()
:
import { Platform } from 'ionic-angular';
[...]
constructor(platform: Platform) {
platform.ready().then(() => {
window.plugins.yourplugin.someMethod()
});
Sources :
http://www.joshmorony.com/using-cordova-plugins-in-ionic-2-with-ionic-native/