How to use ionic-native - 10 common examples

To help you get started, we’ve selected a few ionic-native examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github YourName-App / MyDiary / src / app / app.component.js View on Github external
platform.ready().then(function () {
            // Here you can do any higher level native things you might need.
            StatusBar.styleDefault();
            Splashscreen.hide();
            _this.configServ.setMusicPlayed(false);
            // Listen for pause event (emits when the native platform puts the application into the background)
            platform.pause.subscribe(function () {
                _this.configServ.setPauseEmitted('Y');
                if (_this.configServ.getUserPin().length >= 4) {
                    _this.nav.setRoot(HomePage);
                }
            });
        }, function (error) {
            console.log(error);
github crabcanon / angular2-ionic2-demo / src / app / app.component.ts View on Github external
platform.ready().then(() => {
      // Okay, so the platform is ready and our plugins are available.
      // Here you can do any higher level native things you might need.
      StatusBar.styleDefault();
      Splashscreen.hide();
      BackgroundMode.disable();


      if (platform.is('ios')) {
        window['plugins'].sqlDB.remove('data.db', 2, this.removeDBSucceeded, this.removeDBFailed);
        window['plugins'].sqlDB.copy('data.db', 2, this.copyDBSucceeded, this.copyDBFailed);
      } else if (platform.is('android')) {
        window['plugins'].sqlDB.remove('data.db', 0, this.removeDBSucceeded, this.removeDBFailed);
        window['plugins'].sqlDB.copy('data.db', 0, this.copyDBSucceeded, this.copyDBFailed);
      } else {
        this.presentAlert(this.databseAlert);
      }
      
      this.events.subscribe('auth:customizedExpiration', (time) => {
        console.log('User is automatically logged out at ' + time);
        this.presentAlert(this.sessionAlert);
github YourName-App / MyDiary / src / app / app.component.ts View on Github external
platform.ready().then(() => {
      // Here you can do any higher level native things you might need.
      StatusBar.styleDefault();
      Splashscreen.hide();
      this.configServ.setMusicPlayed(false);

      // Listen for pause event (emits when the native platform puts the application into the background)
      platform.pause.subscribe(() => {
        this.configServ.setPauseEmitted('Y');

        if (this.configServ.getUserPin().length >= 4) {
          this.nav.setRoot(HomePage);
        }
      });
    }, (error) => {
      console.log(error);
github lockeyo / Graphcool-Ionic-Instagram-Clone / src / pages / camera / camera.ts View on Github external
makePicture(){
      // refresh page here
      Camera.getPicture({
        destinationType: Camera.DestinationType.FILE_URI,
        targetWidth: 1000,
        targetHeight: 1000
      }).then((imageData) => {
        // imageData is a base64 encoded string
        // console.log(imageData);
        // var img64 = "data:image/jpeg;base64," + imageData;
        this.postFile(imageData);
      }, (err) => {
        console.log(err);
      });
    }
}
github aaronksaunders / firebaseStorage2 / src / pages / home / home.ts View on Github external
doGetPicture() {

  // TODO:
  // get picture from camera

  console.log(Device)
  let imageSource = (Device.isVirtual ? Camera.PictureSourceType.PHOTOLIBRARY : Camera.PictureSourceType.CAMERA);

  Camera.getPicture({
    destinationType: Camera.DestinationType.FILE_URI,
    sourceType: imageSource,
    targetHeight: 640,
    correctOrientation: true
  }).then((_imagePath) => {
    alert('got image path ' + _imagePath);
    // convert picture to blob
    return this.makeFileIntoBlob(_imagePath);
  }).then((_imageBlob) => {
    alert('got image blob ' + _imageBlob);

    // upload the blob
    return this.uploadToFirebase(_imageBlob);
  }).then((_uploadSnapshot: any) => {
    alert('file uploaded successfully  ' + _uploadSnapshot.downloadURL);

    // store reference to storage in database
github thomasgazzoni / ng2-platform / src / camera / camera.ionic.ts View on Github external
.create((observer: Observer) => {

                const cameraOptions: CameraOptions = {
                    quality: 50,
                    destinationType: options && options.returnBase64 ? Camera.DestinationType.DATA_URL : Camera.DestinationType.FILE_URI,
                    sourceType: Camera.PictureSourceType.CAMERA,
                    encodingType: Camera.EncodingType.JPEG,
                    correctOrientation: true,
                    // saveToPhotoAlbum: false,
                };

                this.setOptions(cameraOptions, options);

                Camera.getPicture(cameraOptions)
                    .then((imageData) => {

                        // imageData is either a base64 encoded string or a file URI
                        // If it's base64:
                        // let base64Image = 'data:image/jpeg;base64,' + imageData;

                        // console.debug('imageData', imageData);
github lockeyo / Graphcool-Ionic-Instagram-Clone / src / pages / camera / camera.ts View on Github external
makePicture(){
      // refresh page here
      Camera.getPicture({
        destinationType: Camera.DestinationType.FILE_URI,
        targetWidth: 1000,
        targetHeight: 1000
      }).then((imageData) => {
        // imageData is a base64 encoded string
        // console.log(imageData);
        // var img64 = "data:image/jpeg;base64," + imageData;
        this.postFile(imageData);
      }, (err) => {
        console.log(err);
      });
    }
}
github thomasgazzoni / ng2-platform / src / camera / camera.ionic.ts View on Github external
.create((observer: Observer) => {

                const cameraOptions: CameraOptions = {
                    quality: 50,
                    destinationType: options && options.returnBase64 ? Camera.DestinationType.DATA_URL : Camera.DestinationType.FILE_URI,
                    sourceType: Camera.PictureSourceType.CAMERA,
                    encodingType: Camera.EncodingType.JPEG,
                    correctOrientation: true,
                    // saveToPhotoAlbum: false,
                };

                this.setOptions(cameraOptions, options);

                Camera.getPicture(cameraOptions)
                    .then((imageData) => {

                        // imageData is either a base64 encoded string or a file URI
                        // If it's base64:
                        // let base64Image = 'data:image/jpeg;base64,' + imageData;

                        // console.debug('imageData', imageData);
github aaronksaunders / firebaseStorage2 / src / pages / home / home.ts View on Github external
doGetPicture() {

  // TODO:
  // get picture from camera

  console.log(Device)
  let imageSource = (Device.isVirtual ? Camera.PictureSourceType.PHOTOLIBRARY : Camera.PictureSourceType.CAMERA);

  Camera.getPicture({
    destinationType: Camera.DestinationType.FILE_URI,
    sourceType: imageSource,
    targetHeight: 640,
    correctOrientation: true
  }).then((_imagePath) => {
    alert('got image path ' + _imagePath);
    // convert picture to blob
    return this.makeFileIntoBlob(_imagePath);
  }).then((_imageBlob) => {
    alert('got image blob ' + _imageBlob);

    // upload the blob
    return this.uploadToFirebase(_imageBlob);
  }).then((_uploadSnapshot: any) => {
github lockeyo / Graphcool-Ionic-Instagram-Clone / src / pages / camera / camera.ts View on Github external
postFile(targetPathURL){
      // new Transfer
      const fileTransfer = new Transfer();

      // URL
      var urlTo = "https://api.graph.cool/file/v1/ciz5dctr01prd015261q0o8jd";

      // File for Upload
      var targetPath = targetPathURL;

      // File name only
      var extension = targetPath.split(".").pop();
      var filepart = "image";
      var filename = filepart + "." + extension;

      var options = {
                      fileKey: "data",
                      fileName: filename,
                      chunkedMode: false,