This commit is contained in:
Viktor Søndergaard 2019-04-07 05:01:01 +02:00
parent f0b568b3fb
commit dd13101bcb
2 changed files with 15 additions and 0 deletions

3
client/Nightr/reference.d.ts vendored Normal file
View File

@ -0,0 +1,3 @@
/// <reference path="./node_modules/tns-platform-declarations/ios.d.ts" />
/// <reference path="./node_modules/tns-platform-declarations/android.d.ts" />
/// <reference path="./node_modules/tns-platform-declarations/android-24.d.ts" />

View File

@ -7,6 +7,18 @@ import { ios as iosUtils } from "tns-core-modules/utils/utils";
})
export class MyBatteryInfoService {
/* public getBatteryLife() {
// use tns-platform-dclarations to access native APIs (e.g. android.content.Intent)
applicationModule.android.registerBroadcastReceiver(
android.content.Intent.ACTION_BATTERY_CHANGED,
(androidContext, intent) => {
const level = intent.getIntExtra(android.os.BatteryManager.EXTRA_LEVEL, -1);
const scale = intent.getIntExtra(android.os.BatteryManager.EXTRA_SCALE, -1);
const percent = (level / scale) * 100.0;
vm.set("batteryLife", percent.toString());
});
} */
/*public getBatteryLife() {
if (iosApp){
iosUtils.getter(UIDevice, UIDevice.currentDevice).batteryMonitoringEnabled = true;