Cordova plugin installation


#1

Hello,

I am trying to install a plugin in my Ionic app:

It is supposed to work with just the first two lines - adding the plugin and copying the library - then serial.requestPermission() etc… However, when I run the app on the device ‘serial’ is undefined and I can’t use it.

I’ve been trying to make this work for a while. No progress at all. Can someone help, pls?


#2

when do you call serial.requestPermission()?


#3

In the controller, after cordova.js is loaded.

I do ‘ionic run android’ and then try to print ‘serial’ or ‘serial.read’ on the device display, just to see if the ‘serial’ object exists.


#4

I’m bumping this since there is no indication the OP ever solved his problem.
I found this link https://github.com/xseignard/cordovarduino/issues/12
According to the link the poster eventually solved his problem.
I’m quoting the relevant text FFR.

The 'serial' is available in module -> .run(...$ionicPlatform.ready()...,which is the default config for a starting Ionic project. I did smthg like document.write(serial.read) in that scope and missed it:), but with an alert(), on the device, it was visible. Then injected $rootScope and attached the object to it so it can be used from the controllers. Not sure if the $rootScope part is a good solution, but I am happy with it right now.

Handy info to have.