Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Push notification in iOS 8 Doesn't work.

Error display:

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

Code:

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

enter image description here I'm using ios 8.0 and xcode 6 beta.

like image 963
user3701584 Avatar asked Jun 03 '14 04:06

user3701584


1 Answers

I am getting from below from official documentation of iOS 8.

  • Apps that use local or push notifications must explicitly register the types of alerts that they display to users by using a UIUserNotificationSettings object. This registration process is separate from the process for registering remote notifications, and users must grant permission to deliver notifications through the requested options.
  • Local and push notifications can include custom actions as part of an alert. Custom actions appear as buttons in the alert. When tapped, your app is notified and asked to perform the corresponding action. Local notifications can also be triggered by interactions with Core Location regions.

And also read

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

AND

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

So Answer should be..

/// First register notification setting with settings type like 
[[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]];
[[UIApplication sharedApplication] registerForRemoteNotifications]; // you can also set here for local notification.
like image 102
iPatel Avatar answered Sep 20 '22 22:09

iPatel