-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix streak notifications scheduling for iOS 10.0* #430
Conversation
private let calendar: Calendar | ||
|
||
private var dateComponents: DateComponents { | ||
let timeZoneDiff = NSTimeZone.system.secondsFromGMT() / 3600 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Тут кстати вроде как есть bridge в TimeZone
let timeZoneDiff = NSTimeZone.system.secondsFromGMT() / 3600 | ||
var localStartHour = self.UTCStartHour + timeZoneDiff | ||
|
||
if localStartHour < 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Не по теме ПРа, но каждый раз смотрю на этот кусок кода и не понимаю, почему вообще в пикере происходит какое-то шаманство с датой. Ведь можно же оттуда отдавать DateComponents с выбранным часом сразу
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Я не разбирался, возможно @Ostrenkiy помнит, почему пришлось шаманить.
Кстати, в момент выбора даты уже выполняется перевод в UTC https://github.com/StepicOrg/stepik-ios/blob/dev/Stepic/NotificationTimePickerViewController.swift#L37
а потом еще раз точно такой же код выполняется тут - в StreakLocalNotificationContentProvider
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Кажется, там шаманство из-за того, что в пикере дата должна быть в локальном часовом поясе, а сохраняем ее мы в UTC формате.
А почему это шаманство именно такое я без понятия, если можно сделать такие вещи по-другому и хорошо - это круто и надо бы сделать
Задача: #APPS-2166
Описание:
Исправили планирование
streak
нотификаций. Оригинальный код до внедренияLocalNotificationsService
и использованияUserNotifications
.При создании компонентов даты для
UNCalendarNotificationTrigger
многие поля были избыточны и поэтому нотификация возникала в лучшем случае только 1 раз. На iOS 9.0 такое поведение не наблюдается из-за использования специального поля для указания частотыrepeatInterval: NSCalendar.Unit?
.Как проверить: