6

MSConversation は、ローカルの参加者とリモートの参加者を提供します。ただし、self または other の表示名を取得できません。これらの名前を取得するにはどうすればよいですか? https://developer.apple.com/reference/messages/msconversation

let ids = activeConversation?.remoteParticipantIdentifiers
let otherId = ids?[0].uuidString
let ownId = activeConversation?.localParticipantIdentifier.uuidString
let predicate = CNContact.predicateForContacts(withIdentifiers: [otherId!]);

do { 
    let contacts = try CNContactStore().unifiedContacts(matching: predicate, keysToFetch: [CNContactFamilyNameKey, CNContactGivenNameKey, CNContactNicknameKey, CNContactIdentifierKey])

    for contact in contacts{
        print(contact.givenName)
        print(contact.familyName)
        print(contact.identifier)
    }

} catch let err{
    print(err)
}

上記のように CNContactsStore を検索しようとしましたが、MSConversation の UUID は CNContact とは異なります。

4

1 に答える 1