AttachmentsService provides everything you need to work with iMessage file attachments. You can count and inspect attachments by GUID, download them (with an optional force-download for files not yet cached on the Mac), generate BlurHash preview strings for images, retrieve Live Photo counterparts, and upload files to the server before composing multipart messages.
Access the service via your initialized client:
Attachment metadata
getAttachmentCount()
Fetch the total number of attachments stored in your iMessage account on the server device.
get()
Fetch an attachment’s full database record by its GUID.
The GUID of the attachment to look up.
getAttachmentBlurhash()
Generate a BlurHash string for an image attachment. You can optionally pre-resize the image before hashing to reduce computation time.
The GUID of the image attachment to generate a BlurHash for.
Generating a BlurHash is computationally intensive. If the attachment is large, consider specifying resize dimensions in the query string (if your server version supports it) to significantly reduce generation time.
Uploading attachments
uploadAttachment()
Upload a file to the server’s iMessage attachments directory. You must call this before including an attachment in a multipart message via MessagesService.sendMultipartMessage(). It is not required when sending a standalone attachment with MessagesService.sendAttachment().
Multipart form data containing the file to upload.
data.hash string — a unique identifier (UUID) you use as the attachment value in each multipart message part.
Downloading attachments
download()
Download an iMessage attachment by its GUID. Returns the file binary. If the file has not been downloaded to the Mac yet, this returns a 404.
The GUID of the attachment to download.
If the attachment has not yet been downloaded to the macOS server, this endpoint returns a
404. Use forceDownloadAttachment() instead if you need to trigger a download for an attachment that isn’t cached locally.forceDownloadAttachment()
Force-download an attachment by GUID, triggering the macOS server to fetch the file from Apple’s servers if it isn’t already cached locally. Requires the Private API.
The GUID of the attachment to force-download.
Live Photos
getAttachmentLivePhoto()
Retrieve the Live Photo counterpart (a short .mov video) for an image attachment that was sent as a Live Photo.
The GUID of the attachment to retrieve the Live Photo for.
If the attachment is not an image or does not have a Live Photo version, this method returns an error indicating that no live photo exists for the given GUID.