Adding a Local Notification - using iOS 10 User Notifications framework


I’ve been biting off more than I can chew by attempting to use Apple’s latest version of the User Notifications framework. I realize there is a steep learning curve, but hoping I can find some solace here in the BNR forums.

First question revolves around the following error message: “Expected a type” After some googling, I believe this is because I need to #import (or @import) something, but don’t know what it is.

(1) Error message appears on this method location in my header (.h) file:
- (void)scheduleNotification:(NSUserNotification *)notification;

Considering I can use/incorporate the above method and following Apple’s Local and Push Notifications Programming Guide, I’m stuck as to where I should go next. I can’t figure out how to create the trigger upon clicking “Remind Me”.


Add the following codes at the end of you addReminder method.

    UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
    // Ask user for the permission
    [center requestAuthorizationWithOptions:(UNAuthorizationOptionAlert + UNAuthorizationOptionSound)
                          completionHandler:^(BOOL granted, NSError * _Nullable error) {
                              if (granted)
                                  // Add your notification to center
                                  [center addNotificationRequest:request
                                           withCompletionHandler:^(NSError * _Nullable error) {
                                               if (error != nil)
                                                   NSLog(@"%@", [error localizedDescription]);
                                               NSLog(@"finished scheduling");
                                  NSLog(@"do something if user deny permission");