From f1e1930c1ac584cd90650159480f00be85a93e23 Mon Sep 17 00:00:00 2001 From: Aldo Armiento Date: Mon, 4 Apr 2016 23:21:17 +0200 Subject: [PATCH] Updated to iOS 8.0 --- Objective-C Demo/Classes/DemoAppDelegate.m | 30 ++++++++++++---------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/Objective-C Demo/Classes/DemoAppDelegate.m b/Objective-C Demo/Classes/DemoAppDelegate.m index 9202d27c..3a8977ea 100644 --- a/Objective-C Demo/Classes/DemoAppDelegate.m +++ b/Objective-C Demo/Classes/DemoAppDelegate.m @@ -29,8 +29,8 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( [window makeKeyAndVisible]; #if !TARGET_IPHONE_SIMULATOR - [application registerForRemoteNotificationTypes: - UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound]; + [application registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeAlert | UIUserNotificationTypeBadge | UIUserNotificationTypeSound) categories:nil]]; + [application registerForRemoteNotifications]; #endif application.applicationIconBadgeNumber = 0; @@ -53,14 +53,18 @@ - (void)application:(UIApplication *)application didReceiveRemoteNotification:(N if (application.applicationState == UIApplicationStateActive) { // Nothing to do if applicationState is Inactive, the iOS already displayed an alert view. - UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Did receive a Remote Notification" - message:[NSString stringWithFormat:@"The application received this remote notification while it was running:\n%@", - [[userInfo objectForKey:@"aps"] objectForKey:@"alert"]] - delegate:self - cancelButtonTitle:@"OK" - otherButtonTitles:nil]; - [alertView show]; - [alertView release]; + + UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Did receive a Remote Notification" + message:[NSString stringWithFormat:@"The application received this remote notification while it was running:\n%@", [[userInfo objectForKey:@"aps"] objectForKey:@"alert"]] + preferredStyle:UIAlertControllerStyleAlert]; + UIAlertAction *alertAction = [UIAlertAction actionWithTitle:@"OK" + style:UIAlertActionStyleDefault + handler:^(UIAlertAction *action) { + [alertController dismissViewControllerAnimated:YES completion:nil]; + }]; + + [alertController addAction:alertAction]; + [self.viewController presentViewController:alertController animated:YES completion:nil]; } } @@ -84,9 +88,9 @@ - (void)application:(UIApplication *)application didFailToRegisterForRemoteNotif #pragma mark Memory management - (void)dealloc { - [viewController release]; - [window release]; - [super dealloc]; + [viewController release]; + [window release]; + [super dealloc]; } @end