Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check contact source in CNContact swift?

In Contact apps there's group like "iCloud", "yahoo", "gmail". In swift, is it possible to fetch contact from gmail source only?

like image 457
Aldo Lazuardi Avatar asked Aug 08 '16 09:08

Aldo Lazuardi


1 Answers

Tested code. Hope it will solve your problem...

   func getAppropriateName(for container: CNContainer?) -> String? {
        var name = ""
        if (container?.name == "Card") || container?.name == nil {
            name = "iCloud"
        }
        else if (container?.name == "Address Book") {
            name = "Google"
        }
        else if (container?.name == "Contacts") {
            name = "Yahoo"
        }
        else {
            name = "Facebook"
        }
        return name
    }
like image 187
emraz Avatar answered Sep 29 '22 20:09

emraz