使用arc不允许'unsigned long'UIUserNotificationSettings *'的隐式转换 [英] implicit conversion of 'unsigned long 'UIUserNotificationSettings *' is disallowed with arc

查看:169
本文介绍了使用arc不允许'unsigned long'UIUserNotificationSettings *'的隐式转换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

iOS 8中的推送通知无效。

Push notification in iOS 8 Doesn't work.

错误显示:

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测试版。

I'm using ios 8.0 and xcode 6 beta.

推荐答案

我来自官方的



  • 使用本地或推送通知的应用程序必须显式注册类型的警报,它们通过使用UIUserNotificationSettings对象显示给用户。此注册过程与注册远程通知的过程是分开的,用户必须授予通过请求的选项传递通知的权限。

  • 本地和推送通知可以包含自定义操作作为警报的一部分。自定义操作在警报中显示为按钮。点击时,系统会通知您的应用程序,并要求您执行相应的操作。

还可以阅读

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

..

/// 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.

这篇关于使用arc不允许'unsigned long'UIUserNotificationSettings *'的隐式转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆