Quentin
Quentin

Reputation: 3

Angular2 Ionic2 create plugin with cordova

I have created an angular 2 application with typescript and i have packaged it on an android apk and it works pretty well.

But i have an issue, i wish to create a plugin for ionic 2 with cordova because i didn't find a plugin that does what i want to do.

I downloaded plugman, created a new plugin but i have no idea how to make it works with my ionic application , i didn't find any tutorial on the subject just about cordova.

I have the plugin directory with a java file where i am supposed to implement my methods, the plugin.js that allows to send request to the native part but how to connect this javascript to my angular2/ionic2 application ? How to call it ?

Thanks everyone !

Upvotes: 0

Views: 254

Answers (1)

Hexiler
Hexiler

Reputation: 203

I think this tutorial will help you.

My examples, i copy the WavAudioEncoder.min.js library into my www folder, then i do the followings, it works well (as you can see on the tutorial link too)

declare var WavAudioEncoder: any;

var encoder = new WavAudioEncoder(this.captureCfg.sampleRate, this.captureCfg.channels);

Do not panic if the environment won't suggest you anything, when you use these plugins/libraries (eg in VSCode the cordova.file is not a function, it will say to you it is a simple variable which type is any)

declare var cordova: any;
this.filePath = cordova.file.externalDataDirectory;

Upvotes: 1

Related Questions