Local Notification in iOS(Objective C) - ios

I have scheduled the local notification on tomorrow 10 AM and i switched off the mobile and then turn on my mobile day after tomorrow.At this time the notification is not receiving.But I can able to receive the notification, once i meeting the scheduled date and time.So this is possible, to get the notification once crossed the scheduled date and time in iOS?

Could you please rephrase your question?
From what I understand you say that your local notification is not delivered if the device was not turned on at the scheduled time.
In general, your local notifications are not handled by your app. When you register a local notifiction, iOS is responsible for delivering it. This also means that your app does not have to be running when your local notification is scheduled to be delivered.
When your local notification was meant to be delivered at 10 AM, but your device was turned off from 9:50 to 10:10 AM, your local notification will be lost!
Your app should not rely on delivering that local notification. Your only way of knowing whether a user received your local notification is when he opens your app by clicking on the notification or using one of its actions. Your app will then be called by application:didReceiveLocalNotification when it is in the background, or regular by application:didFinishLaunchingWithOptions: when it was killed before.
TL;DR: You should not care whether a user received a local notification, as there is no way to make sure he receives it under certain conditions.

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.

iOS Firebase/APNS push notification sound according to local time or timezone

I am using FCM to send iOS push notifications for an app that is used worldwide. Different users are in different time zones.
Is there a way to specify ,that when delivered at worktime local time Mon-Fri (8:00 - 17:00) it will have sound, but any other it will be without sound. I do not want to disturb the user at night.
This question is mostly about the worst situation when my app isn't running/backgrounded/suspended (for example after reboot) and/or offline
.My app uses background fetch, but that doesn't guarantee that it will be running at the delivery time of the push notification.
The problem is i do not know in advance when the push notification will be delivered. If i knew i would specify the sound key in the JSON.
The user could be offline when the push notification is sent.
For example, i send the push notification at night without sound, but the user enables internet connection at day and receives the notification without sound (because it was sent in the night)
Scheduling the sending time at the server won't solve this, because we cannot control the delivery time.
If it is possible using directly APNS without Firebase then that would also solve my problem.
Thank you very much.
Clarification:
When my app is running i have enough control to decide according to local time if the sound should be played. The question is aimed at the other case when my app isn't running/backgrounded/suspended.
I am using silent data notifications (JSON key data with content-available=1) to deliver all neccessary info, but when my app is not running there is only one way to send a notification that will be shown - that is a Display notification (JSON key notification)

iOS PushKit ring phone

I'm developing a VoIP app with Apple's PushKit. I am able to receive notifications when the app is in background or even when it's not running. However, I don't know how to turn on the display and ring the phone when it's necessary, like in case of incoming VoIP call.
You can schedule local notification, with push kit or anything never you app will come foreground, never phone will turn on.
With use of local notification you can set sound file for 30 seconds.
You can repeat at every 30 seconds until user act on local notification.
Local notification could have action buttons.

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.

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