{"action":"created","issue":{"url":"https://api.github.com/repos/bitpay/cordova-plugin-qrscanner/issues/121","repository_url":"https://api.github.com/repos/bitpay/cordova-plugin-qrscanner","labels_url":"https://api.github.com/repos/bitpay/cordova-plugin-qrscanner/issues/121/labels{/name}","comments_url":"https://api.github.com/repos/bitpay/cordova-plugin-qrscanner/issues/121/comments","events_url":"https://api.github.com/repos/bitpay/cordova-plugin-qrscanner/issues/121/events","html_url":"https://github.com/bitpay/cordova-plugin-qrscanner/issues/121","id":259882796,"number":121,"title":"THREAD WARNING: ['QRScanner'] took '468.501953' ms. Plugin should use a background thread.","user":{"login":"m1xf1t","id":6165135,"avatar_url":"https://avatars2.githubusercontent.com/u/6165135?v=4","gravatar_id":"","url":"https://api.github.com/users/m1xf1t","html_url":"https://github.com/m1xf1t","followers_url":"https://api.github.com/users/m1xf1t/followers","following_url":"https://api.github.com/users/m1xf1t/following{/other_user}","gists_url":"https://api.github.com/users/m1xf1t/gists{/gist_id}","starred_url":"https://api.github.com/users/m1xf1t/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/m1xf1t/subscriptions","organizations_url":"https://api.github.com/users/m1xf1t/orgs","repos_url":"https://api.github.com/users/m1xf1t/repos","events_url":"https://api.github.com/users/m1xf1t/events{/privacy}","received_events_url":"https://api.github.com/users/m1xf1t/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2017-09-22T17:23:11Z","updated_at":"2018-05-17T19:39:10Z","closed_at":"2018-05-17T19:39:10Z","author_association":"NONE","body":"Hi there,\r\n\r\nI'm having issues using the QR Scanner with Ionic.\r\n\r\n## **ERROR OUTPUT:**\r\n`THREAD WARNING: ['QRScanner'] took '468.501953' ms. Plugin should use a background thread.`\r\n\r\n\r\n## **App Module:**\r\n> /src/app/app.module.ts\r\n\r\n```javascript import { BrowserModule } from '@angular/platform-browser';\r\nimport { ErrorHandler, NgModule } from '@angular/core';\r\nimport { IonicApp, IonicErrorHandler, IonicModule } from 'ionic-angular';\r\nimport { SplashScreen } from '@ionic-native/splash-screen';\r\nimport { StatusBar } from '@ionic-native/status-bar';\r\nimport { QRScanner } from '@ionic-native/qr-scanner';\r\n\r\nimport { MyApp } from './app.component';\r\nimport { HomePage } from '../pages/home/home';\r\n\r\n@NgModule({\r\n  declarations: [\r\n    MyApp,\r\n    HomePage\r\n  ],\r\n  imports: [\r\n    BrowserModule,\r\n    IonicModule.forRoot(MyApp)\r\n  ],\r\n  bootstrap: [IonicApp],\r\n  entryComponents: [\r\n    MyApp,\r\n    HomePage\r\n  ],\r\n  providers: [\r\n    StatusBar,\r\n    SplashScreen,\r\n    QRScanner,\r\n    {provide: ErrorHandler, useClass: IonicErrorHandler}\r\n  ]\r\n})\r\nexport class AppModule {}\r\n```\r\n\r\n## **Markup**\r\n> /pages/home/home.html\r\n\r\n\r\n```html <ion-header>\r\n  <ion-navbar>\r\n    <ion-title>\r\n      App\r\n    </ion-title>\r\n  </ion-navbar>\r\n</ion-header>\r\n\r\n<ion-content padding>\r\n  <button ion-button full (click)=\"scanTickets()\">Scan Tickets</button>\r\n</ion-content>\r\n```\r\n## **Home Typescript**\r\n>/pages/home/home.ts\r\n\r\n```javascript import { Component } from '@angular/core';\r\nimport { NavController, AlertController } from 'ionic-angular';\r\nimport { QRScanner, QRScannerStatus } from '@ionic-native/qr-scanner';\r\n\r\n\r\n@Component({\r\n  selector: 'page-home',\r\n  templateUrl: 'home.html'\r\n})\r\nexport class HomePage {\r\n\r\n  constructor(\r\n    public navCtrl: NavController, \r\n    public alertCtrl: AlertController,\r\n    private qrScanner: QRScanner) {\r\n\r\n  }\r\n\r\n  scanTickets() {\r\n    // Optionally request the permission early\r\n    this.qrScanner.prepare()\r\n    .then((status: QRScannerStatus) => {\r\n      if (status.authorized) {\r\n        // camera permission was granted\r\n\r\n\r\n        // start scanning\r\n        let scanSub = this.qrScanner.scan().subscribe((text: string) => {\r\n          console.log('Scanned something', text);\r\n\r\n          this.qrScanner.hide(); // hide camera preview\r\n          scanSub.unsubscribe(); // stop scanning\r\n        });\r\n\r\n        // show camera preview\r\n        this.qrScanner.show();\r\n\r\n        // wait for user to scan something, then the observable callback will be called\r\n\r\n      } else if (status.denied) {\r\n        // camera permission was permanently denied\r\n        // you must use QRScanner.openSettings() method to guide the user to the settings page\r\n        // then they can grant the permission from there\r\n      } else {\r\n        // permission was denied, but not permanently. You can ask for permission again at a later time.\r\n      }\r\n    })\r\n    .catch((e: any) => console.log('Error is', e));\r\n  } \r\n}\r\n```\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/bitpay/cordova-plugin-qrscanner/issues/comments/389984662","html_url":"https://github.com/bitpay/cordova-plugin-qrscanner/issues/121#issuecomment-389984662","issue_url":"https://api.github.com/repos/bitpay/cordova-plugin-qrscanner/issues/121","id":389984662,"user":{"login":"bitjson","id":904007,"avatar_url":"https://avatars3.githubusercontent.com/u/904007?v=4","gravatar_id":"","url":"https://api.github.com/users/bitjson","html_url":"https://github.com/bitjson","followers_url":"https://api.github.com/users/bitjson/followers","following_url":"https://api.github.com/users/bitjson/following{/other_user}","gists_url":"https://api.github.com/users/bitjson/gists{/gist_id}","starred_url":"https://api.github.com/users/bitjson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bitjson/subscriptions","organizations_url":"https://api.github.com/users/bitjson/orgs","repos_url":"https://api.github.com/users/bitjson/repos","events_url":"https://api.github.com/users/bitjson/events{/privacy}","received_events_url":"https://api.github.com/users/bitjson/received_events","type":"User","site_admin":false},"created_at":"2018-05-17T19:39:10Z","updated_at":"2018-05-17T19:39:10Z","author_association":"MEMBER","body":"PRs welcome! \r\n\r\nThere are some changes in [2.6.0](https://github.com/bitpay/cordova-plugin-qrscanner/blob/master/CHANGELOG.md#260-2018-05-17) which may help here. If you're still having trouble, please feel free to open a new issue."}}
{"actor":{"display_login":"bitjson"}}