0

I'm using Firebase 3.7.x to store my database. Firebase 3.7.x is support iOS 7.0 or higher but my project supports from iOS 6.0. So I want to detect iOS version in device to call@import Firebase. Something like that:

if IOS_7_OR_HIGHER@import Firebaseelse//do nothingif IOS_7_OR_HIGHER- (void)dosomething{}else- (void)donothing {}

I know aboutif #available in swift. Is there any code likeif #available in Objective C? Or is there any way to import Firebase for iOS 7 or higher and disable disable for iOS6?

Thanks.

askedMay 15, 2017 at 3:34
TienLe's user avatar
7
  • 1
    Possible duplicate ofHow to check iOS version?CommentedMay 15, 2017 at 3:36
  • @aryamccarthy: What is duplicate? I asked for iOS 6, not iOS 8.CommentedMay 15, 2017 at 3:39
  • Possible duplicate ofHow can we programmatically detect which iOS version is device running on?CommentedMay 15, 2017 at 3:39
  • The information is easily generalized. If you don't like the accepted answer, read the other answers.CommentedMay 15, 2017 at 3:40
  • @TienLe Any specific reason, why you're supporting iOS 6? FYI, Less than 1% of devices are on iOS 6.CommentedMay 15, 2017 at 3:43

3 Answers3

2

You can get device system version by using

-(NSString*)getDeviceVersion{    return [[UIDevice currentDevice] systemVersion];}

it will return you device version as string e.g. @"4.0" .

Hope it help you.

answeredMay 15, 2017 at 4:56
Shubham bairagi's user avatar
Sign up to request clarification or add additional context in comments.

Comments

0

Try below code:

    NSArray *osVersion = [[UIDevice currentDevice].systemVersion componentsSeparatedByString:@"."];    if ([[osVersion objectAtIndex:0] intValue] >= 7) {        // iOS-7 or greater    } else if ([[osVersion objectAtIndex:0] intValue] == 6) {        // iOS-6 code    } else if ([[osVersion objectAtIndex:0] intValue] > 2) {        // iOS-3,4,5 code    } else {        // iOS-1,2... code    }
answeredMay 15, 2017 at 9:24
Pravin S.'s user avatar

Comments

-2

To answer your question you can do it like this:

#ifdef __IPHONE_6_0    //Do something patchy!#else    @import Firebase#endif

Humble suggestion: You can consider upgrading your app.

A recent iOS version stats counter from Apple showing that there are only 5% devices which are still having iOS 8, 7 or <= 6. Means, you should drop out support for all those versions or you should start supporting iOS9 onwards.

By doing this you will get all the latest iOS features and you will never have to make this kind of patch in future.

enter image description here

Source:https://developer.apple.com/support/app-store/

answeredMay 15, 2017 at 3:39
Hemang's user avatar

9 Comments

You could also potentially alienate loyal users who may have been using your product on older versions of iOS too and can't run a newer version. Sometimes it's better to leave some options open...
Hi. Thanks for your comment. I knew about that. 1. Your comment is not answer for my question. 2. I have 10% users that use iOS 6. My total user are about 4M. And 10% of 4M is a big number.
@I'L'l I can support you if he's asking for iOS 7 at least, he's asking for iOS 6 and it's too old now. Even Apple is saying to upgrade your app to the latest iOS versions. At least, he can think to upgrade to iOS 7. What's wrong to get update your app to provide great features rather than not upgrading and making use of un-updated things?
@TienLe, Ok, thanks for sharing more information about your app user base. Those people may use iPhone 4/4s at least, they can surely upgrade to iOS 7. As you're having these much of users – it's likely that your app is outstanding. So if they want to use your app, they should consider to upgrade their phone to a new age.
@Hemang: Have you ever seen an older iPhone or iPad Mini with minimum specs running the latest iOS? For older devices It's best not to upgrade, as the device becomes so sluggish it's essentially useless; and not everyone can go out and buy a new one every year.
|

Your Answer

Sign up orlog in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

By clicking “Post Your Answer”, you agree to ourterms of service and acknowledge you have read ourprivacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.