Insomnia-PhoneGap-Plugin icon indicating copy to clipboard operation
Insomnia-PhoneGap-Plugin copied to clipboard

Is it working with Ionic4?

Open ioclaudio opened this issue 5 years ago • 6 comments

Hi, I'm using Insomnia on a Ionic4 app in this way: `

if (this.platform.is('cordova')) {
  this.insomnia.keepAwake()
    .then(
      (res) => {
        console.log(`'@ allowSleepAgain --> success'`);
      },
      (err) => {
        console.log('@ allowSleepAgain --> ERROR');
      }
    );
}

` Running the appon a Xiomi Redmi4 (in debug mode) I can see that the app prints: '@ allowSleepAgain --> success'

However, the cell phone still sleeps after some minutes. Which could be the problem? Is there a way to debug the problem?

I have these plugin installed: `

cordova.cmd plugin ls cordova-plugin-camera 4.0.3 "Camera" cordova-plugin-device 2.0.2 "Device" cordova-plugin-file 6.0.1 "File" cordova-plugin-geolocation 4.0.1 "Geolocation" cordova-plugin-inappbrowser 3.0.0 "InAppBrowser" cordova-plugin-insomnia 4.3.0 "Insomnia (prevent screen sleep)" cordova-plugin-ionic-keyboard 2.1.3 "cordova-plugin-ionic-keyboard" cordova-plugin-ionic-webview 3.1.2 "cordova-plugin-ionic-webview" cordova-plugin-mauron85-background-geolocation 3.0.3 "CDVBackgroundGeolocation" cordova-plugin-splashscreen 5.0.2 "Splashscreen" cordova-plugin-statusbar 2.4.2 "StatusBar" cordova-plugin-whitelist 1.3.3 "Whitelist" phonegap-plugin-barcodescanner 8.0.1 "BarcodeScanner"`

`

Ionic: Ionic CLI : 5.0.0 Ionic Framework : @ionic/angular 4.3.0 @angular-devkit/build-angular : 0.13.8 @angular-devkit/schematics : 7.2.4 @angular/cli : 7.3.8 @ionic/angular-toolkit : 1.4.1 Cordova: Cordova CLI : 9.0.0 ([email protected]) Cordova Platforms : android 8.0.0, ios 5.0.1 Cordova Plugins : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 3.1.2, (and 10 other plugins) `

ioclaudio avatar Jun 10 '19 09:06 ioclaudio

Hi, any solution to this?

BrendanThysse avatar May 15 '20 12:05 BrendanThysse

@BrendanThysse have you found a solution ?

AlfredMothapo avatar Aug 28 '20 17:08 AlfredMothapo

@AlfredMothapo the issue on my side was due to where I allow for the app to sleep again, I had different scenarios where I need to keep the screen on and based on that where I allow the screen to sleep after some processing. There were some issues in my code execution that led to the problem, solved it by reevaluating where I need to keep the screen on. Hope you find your solution as the plugin is working fine for me. 🙂

Brendan92 avatar Aug 31 '20 06:08 Brendan92

@Brendan92 confirming it works well too in my case, but when I build the signed APK, the plugin stops working. Do you know why is that? Have you had the same problem? In brief, all good while debugging, but then when the build is ready for the app store, it doesn't work anymore... Thx

albansch avatar Jan 18 '21 22:01 albansch

@albansch I have unfortunately not experienced this kind of behavior on my side, works the same when developing as well as when deployed to app store/play store. Hope you find the solution sorry for not being much help.

BrendanThysse avatar Jan 19 '21 06:01 BrendanThysse

@BrendanThysse thx for the feedback. I actually found the root cause of my issue: within the gradle.build, I set minifyEnabled to true, and it broke the class names. Reverting back to minifyEnabled to false made it work fine.

albansch avatar Jan 20 '21 04:01 albansch