-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
use UNNotificationRequest to schedule local notification for iOS 10 and above #5667
Conversation
FirebaseMessaging/CHANGELOG.md
Outdated
@@ -1,3 +1,6 @@ | |||
# 2020-06 -- v4.4.2 | |||
- [changed] Use UNNotificationRequest to schedule local notification for local timezone notification for iOS 10 ang above. (#5667) |
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.
Should fixing the problem with the percent character be mentioned?
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.
Done.
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.
LGTM. Couple questions - mostly curiosity.
NSDateComponents *dateComponents = [calendar components:(NSCalendarUnit)unit fromDate:date]; | ||
UNCalendarNotificationTrigger *trigger = | ||
[UNCalendarNotificationTrigger triggerWithDateMatchingComponents:dateComponents | ||
repeats:YES]; |
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.
I wonder why repeats
is YES
? It looks like it won't repeat any time soon with the specified calendar units (maybe in the next era maybe :) ).
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.
Good catch. I think this should be no as backend every day will send a new scheduled notification. And client has no way to set when to end, so this should be a backend control thing. I will double test again today and tomorrow.
+ (void)scheduleLocalNotificationForMessage:(NSDictionary *)message atDate:(NSDate *)date { | ||
if (@available(macOS 10.14, iOS 10.0, watchOS 3.0, tvOS 10.0, *)) { | ||
[self scheduleiOS10LocalNotificationForMessage:message atDate:date]; |
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.
I wonder if we need to make any validation of the date (e.g. if it is in the past or in a distant future)?
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.
We do check it here: https://github.com/firebase/firebase-ios-sdk/blob/master/FirebaseMessaging/Sources/FIRMessagingContextManagerService.m#L99
And if it's very near future we schedule right away.
This fixes b/156310608 also as the UILocalNotification doesn't properly process "%", where it escape it in notification title and body.
Also UILocalNotification is deprecated, so use them for iOS 10 above.