Push Notification that cancels or reschedules a Local Notification? - ios

We're investigating building an alarm-style iOS app as an extension of a website.
We plan to have alarms sent to the device via push notifications. We want to also have a local notification set to a time that's a little after the planned push notification just in case of no network connectivity and the push notification does not reach the user.
However, we would like to cancel this local notification and re-schedule it when the push notification is received so it doesn't annoy the user with an unnecessary notification.
Essentially two types of push notifications:
The actual alarm if it's set to be sent (normal ability)
No alarm but reset the local notification to a little after the next planned alarm time (unknown ability)
Is this a possibility?
Maybe with work-around such as being able to remain in the background like an audio app that only handles the push notifications and we could ask Apple for special approval?
How common it is to get special approvals like this?
Thanks

I'm not sure, like Anthony Corbelli, what the reason for the push notification is if you're going to have the local notification set up for the same alarm.
In any case, if you want to cancel and/or reschedule an existing UILocalNotification from within the push notification handler, you can get a list of notifications with
[[UIApplication sharedApplication]scheduledLocalNotifications]
and then cancel the one you want with
[[UIApplication sharedApplication]cancelLocalNotification]
You can then modify the notification as desired (e.g., move its fireDate into the future) and reschedule it as appropriate.

Related

receive push notification when a certain date expirespush notification

I have an app that has the Firebase Realtime Database as database.
In the app there are different products that expire after a certain time.
The database contains the expiry date and the exact time. How do I get the user to receive a push notification if the product is only available for 10 minutes, even if the app is completely closed?
Do I have to save the data on my device and send a local push notification from there?
Currently the user only receives a push notification when a new product is added.
A "local push notification" isn't really a thing. There are local notifications and push notifications. Push notifications are sent (pushed) from your server, through Apple's APNS (Apple Push Notification Server) and to your app's user.
You can schedule local notifications locally for some future time. There's really no difference to the user. It displays a message in the notification center which the user can tap to wake up your app, even if it wasn't running when the notification "goes off."
It sounds like you want to schedule a local notification.
If the trigger comes from your server then you could trigger a push notification. Those are also displayed to the user in the notification center whether your app is running or not.

Remove but not cancel local notification

cancelAllLocalNotifications() will as the name says, cancel all local notifications.
Consider that the phone has received a couple of notifications while the screen was in locked state. And we are only have interest in notifications received when the user actively are using the phone.
Is it possible to only clear these notifications from the list in the Notification Center, but without cancelling them?
If you can use identifier for description your every notification, than you can only one notification removing, after this process you can setting notification again. I think this kind a trick working for your situation.

Let user schedule time for not receiving remote push notification

I'm developing an iOS app that uses Push Notifications from Parse. Is it possible to let user to schedule the time for receiving push notification. For example, the user may want to mute/disable the push notification from 00:00 to 07:00 everyday.
You may assume there will be remote notification only.
Is it possible to create such a setting to mute the push notification programmatically on the client side?
Any help is appreciated.
I don't know if there are any automated process for it , i have knowledge of the manual process to stop the push notification
1st way: GO to device settings -> your app -> Notifications(if you have taken permission from user to show the notification, it will show in the settings), inside it looks like this
if user disable this Allow Notifications options user will not get notifications for particular app, but to enable the push notification user has to follow the same steps and enable the push notification from the settings only
2nd way in the application there is a method called unregisterForRemoteNotifications which can stop the push notifications programatically but i am not getting idea how we can automate register/unregister this during the user selected period of time

Suppress/Hide push notifications in iOS when the app is running

I receive push notifications on certain events from a notification server we have.
I do want these notification alerts to appear when the app is not active in the background/foreground
I don't want the notification alert to appear when the app is active in the background (foreground not a problem since the notification doesn't show anyway). I want to show my own local notification, only.
Is there any way to do this from code? Basically I want to hide the remote push notification and instead show a local notification when my app is active.
P.S - The notification server sending silent notifications is not an option - the server does not know when our app is running/not running. There is no communication between the app and this server.
You can notify your application first and then show a local notification with that. To perform this you can simply send content-available notification from server. This makes your app notified and then you can decide on showing local notification or not.

Counting push notifications on iOS (deal with cancel from notif center)

I'm trying to understand on how to deal with a particular use case with push notifications.
Let's suppose that I have 4 push notifications in the notification center waiting for an interaction, the server keeps track of the badge number. The user picks up one, in the -application:didReceiveRemoteNotification: I decrement the badge and communicate to the server the notification back to make it decrements its "badge" number and mark the notification as read.Everything works fine.
I'm not able to deal with that case. Let's say that the user deletes from the notification center one notification and then opens the app by tapping on another, I will have an incorrect badge number on both server and app, since deleting a notification it doesn't seem to affect the badge number.
Is there a way to understand which remote notification has been removed?
It seem that for a more fine grained control is better to use a mix of silent push and remote notification.

Resources