Local barcode scanner help


#1

I’m trying to use the barcode scanner locally, but am not getting anything, wondering if anyone can point me in the right direction?

What I did:

In the App cloud settings I navigated to -> "Open build service"
Then I navigated to “Configure” under the iOS tab
and in this view I added:

[
{“source”:“https://github.com/AppGyver/BarcodeScanner.git”}
]

under plugin configuration.

My understanding is that the barcodescanner plugin should be injected on load, and I should have the plugin available for use.

I have a button hooked up to fire the below function on press (with or without the window in front):

window.cordova.plugins.barcodeScanner.scan(
function(result){","
supersonic.logger.log(‘Woohooo’);
},
function(error){
supersonic.logger.log(‘Failure’)
}
);

but I’m not getting anything to happen.


#2

Whelp, I’m an idiot. Just got it working, immediately after my forum posting of course. For those curious I modified the

cordova.plugins.barcodeScanner.scan(
function(result){
supersonic.logger.log(‘Woohooo’);
},
function(error){
supersonic.logger.log(‘You have forgotten the face of your father’)
}
);

to

function fire(){
cordova.plugins.barcodeScanner.scan(
function(result){
supersonic.logger.log(‘Woohooo’);
},
function(error){
supersonic.logger.log(‘You have forgotten the face of your father’)","
}
);
}

made it available outside the scope of the controller, and changed the button onClick event to fire()

  <button class="button button-full button-positive" onClick="fire()">Logger</button>

It works beautifully


#3

I just had a question regarding the installation of this plugin since I’m having trouble with this. I followed the steps of including a custom plugin by adding the link to the source in the build services. The part I’m stuck on is where I have to to manually include a <script> tag in my HTML to load the JavaScript file. What link do I use for the src? This is what goes in the layout.html file.


#4

Hey ozair, if I recall correctly you don’t need to have any files sourced in your code, the cloud build will take care of including all of your dependencies and the api should just “work”. I’m away from my desk but will double check and post back shortly


#5

Just confirmed in my source code, there isn’t anywhere you need to add a

 to include the plugin. The cloud build will do it for you