Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI is not updating after scan result completed in Nativescript-angular #206

Open
monicaarepo opened this issue Jun 13, 2019 · 6 comments
Open

Comments

@monicaarepo
Copy link

monicaarepo commented Jun 13, 2019

I am developing android and ios app using nativescript-angular. I am using this plugin in my application. I have an issue after scan result completed the UI are not updated.
My code:

onScanResult(index,status){
     console.log("onScanResult :"+index);
     if(isAndroid){
         this.barcodeScanner.hasCameraPermission().then(
             function(granted) {
               // if this is 'false' you probably want to call 'requestCameraPermission' now
               console.log("Has Camera Permission? " + granted);
             }
         );
        
         // if no permission was granted previously this wil open a user consent screen
         this.barcodeScanner.requestCameraPermission().then(
             function() {
               console.log("Camera permission requested");
             }
         );
     }
     let that=this;
     this.barcodeScanner.scan({
         formats: "QR_CODE",
         cancelLabel: "EXIT. Also, try the volume buttons!",
         cancelLabelBackgroundColor: "#333333", 
         message: "Use the volume buttons for extra light", 
         showFlipCameraButton: true,
         preferFrontCamera: false,
         showTorchButton: true,
         beepOnScan: true,
         torchOn: false, 
         closeCallback: function () {
              console.log("Scanner closed"); 
         },

         orientation: "landscape",
         openSettingsIfPermissionWasPreviouslyDenied: true
     }).then((result) => {
           //UI update function
           this.CheckFunction();
       }, (errorMessage) => {
         console.log("No scan. " + errorMessage);
       }
     );
 }
Help me to fix the issue.
@EddyVerbruggen
Copy link
Owner

Have you tried wrapping that this.CheckFunction bit in a little timeout or ngzone?

@monicaarepo
Copy link
Author

I have tried timeout function but it was not working
My Code is:

 setTimeout(function(){
       this.CheckFunction()
  },3000);

any other solution

@EddyVerbruggen
Copy link
Owner

I gave you another suggestion actually :)

@monicaarepo
Copy link
Author

I have a listview when I click the particular list in the listview I will open the QRcode scanner and I will scan the QRcode, based on the QRcode result I will update the particular cell, but QRcode result is not updated my listview cell.

@EddyVerbruggen
Copy link
Owner

Did you try using NgZone per my suggestion? If so, please share a repo (playground would be best) that reproduces this.

@monicaarepo
Copy link
Author

ok, I will share my code in the playground.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants