La conversión implícita de 'unsigned long' UIUserNotificationSettings * 'no está permitida con un arco

La notificación push en iOS 8 no funciona.

Visualización de error:

implicit conversion of 'unsigned long 'UIUserNotificationSettings *' is disallowed with arc 

Código:

 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { [application registerUserNotificationSettings:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge)]; return YES; } 

introduzca la descripción de la imagen aquí Estoy usando ios 8.0 y xcode 6 beta.

Obtengo de abajo la documentation oficial de iOS 8.

  • Las aplicaciones que utilizan notifications locales o push deben registrar explícitamente los types de alertas que muestran a los usuarios mediante el uso de un object UIUserNotificationSettings. Este process de logging es independiente del process de logging de notifications remotas, y los usuarios deben otorgar permiso para entregar notifications a través de las opciones solicitadas.
  • Las notifications locales y push pueden include acciones personalizadas como parte de una alerta. Las acciones personalizadas aparecen como botones en la alerta. Cuando se toca, su aplicación recibe una notificación y se le solicita que realice la acción correspondiente. Las notifications locales también pueden desencadenarse mediante interacciones con las regiones de location central.

Y también leer

https://developer.apple.com/library/prerelease/ios/documentation/UIKit/Reference/UIUserNotificationSettings_class/index.html#//apple_ref/occ/cl/UIUserNotificationSettings

Y

https://developer.apple.com/library/prerelease/ios/documentation/UIKit/Reference/UIApplication_Class/index.html#//apple_ref/occ/instm/UIApplication/registerUserNotificationSettings :

Entonces, la respuesta debería ser …

 /// First register notification setting with settings type like [[UIApplication shanetworkingApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]]; [[UIApplication shanetworkingApplication] registerForRemoteNotifications]; // you can also set here for local notification. 
 - (void)registerForRemoteNotificationTypes:(NSUInteger)notificationTypes categories:(NSSet *)categories { if ([UIApplication instancesRespondToSelector:@selector(registerUserNotificationSettings:)]) { [[UIApplication shanetworkingApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:notificationTypes categories:categories]]; } else if ([UIApplication instancesRespondToSelector:@selector(registerForRemoteNotificationTypes:)]) { [[UIApplication shanetworkingApplication] registerForRemoteNotificationTypes:notificationTypes]; } } - (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings { if ([UIApplication instancesRespondToSelector:@selector(registerForRemoteNotifications)]) { [[UIApplication shanetworkingApplication] registerForRemoteNotifications]; } } 

Prueba UIUserNotificationSettings-Extension , proporciona methods de ayuda que te ayudarán a manejar el nuevo # iOS8 #Interactive #Notifications.

Aquí está:

 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions: (NSDictionary *)launchOptions { // are you running on iOS8? if ([application respondsToSelector:@selector(registerUserNotificationSettings:)]) { UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeBadge|UIUserNotificationTypeAlert|UIUserNotificationTypeSound) categories:nil]; [application registerUserNotificationSettings:settings]; } else // iOS 7 or earlier { UIRemoteNotificationType myTypes = UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound; [application registerForRemoteNotificationTypes:myTypes]; } } 

Por favor, eche un vistazo al logging proporcionado durante el time de ejecución. Al principio, sin el logging de usuarios de events locales, el logging sugiere

UILocalNotificationInfiniteRepeatCount, next fire date = Wednesday, 4 June 2014 9:27:24 pm India Standard Time, user info = (null)} with an alert but haven't received permission from the user to display alerts .

Esto es iOS 8.

Y entonces, en este caso, también debes usar

[[UIApplication shanetworkingApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert) categories:nil]];

en didFinishLaunchingWithOptions .

Esto es lo que necesita para manejar iOS 8 y cualquier cosa less que iOS 8

 if (SYSTEM_VERSION_LESS_THAN(@"8.0")) { [[UIApplication shanetworkingApplication] registerForRemoteNotificationTypes:UIRemoteNotificationTypeAlert]; [[UIApplication shanetworkingApplication] registerForRemoteNotificationTypes:UIRemoteNotificationTypeNone]; [[UIApplication shanetworkingApplication] registerForRemoteNotificationTypes:UIRemoteNotificationTypeBadge]; } else { [[UIApplication shanetworkingApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]]; [[UIApplication shanetworkingApplication] registerForRemoteNotifications]; }