These are chat archives for angular/angular-2-ionic-2

26th
Jul 2017
Jonathan Leek
@mrjonleek
Jul 26 2017 01:32
Hey guys... I've got an embarassing problem growing in my JSON area... Trying to install Geolocation and failing: [ERROR] Cordova encountered an error. │Untracked files: You may get more insight by running the Cordova command above directly. │ (use "git add <file>..." to include in what will be committed) │ [ERROR] An error occurred while running cordova plugin add cordova-plugin-geolocation --save (exit code 1): │ src/components/auth/ │ src/providers/location/ │ src/providers/merchant/ You have been opted out of telemetry. To change this, run: cordova telemetry on. │ Error: Failed to fetch plugin cordova-plugin-geolocation via registry. │no changes added to commit (use "git add" and/or "git commit -a") Probably this is either a connection problem, or plugin spec is incorrect. │ Check your connection and plugin name/version/URL. │ Error: npm: Command failed with exit code 1 Error output: │ npm ERR! Unexpected token < in JSON at position 49903 │ │ npm ERR! A complete log of this run can be found in: │ npm ERR! /Users/mrjonleek/.npm/_logs/2017-07-26T01_20_47_477Z-debug.log
Story5
@Story5
Jul 26 2017 01:34

@UncertaintyP No Camera preview show after i call the qrscanner.show().
I post the code blow.I search the problem and got one solution works for others to set the body transparent.So I set <ion-content padding background-color:transparent>,but it’s not work for me.
html

 <ion-header>
  <ion-navbar>
    <ion-title>
      Ionic Blank
    </ion-title>
  </ion-navbar>
</ion-header>

<ion-content padding background-color:transparent>
  The world is your oyster.
  <p>
    If you get lost, the <a href="http://ionicframework.com/docs/v2">docs</a> will be your guide.
  </p>
  <button ion-button (click)="qrscanner()">qrscanner</button>
</ion-content>

ts

import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';

import { AndroidPermissions } from '@ionic-native/android-permissions';
import { QRScanner, QRScannerStatus } from '@ionic-native/qr-scanner';

@Component({
  selector: 'page-home',
  templateUrl: 'home.html'
})
export class HomePage {

  constructor(public navCtrl: NavController,
              public androidPermissions: AndroidPermissions,
              public qrScanner: QRScanner) {

  }

  qrscanner() {

    // Optionally request the permission early
    this.qrScanner.prepare()
      .then((status: QRScannerStatus) => {
        if (status.authorized) {
          // camera permission was granted
          alert('authorized');

          // start scanning
          let scanSub = this.qrScanner.scan().subscribe((text: string) => {
            console.log('Scanned something', text);
            alert(text);
            this.qrScanner.hide(); // hide camera preview
            scanSub.unsubscribe(); // stop scanning
          });

          this.qrScanner.resumePreview();

          // show camera preview
          this.qrScanner.show();

          // wait for user to scan something, then the observable callback will be called

        } else if (status.denied) {
          alert('denied');
          // camera permission was permanently denied
          // you must use QRScanner.openSettings() method to guide the user to the settings page
          // then they can grant the permission from there
        } else {
          // permission was denied, but not permanently. You can ask for permission again at a later time.
          alert('else');
        }
      })
      .catch((e: any) => {
        alert('Error is' + e);
      });
  }
}
Story5
@Story5
Jul 26 2017 02:26
how to set the ion-content background to transparent
UncertaintyP
@UncertaintyP
Jul 26 2017 03:45
@Story5 Oh sorry I'm actually using the @ionic-native/barcode-scanner package
Because it is native you don't need to mess with page transparencies or the like
Story5
@Story5
Jul 26 2017 04:07
@UncertaintyP I used barcode-scanner and it works for me.But I dont find way to embed ionic project with barcode-scanner plugin into android native.
Story5
@Story5
Jul 26 2017 04:13
AnyOne can help?I ask on stackoverflow too.
UncertaintyP
@UncertaintyP
Jul 26 2017 04:22
This can be related to not having camera permissions on phone
You should debug your android build to see whats going on
Story5
@Story5
Jul 26 2017 07:24
I test the plugin, and I find it can scan qrcode and gain the text, but no camera preview. So the exact way is to set the ion-content background transparent. How to set it?AnyOne know?
Story5
@Story5
Jul 26 2017 09:30
@UncertaintyP did according to it but not work. Strangely