0
votes

ionic probleme in @ionic-native/base64/ngx

TypeError: Object(...) is not a function at Base64.encodeFile (vendor.js:79123) at main.js:183 at t.invoke (polyfills.js:3) at Object.onInvoke (vendor.js:5134) at t.invoke (polyfills.js:3) at r.run (polyfills.js:3) at polyfills.js:3 at t.invokeTask (polyfills.js:3) at Object.onInvokeTask (vendor.js:5125) at t.invokeTask (polyfills.js:3)

page.ts

import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams, AlertController, ToastController, ActionSheetController, LoadingController } from 'ionic-angular';
import { RestProvider } from '../../../providers/rest/rest';
import { DatePipe } from '@angular/common';
import { FilePath } from '@ionic-native/file-path';
import { FileChooser } from '@ionic-native/file-chooser';
//import { Base64 } from '@ionic-native/base64';
import { Base64 } from '@ionic-native/base64/ngx';
//import { Camera } from '@ionic-native/camera';
import { Camera } from '@ionic-native/camera/ngx';


/**
 * Generated class for the AlerteFinDroitDecesPage page.
 *
 * See https://ionicframework.com/docs/components/#navigation for more info on
 * Ionic pages and navigation.
 */

@IonicPage()
@Component({
  selector: 'page-alerte-fin-droit-deces',
  templateUrl: 'alerte-fin-droit-deces.html',
})
export class AlerteFinDroitDecesPage {

  constructor(public navCtrl: NavController,
    public navParams: NavParams,
    public Rest: RestProvider,
    public alertConroller: AlertController,
    public datepipe: DatePipe,
    public toastCtrl: ToastController,
    private fileChooser: FileChooser,
    public actionSheetCtrl: ActionSheetController,

    private filePath: FilePath,
    public base64: Base64,
    public camera:Camera,
    public loadingCtrl: LoadingController) {
  }

  ionViewDidLoad() {
    console.log('ionViewDidLoad AlertmariagePage');
  }

  getImage(){
    // choose your file from the device
    console.log("getImage");

    this.fileChooser.open().then(uri => {
    console.log("uri",uri);
        //alert('uri'+JSON.stringify(uri));
        // get file path
        this.filePath.resolveNativePath(uri)
        .then(file => {
      //alert('file'+JSON.stringify(file));
      console.log("file",file);
            let filePath: string = file;
            if (filePath) {
        this.base64.encodeFile(filePath).then((base64File: string) => {

            console.log("filePath",filePath);
            console.log("base64File",base64File);

            //alert('base64File'+JSON.stringify(base64File));

                }, (err) => {
          //alert('err'+JSON.stringify(err));
          console.log("err",err);
                });
            }
        })
        .catch(err => console.log(err));
    })
    .catch(e => alert('uri'+JSON.stringify(e)));
  }

}

please someone help

1
have you find the solution - Malik Rizwan
i am also facing the same issue - Malik Rizwan

1 Answers

0
votes

update your base64 node module version according to the plugin version. I resolved it by removing it from the node module and run npm install @ionic-native/[email protected]