<!--
{
  "availability" : [
    "iOS: 15.0.0 -",
    "iPadOS: 15.0.0 -",
    "macCatalyst: 15.0.0 -",
    "macOS: 12.0.0 -",
    "tvOS: 15.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 8.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreData",
  "identifier" : "/documentation/CoreData/NSPersistentCloudKitContainer/acceptShareInvitationsFromMetadata:intoPersistentStore:completion:",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Core Data"
    ],
    "preciseIdentifier" : "c:objc(cs)NSPersistentCloudKitContainer(im)acceptShareInvitationsFromMetadata:intoPersistentStore:completion:"
  },
  "title" : "acceptShareInvitationsFromMetadata:intoPersistentStore:completion:"
}
-->

# acceptShareInvitationsFromMetadata:intoPersistentStore:completion:

Accepts one or more invitations to participate in sharing using the specified metadata.

```
- (void) acceptShareInvitationsFromMetadata:(NSArray<CKShareMetadata *> *) metadata intoPersistentStore:(NSPersistentStore *) persistentStore completion:(void (^)(NSArray<CKShareMetadata *> *acceptedShareMetadatas, NSError *acceptOperationError)) completion;
```

## Parameters

`metadata`

An array of share metadata. For more information, see <doc://com.apple.documentation/documentation/CloudKit/CKShare/Metadata>.

`persistentStore`

The persistent store that provides the CloudKit container’s identifier. The store must have the <doc://com.apple.documentation/documentation/CloudKit/CKDatabase/Scope/shared> database scope. For more information, see [`NSPersistentCloudKitContainerOptions`](/documentation/CoreData/NSPersistentCloudKitContainerOptions).

`completion`

The handler to invoke after you process the specified invitations.

## Discussion

The `completion` handler returns no value and takes the following parameters:

- An array of accepted share metadata
- An error object that contains information about a problem, or `nil` if the method successfully accepts all invitations

You typically call this method from your scene delegate’s <doc://com.apple.documentation/documentation/UIKit/UIWindowSceneDelegate/windowScene(_:userDidAcceptCloudKitShareWith:)> method. For SwiftUI apps, there are additional steps you need to complete before you can do this. For more information, see [Accepting Share Invitations in a SwiftUI App](/documentation/CoreData/accepting-share-invitations-in-a-swiftui-app).

> Note:
> To be able to accept the share invitations, this method requires an active network connection. It executes a number of CloudKit operations, and imports any shared records into the relevant persistent stores, so it may take some time to complete.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)