Property 'initializePreview' does not exist on type 'HomePage'


#1

Hi, i have a problem with this code:

import { Component } from ‘@angular/core’;
import { NavController, ToastController } from ‘ionic-angular’;
import { Diagnostic } from ‘@ionic-native’;
import { CameraPreview, CameraPreviewRect } from ‘ionic-native’;

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

constructor(public navCtrl: NavController,
public toastCtrl: ToastController ) {
this.checkPermissions();
}

checkPermissions() {
Diagnostic.isCameraAuthorized().then((authorized) => {
if(authorized)
this.initializePreview();
else {
Diagnostic.requestCameraAuthorization().then((status) => {
if(status == Diagnostic.permissionStatus.GRANTED)
this.initializePreview();
else {
// Permissions not granted
// Therefore, create and present toast
this.toastCtrl.create(
{
message: “Cannot access camera”,
position: “bottom”,
duration: 5000
}
).present();
}
});
}
});

}

}

give me 2 errors:
[error] typescript: src/pages/home/home.ts, line: 21
Property ‘initializePreview’ does not exist on type ‘HomePage’.

  L20:  if(authorized)
  L21:      this.initializePreview();
  L22:  else {

[error] typescript: src/pages/home/home.ts, line: 25
Property ‘initializePreview’ does not exist on type ‘HomePage’.

  L24:  if(status == Diagnostic.permissionStatus.GRANTED)
  L25:      this.initializePreview();
  L26:  else {

thanks.


#2

Instead of trying to fix this as is, I would strongly recommend you upgrade to the latest version of the ionic-native stuff, which has different syntax and makes for much smaller app binaries.


#3

my configuration:

cli packages: (/usr/local/lib/node_modules)

@ionic/cli-utils  : 1.10.2
ionic (Ionic CLI) : 3.10.3

global packages:

Cordova CLI : not installed

local packages:

@ionic/app-scripts : 2.1.4
Cordova Platforms  : none
Ionic Framework    : ionic-angular 3.6.1

System:

Node  : v8.5.0
npm   : 5.3.0 
OS    : OS X Yosemite
Xcode : Xcode 7.0.1 Build version 7A1001 

How update the ionic-native at level 3???


#4

Edit package.json and run npm i.