Where to find Foundation Framework Version Numbers macros and what is the way to interact with preprocessor

Hi,
I’m trying to write the java code corresponding to this

 if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_9_x_Max) {
      UIUserNotificationType allNotificationTypes =
      (UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge);
      UIUserNotificationSettings *settings =
      [UIUserNotificationSettings settingsForTypes:allNotificationTypes categories:nil];
      [[UIApplication sharedApplication] registerUserNotificationSettings:settings];
    } else {
      // iOS 10 or later
      #if defined(__IPHONE_10_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
      // For iOS 10 display notification (sent via APNS)
      [UNUserNotificationCenter currentNotificationCenter].delegate = self;
      UNAuthorizationOptions authOptions =
          UNAuthorizationOptionAlert
          | UNAuthorizationOptionSound
          | UNAuthorizationOptionBadge;
      [[UNUserNotificationCenter currentNotificationCenter] requestAuthorizationWithOptions:authOptions completionHandler:^(BOOL granted, NSError * _Nullable error) {
          }];
      #endif
    }
    [[UIApplication sharedApplication] registerForRemoteNotifications];

I couldn’t find any equivalent java constants for the macros mentioned in this code. Also what is alternative way to use the preprocessor directive “#if defined” .

thanks in advance

Hi!

Version number available in the Foundation:

double versionNumber = Foundation.NSFoundationVersionNumber();

Constants values:

    public static double NSFoundationVersionNumber_iPhoneOS_2_0 = 678.24;
    public static double NSFoundationVersionNumber_iPhoneOS_2_1 = 678.26;
    public static double NSFoundationVersionNumber_iPhoneOS_2_2 = 678.29;
    public static double NSFoundationVersionNumber_iPhoneOS_3_0 = 678.47;
    public static double NSFoundationVersionNumber_iPhoneOS_3_1 = 678.51;
    public static double NSFoundationVersionNumber_iPhoneOS_3_2 = 678.60;
    public static double NSFoundationVersionNumber_iOS_4_0 = 751.32;
    public static double NSFoundationVersionNumber_iOS_4_1 = 751.37;
    public static double NSFoundationVersionNumber_iOS_4_2 = 751.49;
    public static double NSFoundationVersionNumber_iOS_4_3 = 751.49;
    public static double NSFoundationVersionNumber_iOS_5_0 = 881.00;
    public static double NSFoundationVersionNumber_iOS_5_1 = 890.10;
    public static double NSFoundationVersionNumber_iOS_6_0 = 992.00;
    public static double NSFoundationVersionNumber_iOS_6_1 = 993.00;
    public static double NSFoundationVersionNumber_iOS_7_0 = 1047.20;
    public static double NSFoundationVersionNumber_iOS_7_1 = 1047.25;
    public static double NSFoundationVersionNumber_iOS_8_0 = 1140.11;
    public static double NSFoundationVersionNumber_iOS_8_1 = 1141.1;
    public static double NSFoundationVersionNumber_iOS_8_2 = 1142.14;
    public static double NSFoundationVersionNumber_iOS_8_3 = 1144.17;
    public static double NSFoundationVersionNumber_iOS_8_4 = 1144.17;
    public static double NSFoundationVersionNumber_iOS_8_x_Max = 1199;
    public static double NSFoundationVersionNumber_iOS_9_0 = 1240.1;
    public static double NSFoundationVersionNumber_iOS_9_1 = 1241.14;
    public static double NSFoundationVersionNumber_iOS_9_2 = 1242.12;
    public static double NSFoundationVersionNumber_iOS_9_3 = 1242.12;
    public static double NSFoundationVersionNumber_iOS_9_4 = 1280.25;
    public static double NSFoundationVersionNumber_iOS_9_x_Max = 1299;

If you need version check, please try:

UIDevice.currentDevice().systemVersion();

Best Regards:
Roland

1 Like

Thanks a Ton, Vighr.