AddressBook and Contacts framework in iOS 8.0 and 9.0

3.4k views Asked by At

I am trying to build an app that fetches contact list from users contacts and renders it in Custom UI of app. I want to support iOS 8 and iOS9 But the problem is methods of AddressBook framework are deprecated in iOS9 and Contacts Framework will not support iOS 8.0. Is there's a way I can support both 8 & 9 for this?

Thanks in Advance!

2

There are 2 answers

2
Varun On BEST ANSWER

You have to implement both the code, if you want to support both iOS versions.

You have to check for iOS versions as below, for Objective-C

NSComparisonResult order = [[UIDevice currentDevice].systemVersion compare: @"9.0" options: NSNumericSearch];
if (order == NSOrderedSame || order == NSOrderedDescending) {
    // OS version >= 9.0
    // Call contact address book function
} else {
    // OS version < 9.0
    // Call address book function
}

For swift,

if #available(iOS 9.0, *) {
    // OS version >= 9.0
    // Call contact address book function
} else {
    // OS version < 9.0
    // Call address book function
}
1
Ted On

Besides checking for iOS 8 and iOS 9 to call functions,

make sure the framework that's not available on iOS 8 is set as Optional

enter image description here