Let user schedule time for not receiving remote push notification - ios

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

Related

Can I block receiving iOS Push Notifications during specified hours (night time) programmatically in Swift

my client wants to have an UISwitch control in Settings view in his app which is: 'Disable Notifications during night time'. He would like pushes that his API will be sending to mobile to be ignored if this option is turned on and it's a night time. Is this possible? I know that I can register and unregister for remote notifications, but this requires an App to be turned on. Is it possible to have it working like he wants?
The only way to do this is to have a configuration in the back-end. Notifications are sent from a server, and only handled in the app. There is no way, besides unregistering the phone from receiving notifications, to have the phone deny a notification in a certain time frame.
The user can set a time preference in the app, send it to the server, and have the server do a check so it only sends the notification to the user in the preferred time period.
Check out this 3rd party repo to send your push notifications and just write in your own check before pushing the notification.
https://github.com/nomad/houston
You can register or unregister for push notifications, i hope in your code switch you can make something like this:
let application = UIApplication.shared
//Didnt receive push
application.unregisterForRemoteNotifications()
//Receive push
application.registerForRemoteNotifications()
and if your client wants make this in Backend you can put a value on some database table with field receive:Bool, and the backend just take all the receive == true to send push notification on this devices

Objective C: Is it possible not to show iOS Push Notifications in specific conditions

Is it possible in iOS 7/8 not to show push notifications? In push userInfo I receive some data. Is it possible to check this data and show/not show this push notification? I need this when user have to logout from my application.
Sorry, You can not stop notification from being shown in notification panel. When your app is in background/terminate state. First Notification is shown in notification panel.
You can control show/hide notification in your application. When your app method didReceiveRemoteNotification is called.
You can ask your back-end developer to send some flag whether this notification should be displayed or not.
Yes,it is possible in server side.when you get notification at the same time ask server side to send save that in one web service from that you have to get and show the details to user.
In app is open that time you able get notification data in didReceiveRemoteNotification.

Scheduled Background task for daily at specific time in iOS

I need some help for scheduling a Background task at daily basis at specific time in iOS.
I want to call a webservice at a specific time (let's say at 1.00 am ) and download all new data to app.
After searching a lot, I came to know about Notifications and timer to do such things but I have some questions
Suppose I create scheduled job on server which sends a push notification at 1 am to device.
After receiving push notification can my app start automatically (without any user interaction with app icon or push notification)?
What should be happen when at 1 am the device has not an active internet connection or my app does not receive the push notification?
Suppose I create a Timer or a local notification to schedule the download at 1 am - it will call the web service only if my app is running
How do I achieve this?
Please give me any suggestion.
Answer to your question
1- After receiving push notification app will not start automatically until user will himself click on that push notification.
If device will have no internet access then again your notification will not be transferred.
I recommend you that you should go with push notification.you can Schedule
your push notification and when it receives on user device run a webService for successfully receiving of notification which will tell that notification successfully delivered in case if it will not be delivered due to internet problem or something else then you can again schedule notification after 30 minutes again until you will get a success.
there is no other option for achieving this.

Don't show push notifications

Is there an opportunity to stop showing push notifications via an app?
I have an app connected to a database. When someone sends me something like a message I will get a push on my devices (lock-)screen. But if the user does not want to see specific notifications for something, maybe a new message by person XY, it should not appear!
So is there an opportunity for hide specific pushs via the app or do I have stop them server-side?
You'll have to make the change server-side. From the app side, you can't stop only certain push notifications, because it's while the app is backgrounded (or not even running) that push notifications will be showing, so your app has no control over whether specific ones will show or not.
If the app is not in the foreground then the push notifications don't get delivered to the app, they get delivered directly to the user and hence there is no chance for the app to intervene and filter them.
BUT if your app is for iOS7 only then you could use silent background push notifications, then when the push is delivered the OS will rouse your app and the push will be delivered to it, then the app can examine the content of the push and also examine the user preferences and then present the background push as a local push or not (to the user a local push looks just like a remote push).
One caveat is that if the user forcefully terminates your app (by upwardly swiping it out of the task manager) and the user has not restarted it then the OS will not deliver the silent push to it.

Push Notification that cancels or reschedules a Local Notification?

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.

Resources