ios – UIRemoteNotificationTypeAlert已弃用 – 如何与大型团队一起过渡到UIUserNotificationTypeAlert?

我想快速转换出已弃用的推送通知常量,但顺利.我知道实现远程和本地通知方法也发生了变化,但这超出了本问题的范围.

以下是应考虑的一些因素/约束:

>我有一个相当庞大的iOS开发团队.
>一些开发人员仍在使用xCode 5,它不能使用iOS 8 API进行编译.
>一些开发人员已经在使用xCode 6.2 Beta 3,它使用xCode 6.1.1中没有的额外WatchKit目标.
>绝大多数开发人员都在使用xCode 6.1.1.

谢谢您的帮助!

解决方法

幸运的是,这是相当直接的.您需要做的就是使用编译器指令,最好是在推送通知中心的头文件中.在条件指令中,您可以使用定义将自己的常量集映射到新集或不建议集,具体取决于xCode支持的最新iOS版本.
#ifdef __IPHONE_8_0
    #define RemoteNotificationTypeAlert UIUserNotificationTypeAlert
    #define RemoteNotificationTypeBadge UIUserNotificationTypeBadge
    #define RemoteNotificationTypeSound UIUserNotificationTypeSound
    #define RemoteNotificationTypeNone  UIUserNotificationTypeNone
#else
    #define RemoteNotificationTypeAlert UIRemoteNotificationTypeAlert
    #define RemoteNotificationTypeBadge UIRemoteNotificationTypeBadge
    #define RemoteNotificationTypeSound UIRemoteNotificationTypeSound
    #define RemoteNotificationTypeNone  UIRemoteNotificationTypeNone
#endif

相关文章

UITabBarController 是 iOS 中用于管理和显示选项卡界面的一...
UITableView的重用机制避免了频繁创建和销毁单元格的开销,使...
Objective-C中,类的实例变量(instance variables)和属性(...
从内存管理的角度来看,block可以作为方法的传入参数是因为b...
WKWebView 是 iOS 开发中用于显示网页内容的组件,它是在 iO...
OC中常用的多线程编程技术: 1. NSThread NSThread是Objecti...