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"
Related
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.
This is in response of an effort in order to implement an app in a way, so that I could run some code at specific interval of time i-e Morning 9:00 am daily.
Lets take an example of an Alarm.
If user is allowed to set a time interval, during which he is going to remain busy, so now after setting two - three intervals for his daily schedule.
After the app is suspended or in foreground, user needs a reminder before entering to and after getting out of the interval.
I need guidance for this problem in a way :
Local notifications for this situation in swift
Changing the mode of device from ringer to silent during that interval
OR
Accessing programatically 'Do not Disturb Me' feature of IOS
Your kind conveyance regarding this issue will be really productive for me.
Thanks.
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.
May be I am asking a stupid question here.
I recently noticed an UIApplication delegate method
- (void)applicationSignificantTimeChange:(UIApplication *)application {
}
I was wondering what will be its actual use? Do we need to handle this. Can anyone explain a scenario that can happen in an iOS application and we need to do some coding here.
My App is really sensitive to system time, that is the reason I am asking this question. After seeing this API , I have a feeling that I am missing something here to handle.
I am just curious to know... :)
Thanks,
Ramesh Chandran A
Per the documentation on iOS, this method is called:
Examples of significant time changes include the arrival of midnight,
an update of the time by a carrier, and the change to daylight savings
time. The delegate can implement this method to adjust any object of
the app that displays time or is sensitive to time changes. Prior to
calling this method, the app also posts a
UIApplicationSignificantTimeChange notification to give interested
objects a chance to respond to the change. If your app is currently
suspended, this message is queued until your app returns to the
foreground, at which point it is delivered. If multiple time changes
occur, only the most recent one is delivered.
Examples of when this should be used include:
If your app has repeating scheduled events, such as a local notification that now is past, and your app should reschedule the next notification (like daily reminders).
If your app displays data in time ago that needs to be correct, even if the user sets a bad time (for example a medical app that shows your current glucose reading or similar). If a glucose monitor showed an old glucose value as the users current glucose value for instance, the user could make the wrong decision and get hurt.
How you respond to this event depends on your application. You could for instance, read UTC from a server to see if the phone's UTC is correct within some margin, and take appropriate action, such as warning the user, or updating an internal offset between actual UTC and phone UTC.
Hope that helps.
-applicationSignificantTimeChange: is roughly equivalent to the UIApplicationSignificantTimeChangeNotification notification.
I have a custom date picker control that highlights the today date. Subscribing to this notification allows it to change its highlight at midnight, or if the user messes with the time setting manually.
In an iOS app, is there any method to get notified either user changed the date or time setting.
Actually in an app we want to know the time difference between the two app sessions. It can be done by saving the time when user closed the app and when user restart again. But what if user change the time setting in between.
Can we get noticed at the starting of the game whether user changed the time/date setting.
Any suggestions would be of great help.
UIApplicationSignificantTimeChangeNotification is what you're looking for. But there's another case where date may change, for example when user changes time zone. In this case you need to observe NSSystemTimeZoneDidChangeNotification.
I believe that this is what applicationSignificantTimeChange: (on the app delegate) and the UIApplicationSignificantTimeChangeNotification notification is used for (though the case where the user manually changes their time is not listed as an example)