I am trying to schedule a notification locally as I don't have the necessary structure in the backend yet. The idea is that after a X period of time, certain conditions are validated; and if fulfilled, a regular local notification is triggered.
This could be easily achieved using a timer for instance, but some of this periods are long enough (1 hour, 24 hours) that this doesn't work.
This is how I end up thinking in the local notifications. I could schedule one with a firedate of +24hs. The thing is that I need this to be silent in order to validate the conditions.
From the configuring a local notification
section here it seems that only remote notifications can be silent, but it doesn't really say it can't be done.
Also, I've found that it is possible to trigger a local notification with nothing but the badgeNumber, and it WILL change the badge. Though the callbacks in my AppDelegate are never called.
I've seen some people say it can't be done, but haven't found a real hard official evidence stating it. Anybody managed to do this? Or know for sure this is in fact impossible? Any advice will be of great help, thanks a lot in advance!
Go to Settings > Do Not Disturb. Turn on Scheduled and set a schedule. Choose when you want to receive alerts, calls, and notifications: Silence: Choose to silence calls and notifications always or only when the device is locked.
There are two ways users can receive silent push notifications on Android. Users can long press on a notification to get an option to display notifications silently. Users can also enable silent notifications by heading to Settings > App & Notifications > Search for app and choose> Notifications, and turn it off.
Silent notifications is a feature allowing to send notifications without disturbing the user. Notifications are not shown in the notification center or notification bar. Callback methods are executed even when the application is running in the background.
I tried and had the same experience as you - the callbacks are never called when my app is not in the foreground. This is by design. The Apple documentation states that the callback is only called when your app is in the foreground userNotificationCenter:willPresentNotification:withCompletionHandler:
https://developer.apple.com/reference/usernotifications/unusernotificationcenterdelegate/1649518-usernotificationcenter?language=objc
The only callback method for receiving notifications when the app is not in the foreground is didReceiveRemoteNotification
but unfortunately it is only for push notifications (silent or otherwise). https://developer.apple.com/reference/usernotifications/unusernotificationcenterdelegate/1649518-usernotificationcenter?language=objc
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With