Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- - (void)scheduleNotification:(ANSNotificationMO *)notification content:(UNMutableNotificationContent *)content repeats:(BOOL)repeats {
- ANSNotificationMO *notificationForFunction = notification;
- [[UNUserNotificationCenter currentNotificationCenter] requestAuthorizationWithOptions:(UNAuthorizationOptionAlert | UNAuthorizationOptionSound | UNAuthorizationOptionBadge)
- completionHandler:^(BOOL granted, NSError * _Nullable error) {
- // UNMutableNotificationContent *notificationContent = [self notificationContentForNotification:notification];
- // if (userInfo) {
- // notificationContent.userInfo = userInfo;
- // }
- if (content) {
- // schedule with UNUserNotificationCenter
- NSDateComponents *fireDateComps = [self fireDateComponentsForNotification:notificationForFunction];
- UNCalendarNotificationTrigger *trigger = [UNCalendarNotificationTrigger triggerWithDateMatchingComponents:fireDateComps repeats:repeats];
- UNNotificationRequest *request = [UNNotificationRequest requestWithIdentifier:notificationForFunction.requestIdentifier content:content trigger:trigger];
- [[UNUserNotificationCenter currentNotificationCenter] addNotificationRequest:request withCompletionHandler:^(NSError * _Nullable error) {
- if (error) {
- CLS_LOG(@"Notification Scheduling Error: %@", error);
- [Answers logCustomEventWithName:@"UNUserNotificationError" customAttributes:@{@"error":error.description,
- @"method":@"scheduleNotification:(ANSNotificationMO *)notification userInfo:(NSDictionary *)userInfo repeats:"
- }];
- } else {
- // [_dataController saveContext];
- // [_rescheduler requestDescheduleForNotification:notification];
- }
- }];
- }
- }];
- }
Add Comment
Please, Sign In to add comment