From 9b7db588a1f7608e7a7c9e8b4db7951dc98bd816 Mon Sep 17 00:00:00 2001 From: Fedello Date: Mon, 5 Apr 2021 23:28:39 +0200 Subject: [PATCH] feat(power-optimization): plugin initial wrapper (#3642) * feat(power-optimization): plugin initial wrapper * fix(power-optimization): Sync methods --- .../plugins/power-optimization/index.ts | 95 +++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 src/@ionic-native/plugins/power-optimization/index.ts diff --git a/src/@ionic-native/plugins/power-optimization/index.ts b/src/@ionic-native/plugins/power-optimization/index.ts new file mode 100644 index 0000000000..c2f9d4cff8 --- /dev/null +++ b/src/@ionic-native/plugins/power-optimization/index.ts @@ -0,0 +1,95 @@ +import { Injectable } from '@angular/core'; +import { Cordova, IonicNativePlugin, Plugin } from '@ionic-native/core'; +/** + * @name Power Optimization + * @description + * Android Custom Roms made sometimes your apps unfunctional due to being killed in the background, notification messages do not appearing or your services being killed by agressive power saving mode. + * The Power Optimization plugin give you android PowerManager methods with cordova. + * + * @usage + * ```typescript + * import { PowerOptimization } from '@ionic-native/power-optimization/ngx'; + * + * constructor(private powerOptimization: PowerOptimization) { } + * + * ... + * + * this.powerOptimization.IsIgnoringBatteryOptimizations() + * .then(onSuccess) + * .catch(onError); + * + * ``` + */ +@Plugin({ + pluginName: 'PowerOptimization', + plugin: 'cordova-plugin-power-optimization', + pluginRef: 'cordova.plugins.PowerOptimization', + repo: 'https://github.com/snt1017/cordova-plugin-power-optimization', + platforms: ['Android'], +}) +@Injectable() +export class PowerOptimization extends IonicNativePlugin { + /** + * Check if the battery optimization is ignoring + * For more info, please check https://github.com/snt1017/cordova-plugin-power-optimization + * @returns {Promise} + */ + @Cordova({ sync: true }) + IsIgnoringBatteryOptimizations(): Promise { + return; + } + /** + * Request permisson to ignore optimizations: + * For more info, please check https://github.com/snt1017/cordova-plugin-power-optimization + * @returns {Promise} + */ + @Cordova({ sync: true }) + RequestOptimizations(): Promise { + return; + } + /** + * Go to battery optimizations configurations menu: + * For more info, please check https://github.com/snt1017/cordova-plugin-power-optimization + * @returns {Promise} + */ + @Cordova({ sync: true }) + RequestOptimizationsMenu(): Promise { + return; + } + /** + * Check if have any data restrictions in background: + * For more info, please check https://github.com/snt1017/cordova-plugin-power-optimization + * @returns {Promise} + */ + @Cordova({ sync: true }) + IsIgnoringDataSaver(): Promise { + return; + } + /** + * Go to data restrictions in background configurations menu: + * For more info, please check https://github.com/snt1017/cordova-plugin-power-optimization + * @returns {Promise} + */ + @Cordova({ sync: true }) + RequestDataSaverMenu(): Promise { + return; + } + /** + * Check if have another battery restriction is present into phone (like huawei, xiaomi, etc): + * For more info, please check https://github.com/snt1017/cordova-plugin-power-optimization + * @returns {Promise} + */ + @Cordova({ sync: true }) + HaveProtectedAppsCheck(): Promise { + return; + } + /** + * Go to configurations menu if another battery restriction is present into phone (like huawei, xiaomi, etc). You can send true into params if you want to force show the menu (is only show the fist time without params): + * For more info, please check https://github.com/snt1017/cordova-plugin-power-optimization + * @returns {Promise} + */ + @Cordova({ sync: true }) + ProtectedAppCheck(): Promise { + return; + } +}