# Locked screen detection? Ionic notifications

**URL:** <https://forum.ionicframework.com/t/locked-screen-detection-ionic-notifications/94915>\
**Category:** Ionic Native\
**Created:** [June 19, 2017, 6:56am UTC](https://forum.ionicframework.com/t/locked-screen-detection-ionic-notifications/94915 "2017-06-19T06:56:51Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![FnnHuman](https://avatars.discourse-cdn.com/v4/letter/f/5f8ce5/32.png) [@FnnHuman](https://forum.ionicframework.com/u/FnnHuman)\
**Post date:** [June 19, 2017, 6:56am UTC](https://forum.ionicframework.com/t/locked-screen-detection-ionic-notifications/94915/1 "2017-06-19T06:56:51Z")

</div>

I want to send notifications but only when the screen is locked or the app is minimalized, is there any way to detect those two stances?

---

<div class="post-metadata">

**Author:** ![Sujan12](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/sujan12/32/108395_2.png) [@Sujan12](https://forum.ionicframework.com/u/Sujan12)\
**Post date:** [June 19, 2017, 7:10am UTC](https://forum.ionicframework.com/t/locked-screen-detection-ionic-notifications/94915/2 "2017-06-19T07:10:15Z")

</div>

Notifications are normally sent from a server to a device - so there is no connection to the device.

Lets turn the question around: In which instances do you NOT want to receive a notification?

---

<div class="post-metadata">

**Author:** ![FnnHuman](https://avatars.discourse-cdn.com/v4/letter/f/5f8ce5/32.png) [@FnnHuman](https://forum.ionicframework.com/u/FnnHuman)\
**Post date:** [June 19, 2017, 7:54am UTC](https://forum.ionicframework.com/t/locked-screen-detection-ionic-notifications/94915/3 "2017-06-19T07:54:52Z")

</div>

When user is currently browsing the application

---

<div class="post-metadata">

**Author:** ![Sujan12](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/sujan12/32/108395_2.png) [@Sujan12](https://forum.ionicframework.com/u/Sujan12)\
**Post date:** [June 19, 2017, 8:17am UTC](https://forum.ionicframework.com/t/locked-screen-detection-ionic-notifications/94915/4 "2017-06-19T08:17:29Z")

</div>

What should happen after the device received a push notification and the user then starts the app?

If the answer is “nothing special” you could just implement normal push applications and not do anything in the app to show it. Then the notification text only appears on the OS level, which only happens when the app is not currently open.

---

<div class="post-metadata">

**Author:** ![FnnHuman](https://avatars.discourse-cdn.com/v4/letter/f/5f8ce5/32.png) [@FnnHuman](https://forum.ionicframework.com/u/FnnHuman)\
**Post date:** [June 19, 2017, 8:48am UTC](https://forum.ionicframework.com/t/locked-screen-detection-ionic-notifications/94915/5 "2017-06-19T08:48:37Z")

</div>

so what should I use instead of local-notifications?

---

<div class="post-metadata">

**Author:** ![Sujan12](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/sujan12/32/108395_2.png) [@Sujan12](https://forum.ionicframework.com/u/Sujan12)\
**Post date:** [June 19, 2017, 9:06am UTC](https://forum.ionicframework.com/t/locked-screen-detection-ionic-notifications/94915/6 "2017-06-19T09:06:50Z")

</div>

Normal push notifications, e.g. Ionic Push or OneSignal.

---

<div class="post-metadata">

**Author:** ![FnnHuman](https://avatars.discourse-cdn.com/v4/letter/f/5f8ce5/32.png) [@FnnHuman](https://forum.ionicframework.com/u/FnnHuman)\
**Post date:** [June 19, 2017, 9:27am UTC](https://forum.ionicframework.com/t/locked-screen-detection-ionic-notifications/94915/7 "2017-06-19T09:27:50Z")

</div>

but I dont want to notify every user that match certain criteria from the server, I want something like:  
user is clicking “show notifications every 2 minutes” button in app and he will reveice those notifications, without server, just simple alerts on phone’s lock screen

---

<div class="post-metadata">

**Author:** ![Sujan12](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/sujan12/32/108395_2.png) [@Sujan12](https://forum.ionicframework.com/u/Sujan12)\
**Post date:** [June 19, 2017, 10:22am UTC](https://forum.ionicframework.com/t/locked-screen-detection-ionic-notifications/94915/8 "2017-06-19T10:22:57Z")

</div>

Then do the same with local notifications: Schedule them, don’t handle them by showing something in the app but just “swallow” the message.

---

<div class="post-metadata">

**Author:** ![FnnHuman](https://avatars.discourse-cdn.com/v4/letter/f/5f8ce5/32.png) [@FnnHuman](https://forum.ionicframework.com/u/FnnHuman)\
**Post date:** [June 20, 2017, 7:05am UTC](https://forum.ionicframework.com/t/locked-screen-detection-ionic-notifications/94915/9 "2017-06-20T07:05:39Z")

</div>

could you elaborate because i am not sure if i get this, i just use

```auto
this.localNotifications.schedule({
            id: 0,
            text: 'You are currently not working',
            sound: this.platform.is('android') ? 'file://sound.mp3' : 'file://beep.caf',
          });

```

an i am not sure how it works out since i dont run emulator

---

<div class="post-metadata">

**Author:** ![Sujan12](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/sujan12/32/108395_2.png) [@Sujan12](https://forum.ionicframework.com/u/Sujan12)\
**Post date:** [June 20, 2017, 7:18am UTC](https://forum.ionicframework.com/t/locked-screen-detection-ionic-notifications/94915/10 "2017-06-20T07:18:15Z")

</div>

Yes, use [https://ionicframework.com/docs/native/local-notifications/](https://ionicframework.com/docs/native/local-notifications/)

---

<div class="post-metadata">

**Author:** ![FnnHuman](https://avatars.discourse-cdn.com/v4/letter/f/5f8ce5/32.png) [@FnnHuman](https://forum.ionicframework.com/u/FnnHuman)\
**Post date:** [June 20, 2017, 9:53am UTC](https://forum.ionicframework.com/t/locked-screen-detection-ionic-notifications/94915/11 "2017-06-20T09:53:12Z")

</div>

and it will notify only in locked screen?

---

<div class="post-metadata">

**Author:** ![Sujan12](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/sujan12/32/108395_2.png) [@Sujan12](https://forum.ionicframework.com/u/Sujan12)\
**Post date:** [June 20, 2017, 10:13am UTC](https://forum.ionicframework.com/t/locked-screen-detection-ionic-notifications/94915/12 "2017-06-20T10:13:14Z")

</div>

No idea. Read the docs, test it, find a way to configure it.
