微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

原文地址:https://www.jb51.cc/iOS/331847.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐