Local user Notification not triggering inspite of authorisation

Below is my code that cancels previous notification and should trigger a new one for the set time. Code runs without error but i dont see any notification. I have taken concrete authorisation for the same and there are no run time errors in the trigger below.

previously when the authorisation was provisional, the notification would fire fine upon subsequent time changes. Not it just doesnt show up. Please help me out.

-(void)makeNotificationFromDateComponents:(NSDateComponents *)dateComponents
{
    [[UNUserNotificationCenter currentNotificationCenter] removeAllPendingNotificationRequests];
    UNMutableNotificationContent *notificationContent = [[UNMutableNotificationContent alloc] init];
    notificationContent.title = @"title";
    notificationContent.body = @"body.";
    notificationContent.sound = [UNNotificationSound defaultSound];
    UNCalendarNotificationTrigger *notificationtrigger = [UNCalendarNotificationTrigger triggerWithDateMatchingComponents:dateComponents repeats:YES];
    UNNotificationRequest *notificationRequest = [UNNotificationRequest requestWithIdentifier:@"AddReminderNotification" content:notificationContent trigger:notificationtrigger];
    [[UNUserNotificationCenter currentNotificationCenter] addNotificationRequest:notificationRequest withCompletionHandler:^(NSError *error){
        if (error!=nil) {
            NSLog(@"Notification error: %@",error.userInfo);
        }
    }];
}
  • note i have already deleted and reinstalled the app post changing authorisation type. And upon launch i am allowing notifications in the prompt.

Add a Comment

Replies

amy insight is appreciated.