Open rex79 opened 7 years ago
+1
Same issue with ionic 2, I have: app.module.ts:
import { Insomnia } from '@ionic-native/insomnia';
providers: [
Insomnia,
]
export class AppModule {
constructor(private backgroundMode: BackgroundMode, public platform: Platform, private insomnia: Insomnia) {
console.log('Hello app');
this.platform = platform;
this.platform.ready().then(() => {
this.backgroundMode.enable();
this.insomnia.keepAwake()
.then(
() => console.log('success'),
() => console.log('error')
);
});
}
}
But after 40secs the app goes to sleep and it fails. Client is freaking! Using Remi note 4 with Android version 5.0.2. No errors in any logs... just seems to stop. please help
+1 one, about to get my head chopped off, happy to pay for your time to help asap
DId anyone have any luck with this. It's really driving me insane, not to mention getting yelled at by the client. Are we doing this right? Should the code go in app.module.ts.... So confused
@nimeso You client is a dick.
Have you tried calling keepAwake
in a different spot of your app to make sure the timing is right? For instance on a home screen, triggered from a button, for experiment's sake?
I can confirm that we are running into this as well. I will investigate in more detail later today. The device I confirmed this on was Galaxy S5 with Android 6.0.1 and webview version 60.0.3112.107
edit: See comment below. This was not a bug in insomnia.
For me, it works on development mode but not on production mode. What could be the possible causes? the device is an iphone 5.
@Jun711 How are those modes different? Also stuff like Webpack?
@EddyVerbruggen Yea, there is webpack. And I built it with this command ionic prepare ios --prod --release
the browser is Mobile Safari UIWebView ver 10.3.3
Perhaps webpack messes it up, perhaps something else, but you need to do the digging.
I can confirm that my problem was in our own code. Insomnia is working for us as it should (and has for years). Thanks Eddy.
@AgDude hi, could you please briefly explain what problem u ran into? Thanks!
The short answer is that we were calling "allowSleep" immediately after calling "keepAwake".
We manage insomnia with a service that gets tied into which view is active, as well as what long-running async functions may be running and try to handle it automatically. That service was broken and letting an async function cancel the keepAwake when it shouldn't.
@EddyVerbruggen Bhahahaha. Unfortunately my client is a good friend of mine :) Poor bastard has gone through 5 devs on this project and it was suppose to be completed in 3 months... 6 months later... haha. I'll try a manual button. And let you know how it goes :) It should work in platform ready though?
Ok, so I'm calling keepAwake() on a manual button now but still have the same issue. Issue.
I have a feeling this is a security issue?
Ok, this is getting nuts @EddyVerbruggen . This plugin does not work :( what am I doing wrong? I've put in in home page, I've put it in a button... I've done everything! After 40sec it just stops working when the phone goes to sleep. Happy to help pay for your time, this is getting urgent. I can add you to our Ionic repo and maybe you can look. I've wasted 3 days now. Desperate for help.
@nimeso If you can start a new cordova create myapp
helloworld app and reproduce the issue there (and share the project), I will take a look.
@EddyVerbruggen Thanks man! I'm going to have a long needed day away from this stupid computer today :) but I'll do that tonight. I made some discoveries yesterday though. Your plugin does work. But it's the background-geolocation that seems to stop working, everything else works fine in sleep mode. I've discovered if you change the battery saving settings on your android everything works fins including the geolocation. :) My fingers are slow at typing... they need coffee. Thanks for all your help.
I see that this is an old issue. Im facing something similar though.
The plugin works flawless on all our test devices. However, our client has bought a bunch of Huawei phones for their staff - and all of these phones fails.
They are using the following devices: FIG-LX1 ALE-L21
Hi, is there a settings on android that will prevent the plugin from work? I've try with different device and I put this code on my app.component.ts:
platform.ready().then(() => { // Okay, so the platform is ready and our plugins are available. // Here you can do any higher level native things you might need. Splashscreen.hide(); StatusBar.styleDefault();
(I'm using ionic 2) and on some device it work, on other no.
Is this the right way to call it or there are some sort of Android settings that will block the plugin?
Thanks a lot