How to adjust the iOS Local Notifications on device timezone change - ios

We have developed an iOS application which allows users to set some alarms based on the time given. These set alarms are displayed in my "Alarm scheduler" screen of my application. The local notification will trigger this alarm when set time is reached.
Now if user changes his timezone say from EDT to PDT, then the "Alarm scheduler" screen is showing the alarm time properly, but my local notification is not getting triggered.
For example suppose its 8:55 AM EDT and user has set the alarm to trigger at 9:00 AM EDT. Now my "Alarm scheduler" screen will show the alarm time as "9:00 AM", now if user changes the timezone to PDT, then the "Alarm scheduler" page will display the alarm time as "6:00 AM" which is correct and users phone will show the time as "5:55 AM". However after 5 mins when "6:00 AM PDT" is reached the local notification is not getting triggered.
Can some one advice how to achieve this?

Did you sent any timezone when scheduling local notification?
When you sent time zone to notification all hard work is done for you by OS.

This might help you..
On changing system's timezone,
UIApplicationDelegate's --> applicationSignificantTimeChange:
method gets called. You can manage your stuff there.

Related

iOS: Limit local notifications to a certain time frame?

I am working on an app that uses local notifications, which are repeating in an interval chosen by the user (between 5 and 60 minutes).
I would like to enable users to also choose a certain time frame so that the app will fire notifications only during this time frame. I was thinking about using NSDate and some kind of conditional statement where the notification only fires if the current time is in the time frame which was chosen by the user.
Do you think that will work or am I overseeing something?
You can use UNCalendarNotificationTrigger for this.
Triggers a notification at the specified date and time.
See
official documentation.
Calendar triggers can also be repeating, so it should serve your purpose.

How to send local usernotifications based on user input [duplicate]

I am creating my first app that lets the user set alerts for themselves and then the app would send the user a local notification on the set time. The thing that I'm having trouble with now is being able to fire the local notification on specific days of the week (for example every Mondays and Tuesdays only). All the tutorials/questions that I have come across so far (like this one) have only been about scheduling the notification everyday/everyweek. The desired result that I'm trying to achieve is sort of like the iPhone's built in alarm system, where you can set an alarm to fire only on certain days of the week.
If I can't just set the notification.repeatInterval field, is there a way I can do what I'm trying to do? Could I possibly execute a little code at midnight that schedules the correct notifications for that day? If so, how could I do that?
Thanks in advance!
The thing that I'm having trouble with now is being able to fire the local notification on specific days of the week
In iOS 10, a UNCalendarNotificationTrigger is formed using DateComponents. This means you can specify as much or as little of the date-time in question as you wish. Thus, if you specify a specific weekday and a time (hour and minutes), and nothing else, you'll repeat at that time on that day of the week.
If you also need to repeat on a different day of the week, just make another notification.

How to repeat local notifications on specific days of the week (iOS Swift 3)

I am creating my first app that lets the user set alerts for themselves and then the app would send the user a local notification on the set time. The thing that I'm having trouble with now is being able to fire the local notification on specific days of the week (for example every Mondays and Tuesdays only). All the tutorials/questions that I have come across so far (like this one) have only been about scheduling the notification everyday/everyweek. The desired result that I'm trying to achieve is sort of like the iPhone's built in alarm system, where you can set an alarm to fire only on certain days of the week.
If I can't just set the notification.repeatInterval field, is there a way I can do what I'm trying to do? Could I possibly execute a little code at midnight that schedules the correct notifications for that day? If so, how could I do that?
Thanks in advance!
The thing that I'm having trouble with now is being able to fire the local notification on specific days of the week
In iOS 10, a UNCalendarNotificationTrigger is formed using DateComponents. This means you can specify as much or as little of the date-time in question as you wish. Thus, if you specify a specific weekday and a time (hour and minutes), and nothing else, you'll repeat at that time on that day of the week.
If you also need to repeat on a different day of the week, just make another notification.

Notifying timezone change to an iOS app

I would like to get a clarification on notifying the timezone change in an app.
Scenario 1: When the user changes the timezone manually from the iPhone settings. I guess in this case, following post will workout.
Notify app when iPad date time settings changed
Scenario 2: If the app is in foreground and the user is travelling to a different timezone from the timezone set in phone settings. In this case, is there any way that the app can be notified about the change of timezone? That means when ever the location changes to a different timezone, will it be possible to notify the app about change in timezone.
I have seen one more way the timezone change can be notified, which is given as following.
[[NSNotificationCenter defaultCenter] addObserver:self selector:#selector(timeZoneChanged) name: NSSystemTimeZoneDidChangeNotification object:nil];
Can anyone give the best way of notifying the timezone change based on scenario 2.
You can handle both notifications by letting them call the same method. All you need to know is that any times that you are displaying may have to change; in the rare case that you would display the user's time zone, that needs changing as well. Both notifications will be rare, so it would be easiest to just redisplay everything.
You might also consider looking at nextDaylightSavingTimeTransition; if there's anything that needs changing. For example if I set an alarm to 8am and you notice that daylight saving time changes between now and the alarm, you could ask if you want the alarm at 8am tomorrow, or 24 hours after 8am, today.

How to know whether iPhone's clock changed while app is running?

will UIApplicationSignificantTimeChangeNotification work if user set automatically setting clock in iOS's General setting, and the clock of the device changes because of the carrier time change?
Is there any other way to get notified when system clock changes while app is running.
The UIApplicationSignificantTimeChangeNotification notification is sent at midnight or anytime the device's time changes (such as daylight savings, the user changing the time, timezone changes, etc.). I don't have direct knowledge of whether changes in time from the carrier will trigger this notification but given the other events, I'd be surprised if such a change didn't trigger the notification.
Documentation says yes, it is called due to carrier time changes.
"Posted when there is a significant change in time, for example, change to a new day (midnight), carrier time update, and change to or from daylight savings time.
This notification does not contain a userInfo dictionary"

Resources