app.share - macOS Sharing Services API

Use NSSharingService to invoke the system sharing panel (AirDrop, Mail, Messages, etc.).

Methods

app.share.show(items)

Show the system sharing panel, allowing the user to choose a sharing method.

Parameters:

  • items (string|array) - content to share:
    • File paths (automatically converted to file URLs)
    • HTTP/HTTPS links (automatically converted to URLs)
    • Plain text

Returns: boolean, error

-- Share a single file
app.share.show("/path/to/file.pdf")

-- Share multiple files
app.share.show({"/path/to/a.png", "/path/to/b.png"})

-- Share text
app.share.show("Hello, World!")

-- Share a URL
app.share.show("https://example.com")

-- Mixed content
app.share.show({"/path/to/file.txt", "https://example.com"})

app.share.services(items?)

List available sharing services.

Parameters:

  • items (string|array, optional) - content to share (affects available services list)

Returns: array<table> - each item contains:

  • name (string) - service identifier name
  • title (string) - service display title
local services = app.share.services()
for _, s in ipairs(services) do
    app.log.info(s.name .. " → " .. s.title)
end

-- View available sharing services for a specific file
local services = app.share.services({"/path/to/photo.jpg"})

app.share.sendTo(serviceName, items)

Share content directly through a specific service (without showing the panel).

Parameters:

  • serviceName (string) - service name, supports:
    • Built-in names: "email", "message", "airdrop"
    • Service titles (obtained from services())
  • items (string|array) - content to share

Returns: boolean, error

-- Share via email
app.share.sendTo("email", {"/path/to/report.pdf"})

-- Share via AirDrop
app.share.sendTo("airdrop", {"/path/to/photo.jpg"})

-- Share via Messages
app.share.sendTo("message", "Check this out: https://example.com")

Description

  • The sharing panel appears near the mouse cursor position
  • When using sendTo() with built-in service names, there’s no need to call services() first
  • Built-in service name mappings: email → Mail, message → Messages, airdrop → AirDrop
  • File paths are automatically detected and converted to file URLs
  • Strings starting with HTTP/HTTPS are automatically converted to URLs

Examples

Share Selected Files via Context Menu

function MyPlugin:handleShare(context)
    local files = context.selectedFiles
    if #files == 0 then
        app.dialog.alert("Note", "Please select files first")
        return
    end

    app.share.show(files)
end

Send Files via Email

function MyPlugin:handleEmailFiles(context)
    local files = context.selectedFiles
    local ok, err = app.share.sendTo("email", files)
    if not ok then
        app.log.error("Share failed: " .. (err or "unknown"))
    end
end
Developer Documentation
User Guide
Getting Started Script Menus FAQ
Script Development
Development Guide
Plugin Development
Quick Start Development Guide Example Plugins
API Reference
Overview API Query Plugin Info Logging Finder Context Plugin Settings Internationalization
UI & Interaction
Dialog Progress Notification Chooser WebView Status Bar Dock
Files & Paths
File Operations Path Utilities Finder Actions Trash Extended Attributes Metadata File Watcher
Data Formats
JSON Plist CSV XML PDF Image
Text & Encoding
String Regex Date & Time Color Crypto
System
Shell Commands Process Application System Info AppleScript Shortcuts
System Info
Network Power/Battery Screen/Appearance Audio Bluetooth Location
Network
HTTP WebSocket URL
Input & Clipboard
Keyboard Mouse Hotkey Clipboard Window
Storage
SQLite Keychain UserDefaults
Media
OCR QR Code
Utilities
Archive UTI Share Timer Wake Lock Thread