add(_:metadata:)
Adds the specified item and metadata to the journal and begins transferring the data to the other participants’ devices so they can access it.
Declaration
final func add<ItemType, MetadataType>(_ item: ItemType, metadata: MetadataType) async throws -> GroupSessionJournal.Attachment where ItemType : Transferable, MetadataType : Decodable, MetadataType : EncodableParameters
- item:
The item to send to other session participants. The type you specify must conform to the Transferable protocol. For more information about creating transferable types, see Coretransferable.
- metadata:
Custom metadata to include with the item. Specify a Codable type that contains information to help your app interpret or process the item on other devices. For example, you might include app-specific details that aren’t part of the item’s intrinsic data format.
Return Value
An attachment object you can remove by passing it to the remove(attachment:) function.
Discussion
Call this method when you want to send a file or codable data type to the other participants of an activity. The method runs asynchronously and can return before the upload operation finishes.