Home / Build / Build your Wallet / iOS / Library Level
Manage Documents
The library provides a set of methods to work with documents.
Load Documents
The loadDocuments method returns documents with a specific status from storage.
The following example shows how to retrieve issued documents:
public func loadDocuments() async throws {
let documents = try await wallet.loadDocuments(status: .issued)
}
To retrieve documents of all statuses use the loadAllDocuments method.
let documents = try await wallet.loadAllDocuments()
The loadDocument(id:status:) method returns a document with a given id and status.
The following example shows how to retrieve a document:
let document = try await wallet.loadDocument(id: documentId, status: .issued)
Storage Manager
The read-only property storage is an instance of a StorageManager class.
Currently the keychain implementation is used. It provides document management functionality using the iOS KeyChain.
The storage model provides the following models for the supported well-known document types:
| DocType | Model |
|---|---|
| eu.europa.ec.eudiw.pid.1 | EuPidModel |
| org.iso.18013.5.1.mDL | IsoMdlModel |
Since the issued mDoc documents that are retrieved expose only basic metadata and raw data, they must be decoded into the corresponding CBOR models. The library provides the StorageManager\toClaimsModel function to decode document raw CBOR data to strongly-typed models conforming to DocClaimsDecodable protocol.
The loading functions automatically update the members of the StorageManager. The decoded issued documents are available in the docModels property. The deferred and pending documents are available in the StorageManager\deferredDocuments and StorageManager\pendingDocuments properties respectively.
For other document types the GenericMdocModel is provided.
Delete Documents
The deleteDocument(id:) method that deletes a document with the given id.
The following example shows how to delete a document:
try await wallet.deleteDocument(id: documentId)