so i have got a simple button which should do some action (of course not at the same time )
so i also added this code in home.ts
import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import { Flashlight } from '@ionic-native/flashlight';
@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {
constructor(private flashlight: Flashlight) {}
flashlight(){
check = this.flashlight.isSwitchedOn();
alert(check);
}
}
The app is built without errors and i installed it on a xperia z1 compact and huawei p9 lite. the following behaviour is shown:
toggle-function - no effect
isSwitchedOn - always returns false
switchOn - fires once, but if i tried another time nothing happens. i have to deinstall the app and install it again to fire one more time - but only once again.
import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import { Platform } from 'ionic-angular';
import { Flashlight } from '@ionic-native/flashlight';
@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {
constructor(private flashlight: Flashlight,
private platform: Platform) {}
flashlight(){
this.flashlight.toggle();
this.platform.ready().then(() => {
var check = this.flashlight.isSwitchedOn();
alert(check);
});
}
}
would be nice if the note “platform.ready recommended” would be posted on the official docs but ok as long as there is an active community. thanks a lot. i´ll do more experiments with ionic and cordova