WorryFree Computers   »   [go: up one dir, main page]

Skip to content
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

Merged
merged 9 commits into from
May 29, 2020

Conversation

charlotteliang
Copy link
Contributor
@charlotteliang charlotteliang commented May 21, 2020

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.

FirebaseMessaging/CHANGELOG.md Outdated Show resolved Hide resolved
FirebaseMessaging/Sources/FIRMMessageCode.h Outdated Show resolved Hide resolved
@@ -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)
Copy link
Member

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link
Contributor
@maksymmalyhin maksymmalyhin left a 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];
Copy link
Contributor

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 :) ).

Copy link
Contributor Author

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];
Copy link
Contributor

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)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@charlotteliang charlotteliang merged commit b48cc90 into master May 29, 2020
@charlotteliang charlotteliang deleted the fcm-local branch May 29, 2020 20:48
@firebase firebase locked and limited conversation to collaborators Jun 29, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants