KNContactsPicker remove empty phone numbers while picking contact swift

 Problem:

I had used KNContactsPicker for adding contacts in my app.But it fetches empty phone numbers also .How to avoid fetching empty contacts swift?


Solution:

KNcontact picker had settings.You can also select multiple contacts.You can use the condition as below that 

"!contact.phoneNumbers.isEmpty".For fetching the contacts.


Code:


import KNContactsPicker    

var settings = KNPickerSettings() 

settings.selectionMode = .multiple

settings.subtitleDisplayInfo = .phoneNumber

settings.conditionToDisplayContact = { contact in

                return !contact.phoneNumbers.isEmpty

            }

let controller = KNContactsPicker(delegateselfsettingsself.settings)

self.navigationController?.present(controller, animatedtruecompletionnil)


Comments

Popular posts from this blog

Invalid bundle error while upload the app to the app Store

Convert NsNumber, NSDate to String in iOS Swift

Global LocationManager Singleton class iOS Swift