angularjs - Ionic BarcodeScanner does not work on ios -


i created ionic app, work on android good. barcode scanner not working correct in ios.

my code;

$cordovabarcodescanner.scan().then(function (barcodedata) {   console.log("data : "+barcodedata.text); }); 

but xcode giving me non-stop; enter image description here

when tried this;

  cordova.plugins.barcodescanner.scan(   function (result) {       alert("we got barcode\n" +             "result: " + result.text + "\n" +             "format: " + result.format + "\n" +             "cancelled: " + result.cancelled);   },    function (error) {       alert("scanning failed: " + error);   },   {       "preferfrontcamera" : true, // ios , android       "showflipcamerabutton" : true, // ios , android       "prompt" : "place barcode inside scan area", // supported on android       "formats" : "qr_code,pdf_417", // default: pdf_417 , rss_expanded       "orientation" : "landscape" // android (portrait|landscape), default unset rotates device   } }; 

getting error:

warning: attempt present <cdvbcsviewcontroller: 0x15f30c400> on <mainviewcontroller: 0x15dd4fab0> view not in window hierarchy! 

by doing i'm able scan qr code in ios.

  • add ios platform:

    ionic platform add ios 
  • install ngcordova

    bower install ngcordova 
  • added barcodescanner plugin this:

    cordova plugin add https://github.com/phonegap/phonegap-plugin-barcodescanner.git 
  • index.html

    <button class="button button-block button-positive" ng-click="scanbarcode()">       <i class="icon ion-qr-scanner"></i>       scan </button> 
  • app.js

    angular.module('myapp', ['ionic','ngcordova']) // include ngcordova  // scan  angular.module("myapp").controller('scanner',function($scope, $cordovabarcodescanner) { $scope.scanbarcode = function() { $cordovabarcodescanner.scan().then(function(imagedata) {     alert(imagedata.text);     console.log("barcode format -> " + imagedata.format);     console.log("cancelled -> " + imagedata.cancelled); }, function(error) {     console.log("an error happened -> " + error); }); }; }); 

my nodejs version : v5.5.0

phonegap version : 6.0.2

ionic version : 1.7.14


Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -

java - Digest auth with Spring Security using javaconfig -