iOS 8中的推送通知不起作用.
implicit conversion of 'unsigned long 'UIUserNotificationSettings *' is disallowed with arc
码:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { [application registerUserNotificationSettings:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge)]; return YES; }
我正在使用ios 8.0和xcode 6 beta.
解决方法
我从
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.
还读了
和
所以答案应该是……
/// 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.