func createContact() {
let store = CNContactStore()
let contactToAdd = CNMutableContact()
contactToAdd.phoneticGivenName = "Harshad"
contactToAdd.phoneticMiddleName = "I"
contactToAdd.phoneticFamilyName = "Pipaliya"
contactToAdd.emailAddresses.append(CNLabeledValue(label: CNLabelPhoneNumberMain, value: "[email protected]"))
let saveRequest = CNSaveRequest()
saveRequest.add(contactToAdd, toContainerWithIdentifier: nil)
do {
try store.execute(saveRequest) // Here I need to get identifier of created new contact
}
catch {
print(error)
}
}
I Tried to create an identifier from an app but I can't able to do.
Thanks In advance
This is the way to get contact id when creating contact