0

I have a code that allows the device to run an update. It works perfectly when the ipad is not under guided access for information under iOS11 (and it worked under iOS10 & guided accesss):

- (void)viewDidLoad
{
...
      UNMutableNotificationContent* content = [[UNMutableNotificationContent alloc] init];
        content.title = [NSString localizedUserNotificationStringForKey:@"Update!" arguments:nil];
        content.body = [NSString localizedUserNotificationStringForKey:@"Update!"
                                                             arguments:nil];

        // Configure the trigger for a 7am update.
        NSDateComponents* date = [[NSDateComponents alloc] init];
        date.hour = 18;
        date.minute = 31;
        UNCalendarNotificationTrigger* trigger = [UNCalendarNotificationTrigger
                                                  triggerWithDateMatchingComponents:date repeats:NO];

        // Create the request object.
        UNNotificationRequest* request = [UNNotificationRequest
                                          requestWithIdentifier:@"update" content:content trigger:trigger];

        UNUserNotificationCenter* center = [UNUserNotificationCenter currentNotificationCenter];
        center.delegate = self;
        [center addNotificationRequest:request withCompletionHandler:^(NSError * _Nullable error) {
            if (error != nil) {
                NSLog(@"%@", error.localizedDescription);
            }
        }];
    }

    - (void)userNotificationCenter:(UNUserNotificationCenter *)center
           willPresentNotification:(UNNotification *)notification
             withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler {
        // Update the app interface directly.
        NSLog(@"");
        // Play a sound.
        completionHandler(UNNotificationPresentationOptionSound);
    }

I found that Ticket, but no exhaustive explanations to accomplish it:

Is it possible under iOS11 to launch notification on guided access?

Thanks in advance.

ΩlostA
  • 2,501
  • 5
  • 27
  • 63

1 Answers1

1

It appears this was nothing more than an iOS bug which has been fixed in iOS 11.2.5 beta 4. Please see my own question here for more information.

If you can wait until iOS 11.2.5 is released (which will hopefully be soon according to Apple) the issue should just resolve itself. Otherwise you'll need to investigate something like a sockets system instead.

Wade
  • 180
  • 1
  • 9