Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot share with UICloudSharingController; vanishes with "uploading" message

while presenting the UICloudSharingController on top of a view, it presents the screen and when I select the messages option to send a message to a person whom I want to share with, it gives a spinning wheel with "uploading" message and vanishes - attachedscreenshot.

However when I go to cloudkit dashboard the root record has been shared. But I cannot share it with specific person. Is it because it has shared global? How can I fix it?

self.shareInfraRecord(zoneID: appDelegate.privateContactZoneID, completion: { (status) in
     if ( status == false) {
             return
      }
    })

func shareInfraRecord(zoneID: CKRecordZone.ID, completion: @escaping(Bool) -> Void) {
    
    if let rootRecord = self.rootRecord {
        if self.rootRecord?.share == nil {
            let sharingController = UICloudSharingController { (controller, preparationHandler: @escaping (CKShare?, CKContainer?, Error?) -> Void) in
                
                let shareID = CKRecord.ID(recordName: UUID().uuidString, zoneID: zoneID)
                var share = CKShare(rootRecord: rootRecord, shareID: shareID)
               
                share[CKShare.SystemFieldKey.title] = Cloud.ShareInfrastructure.ContactShareTitleKey as CKRecordValue?
                share[CKShare.SystemFieldKey.shareType] = Cloud.ShareInfrastructure.ContactShareTypeKey as CKRecordValue?
               
                let modifyRecZoneOp = CKModifyRecordsOperation(recordsToSave:[rootRecord, share], recordIDsToDelete: nil)
                modifyRecZoneOp.modifyRecordsCompletionBlock = { (records, recordID, error) in
                    if error != nil {
                        if let ckerror = error as? CKError {
                            if let serverVersion = ckerror.serverRecord as? CKShare {
                                share = serverVersion
                            }
                            completion(false)
                        }
                    }
                    preparationHandler(share, self.defaultContainer, error)

                }
                self.privateDB?.add(modifyRecZoneOp)
            }
        
            sharingController.availablePermissions = [.allowReadOnly, .allowPrivate]
            sharingController.delegate = self
            sharingController.popoverPresentationController?.sourceView = self.view
        
            self.present(sharingController, animated:true, completion:nil)

    } else {
            let shareRecordID = rootRecord.share!.recordID
            let fetchRecordsOp = CKFetchRecordsOperation(recordIDs: [shareRecordID])
        
            fetchRecordsOp.fetchRecordsCompletionBlock = { recordsByRecordID, error in
                guard error == nil, let share = recordsByRecordID?[shareRecordID] as? CKShare  else {
                    if let ckerror = error as? CKError {
                        self.aErrorHandler.handleCkError(ckerror: ckerror)
                        //self.saveToCloudKitStatus(recordName: myRecordName, success: false)
                    }
                    completion(false)
                    return
                }
               
                DispatchQueue.main.async {
                    let sharingController = UICloudSharingController(share: share, container: self.defaultContainer!)
                    completion(true)
                    //completionHandler(sharingController)
                }
            }
            self.privateDB?.add(fetchRecordsOp)
        }
    }
}
like image 446
vrao Avatar asked Aug 30 '20 22:08

vrao


People also ask

Why can’t I upload folders?

If you need to upload folders, please use a different web browser. Check your network connection to Box. If connected to the internet with a wireless card, check to see if the connection to the internet drops intermittently. If this is the case, we recommend the Upload Folders method.

Why can’t I upload to box?

You may find that your anti-virus software includes a built-in firewall. If you are attempting to access Box from an office setting and experience upload issues, then please contact your IT administrator or internal Help Desk. Proxy servers may sometimes cause failed uploads. If you see the error message: An error occurred with the upload.

Why is my upload taking so long to upload?

If you find that your upload is taking longer than it should, we have listed a few reasons that may affect upload speeds. Firewalls: Firewalls can slow down or block the upload process. If you use third-party software, try temporarily turning off firewalls such as ZoneAlarm, the built-in Windows or Mac firewall, or any others.

Why can't I upload to my proxy server?

Proxy servers may sometimes cause failed uploads. If you see the error message: An error occurred with the upload. Please refresh the page and try again. Please contact your IT department or Help Desk and ask them to check your proxy configuration. Slow upload speeds can have a variety of causes.


1 Answers

This might be a bit late but I was running into this issue too, while using NSPersistentCloudKitContainer and it seems the issue was just making sure that my iCloud container name in the Capabilities section of the settings matched my app bundle name ie iCloud.com.goddamnyouryan.MyApp

like image 96
goddamnyouryan Avatar answered Sep 24 '22 06:09

goddamnyouryan