Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIRemoteNotificationTypeAlert is deprecated - how do I transition to UIUserNotificationTypeAlert with a large team?

I would like to transition away from the deprecated Push Notification constants quickly, but smoothly. I understand that the approach in implementing remote and local notifications have also changed, but that is outside the scope of this question.

Here are some factors/constraints that should be considered:

  1. I have a fairly large team of iOS developers.
  2. Some developers are still using xCode 5, which doesn't compile with iOS 8 API.
  3. Some developers are already using xCode 6.2 Beta 3, which uses an additional WatchKit target that is not available in xCode 6.1.1.
  4. The vast majority of developers are using xCode 6.1.1.

Thank you for your help!

like image 347
norton9000 Avatar asked Jan 14 '15 04:01

norton9000


1 Answers

Fortunately this is fairly straight forward. All you need to do is use a compiler directive, preferably in a header file central to your Push Notifications. In the conditional directive, you can map your own set of constants, using defines, to either the new set, or the deprecated set, depending on the latest iOS version that your xCode supports.

#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
like image 148
Sheamus Avatar answered Oct 19 '22 16:10

Sheamus