---
title: "registerCKShare(container:allowedSharingOptions:preparationHandler:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/nsitemprovider/registerckshare(container:allowedsharingoptions:preparationhandler:)"
---

# registerCKShare(container:allowedSharingOptions:preparationHandler:)

Creates and registers a new collaboration object using a collection of records to share.

## Declaration

```swift
func registerCKShare(container: CKContainer, allowedSharingOptions: CKAllowedSharingOptions = CKAllowedSharingOptions.standard, preparationHandler: @escaping @Sendable () async throws -> CKShare)
```

## Parameters

- `container`: A doc://com.apple.documentation/documentation/CloudKit/CKContainer the system uses to coordinate all the interactions between your app and the server.
- `allowedSharingOptions`: The doc://com.apple.documentation/documentation/CloudKit/CKAllowedSharingOptions. The standard option is the default.
- `preparationHandler`: The handler the system calls in your app to create a new doc://com.apple.documentation/documentation/CloudKit/CKShare.

## Discussion

Discussion Use this method to share a collection of CKRecord objects that don’t have an existing CKShare assignment. When the system calls the preparationHandler, your app creates a new CKShare with the appropriate root CKRecord or CKRecordZone.ID. After the server successfully saves the share, invoke the CKSharePreparationCompletionHandler with either the resulting CKShare, or an NSError if the save fails. When the system invokes the share sheet with a CKShare that you register with this method, it prompts the user to start sharing.

## See Also

### Registering CloudKit shares

- [registerCloudKitShare(_:container:)](foundation/nsitemprovider/registercloudkitshare(_:container:).md)
- [registerCloudKitShare(preparationHandler:)](foundation/nsitemprovider/registercloudkitshare(preparationhandler:).md)
- [registerCKShare(_:container:allowedSharingOptions:)](foundation/nsitemprovider/registerckshare(_:container:allowedsharingoptions:).md)
