Access the app when the phone is locked


i want to create an emergency app. The user press a button to send an alarm.
My main problem is that it’s too long to unlock the ios/android phone with pin/schema and press the button.

So, using ionic, is it possible to use the app even if the phone is locked (as it is possible in google map).

Thank you

No, this is not possible with anything. You’re effectively asking to build an app that can hack someones phone (bypassing it’s security).

You cannot do this, ionic or not. Phones already have an emergency mode that let you call 911 even if the phone is locked. You are not allowed to make your own, because again, you’re hacking their phone.

Thank you for your response.
I don’t think this is a hack since goole map uses this feature.
My purpose is that the user could use just my app when the phone is locked (if the app is running before locking the phone).

Ya, I mean, google and apple just aren’t going to trust your app like that you know? I never noticed that with google maps, but I see what you mean. Does it do that on iOS too? I could see it being possible on Android because Maps is a google product, so they could pull it off. I wouldn’t think that would work on iOS though. Pretty interesting for sure.

Google owns Android. You (probably) don’t…

I don’t know if map on iOs does.
I’ll try something using background mode plugin but i think it’s gonna be hard to be accepted by apple :frowning:

Google just create Local Notifications in iOS with the instructions of the route you are. You can do the same (maybe) try to find a way to execute a method when user leave the app (by unlocking or pressing back or home) and then start a timeout to create a Local Notification for example:

I read something about this method:
You can use this ionic native plugin to create local notification

this.platform.pause.subscribe(() => {
     console.log('[INFO] App paused');
     // Probably phone lock, need to test.
     // If works to detect phone lock, here you create a local notification.
     // Notifications appear in lock screen until you clear it in iOS need to test it in Android...

     setTimeout(() => {
          // Create notification 1 second after user lock the phone
               id: 1,
               text: 'Please swipe this notification to ask for emergency!!!',
               sound: isAndroid? 'file://sound.mp3': 'file://beep.caf',
               data: { yourParam: 'test' }
     }, 1000);

And you detect when user swipe/touch/open the notification and start your emergency call method.

this.localNotifications.on('click', () => {