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?
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?
When user is currently browsing the application
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.
so what should I use instead of local-notifications?
Normal push notifications, e.g. Ionic Push or OneSignal.
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
Then do the same with local notifications: Schedule them, don’t handle them by showing something in the app but just “swallow” the message.
could you elaborate because i am not sure if i get this, i just use
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
and it will notify only in locked screen?
No idea. Read the docs, test it, find a way to configure it.