CKContainer shareParticipant() 'missing' nameComponents

My App requires access to iCloud. I used to be able to get the User's name components (family+given name) using:

            let dummyZone     = CKRecordZone (zoneName: UUID().uuidString)
            let dummyShare    = CKShare (recordZoneID: dummyZone.zoneID)

            Persistence.logger.notice ("\(#function): Dummy Zone: \(dummyZone.zoneID.zoneName)")

            // Save the dummyZone and then the dummyShare (for/in the dummyZone)
            let _ = try await container.privateCloudDatabase.save (dummyZone)
            let _ = try await container.privateCloudDatabase.save (dummyShare)

            // Extract the dummyShare's owner's identity - which is 'us/me'
            let userIdentity = dummyShare.owner.userIdentity

where the resulting userIdentity had a filled out nameComponents. Now, recently, it seems to be empty.

Did something change in the interfaces?

I've also tried, more directly:

            let userRecordID = try await container.userRecordID()
            let userParticipant = try await container.shareParticipant(forUserRecordID: userRecordID)
            let userIdentity = userParticipant.userIdentity

and still nameComponents is empty.

Given that my App requires iCloud, is there a way to get (familyName,givenName)?

The issue you described doesn't seem to happen to me – I verified with the following steps:

  1. Follow the Readme to set up and run the Sharing Core Data objects between iCloud users sample on my devices.

  2. Share a photo from the owner side and accept the share from the participant side.

  3. On the participant side, long tap the accepted photo to show the menu, and then tap Participants to show the participant view.

  4. Observe that the name shows up in the list.

I ran the app with Xcode 16.0 (16A242d) on my iPhone XR + iOS 17.6.1 (the owner side) and iPhone 16+ + iOS 18.0.1 (the participant side).

I am wondering if you could check with the sample if you see the same thing...

Best,
——
Ziqiao Chen
 Worldwide Developer Relations.

(First, see comments to your reply)

I also tried modifying presentCloudSharingController as such:

func presentCloudSharingController(photo: Photo) {
        self.cloudKitContainer.fetchUserRecordID { recordID, recordIDError in
            if let id = recordID, nil == recordIDError {
                self.cloudKitContainer.fetchShareParticipant(withUserRecordID: id) { participant, participantError in
                    if let p = participant, nil == participantError {
                        let participantIdentity = p.userIdentity
                        print ("CDS: Identity: \(participantIdentity.description)")

                        if let participantName = participantIdentity.nameComponents {
                            print ("CDS: Identity Name: \(participantName.description.isEmpty ? "<none>" : participantName.description)")
                        }

                    }
                    else { print ("CDS: Error `fetchShareParticipant") }
                }
            }
            else { print ("CDS: Error `fetchUserRecordID") }
        }

        ...
    }

The resulting output is:

CDS: Identity: <CKUserIdentity: 0x301da83c0; userID=_bfbb377f5fb38b76ecb9b35c3d050c79:(_defaultZone:__defaultOwner__), nameComponents=, lookupInfo=<CKUserIdentityLookupInfo: 0x303765590; userRecordID=_bfbb377f5fb38b76ecb9b35c3d050c79:(_defaultZone:__defaultOwner__)>, cached=false, publicKeyVersion=2>
CDS: Identity Name: <none>

Again the nameComponents are empty.

CKContainer shareParticipant() 'missing' nameComponents
 
 
Q