Brig app to front after certain time?

Hi,

I’m porting and android native app to ionic.

The app needs to be woken up after a certain timeout.

By woken up I mean that even if the screen is off or the user is doing some other task then the app should be brought to front.

Alternatively, if this is not possible it could show a notification and play a media so the user can activate it clicking on the notification icon.

Checking the forum it seems that this is not possible or that it would be possible just letting the app run in background as a service. which IMHO is a terrible solution as it will affect the phone performance.

Am I missing something?

Use local notification plugin and schedule the app to receive local notification.

1 Like

Hi,

Thanks for your reply. I have one more question: will this also wake up the phone if the screen is off? BEcause it looks like a simple notification and I need to play an alarm sound in loop until it’s switched off

S.

It will wake the app when the user clicks on the notification. It will not do it automatically. The limitation of using cordova is that the app is running inside a web view. Untill someone has created created a plugin, we cannot hook into the native capabilities.

Ok.

Thanks for your reply, Was very helpful

Just a note even with native apps Apple at least is very strict about using background modes. They most likely would reject an app that is trying to pull itself forward to do things without the user consenting to it. Local notifications and the user opening the app is the best route. I think on iOS you can do 64 notifications and schedule them in advance and android has a higher limit, don’t remember what it is off the top of my head though.

1 Like

Ok but if it’s an Alarm how does it work on Apple? It’s 6AM in the morning I don’t want to start playing with the phone just to find the snooze.

I found this plugin here: https://github.com/uniclau/AlarmPlugin I’ll give it a try.

I writing a cooking timer so I don’t need to bring it to front (I said that because it’s the way I did it on Android).

It’s ok to play the alarm sound and let the user interact, but the soud should play even if the screen is off otherwise the chicken will burn in the oven :slight_smile:

Ah! So I believe alarms are covered in the background modes at least with iOS. I believe they use the same mechanics that a music player would. Though it’s fairly limited. I used an app called Pillow a while back and did some basic sleep tracking however I had to have my phone plugged in so I could turn the app on and then lay it on my bed and it would prevent the phone from sleeping this way it could use the sensors and such. But with your app just regular background modes and that alarm plugin will hopefully do the trick.

Let us know how that goes I’m curious!

Did you find a workable solution to this issue? I too have need of this. Thanks!

-Ben

Take a look at https://github.com/katzer/cordova-plugin-background-mode