将联系人地址保存到Unified Contact会导致(CNErrorDomain错误500)

Har*_*ish 6 facebook ios swift cncontact

我的应用程序中有一个奇怪的错误,我找不到任何解决方法/修复程序.出于某种原因,我能够将地址保存到与社交个人资料(Facebook,Twitter等)不统一的联系人.但是,当我尝试为与Facebook或Twitter统一的联系人添加地址时,我收到一个奇怪的保存错误:

The operation couldn’t be completed. (CNErrorDomain error 500.)
Run Code Online (Sandbox Code Playgroud)

以下是我正在使用的一些代码:

    if mutableContact.isKeyAvailable(CNContactPostalAddressesKey) {
        var postalAddresses = [CNLabeledValue<CNPostalAddress>]()

        for address in self.contactAddresses {
            let postalAddress: CNLabeledValue<CNPostalAddress> = CNLabeledValue(label: CNLabelOther, value: address)
            postalAddresses.append(postalAddress)
        }

        mutableContact.postalAddresses = postalAddresses
    }

    let saveRequest = CNSaveRequest()

    if isNewContact {
        saveRequest.add(mutableContact, toContainerWithIdentifier: nil)
    } else {
        saveRequest.update(mutableContact)
    }

    do {
        try contactStore.execute(saveRequest)
    } catch let error as NSError {
        print(error.localizedDescription)
        let alertController = UIAlertController(title: "Failed to save/update contact!", message: "Unfortunatly, the app couldn't add or make modifications to your contact. Please try again or use the Contacts app to preform changes.", preferredStyle: .alert)
        let cancelAction = UIAlertAction(title: "Okay", style: .cancel) {
            action in
            self.dismiss(animated: true, completion: nil)
        }
        alertController.addAction(cancelAction)
        self.present(alertController, animated: true, completion: nil)
    }
Run Code Online (Sandbox Code Playgroud)

Har*_*ish 1

好的,我已经收到 Apple 的回复,这种行为是有意为之的。开发人员应检测到此政策违规行为,然后提出创建新联系人,然后链接这两个联系人。