Skip to main content
Unveilydocs

Share & Save

Export content to the native share sheet, or save it to the gallery / downloads.

Overview

Send images, files, text, or URLs created in your web app to other apps through the native share sheet, or save them to the gallery (Photos) / Downloads folder. If openFileSelector is the bridge that imports content, this bridge is its export counterpart.

MethodSupported typesAndroidiOS
shareimage · file · text · url
saveToDeviceimage · file

Available on: Basic and above

unveilyBridge is injected into the WebView automatically. No initialization is needed — use it right away.

Prerequisites

Android

  • share: no extra permission required.
  • saveToDevice: no permission needed on Android 10 (API 29) and above. Only Android 9 (API 28) and below require WRITE_EXTERNAL_STORAGE, which the SDK requests at runtime automatically.

iOS

  • share: no extra permission required.
  • saveToDevice(image): saves to the photo library, so add the following to Info.plist.
<key>NSPhotoLibraryAddUsageDescription</key>
<string>Save content you create to your photo library.</string>
  • saveToDevice(file): saves to the Files app and needs no extra permission.

Sharing — share

Hands content to the native share sheet. Options are passed as an object.

// Share text / URL
window.unveilyBridge.share({
  type: "url",
  data: "https://example.com/article/42",
  callback: "onShareResult"
});

// Share an image (base64 or a local path/URI)
window.unveilyBridge.share({
  type: "image",
  data: base64OrPath,       // "data:image/png;base64,..." or "/path", "content://..."
  mimeType: "image/png",
  filename: "receipt.png",
  callback: "onShareResult"
});
OptionTypeDescription
typestring'image' · 'file' · 'text' · 'url'
datastringtext·url → the string. image·file → base64 (raw or data URI) or a local path/URI (/…, file://…, content://…)
mimeTypestring(optional) e.g. image/png, application/pdf
filenamestring(optional) name of the shared file
callbackstringName of the global function to receive the result. Defaults to 'onShareResult'

For large images or files, pass a local path/URI instead of base64. Base64 inflates the size by about 33% and can cause memory issues with large media.


Save to device — saveToDevice

Images are saved to the gallery (Photos) and files to the Downloads folder, under an Unveily subfolder.

// Save an image to the gallery
window.unveilyBridge.saveToDevice({
  type: "image",
  data: base64OrPath,
  mimeType: "image/png",
  filename: "chart.png",
  callback: "onSaveResult"
});

// Save a file to Downloads
window.unveilyBridge.saveToDevice({
  type: "file",
  data: base64OrPath,
  mimeType: "application/pdf",
  filename: "invoice.pdf",
  callback: "onSaveResult"
});
OptionTypeDescription
typestring'image' · 'file'
datastringbase64 (raw or data URI) or a local path/URI
mimeTypestring(optional) defaults: image image/png, file application/octet-stream
filenamestring(optional) name of the saved file
callbackstringName of the global function to receive the result. Defaults to 'onSaveResult'

Callback result

The global function named in callback is invoked with a result object.

function onShareResult(result) {
  if (result.success) {
    // done
  } else if (result.canceled) {
    // user canceled (iOS)
  } else {
    console.log("failed:", result.error);
  }
}
ResultMeaning
{ success: true }Success
{ success: false, canceled: true }User canceled
{ success: false, error: "<code>" }Failure (e.g. invalid_data, unsupported_type)

Platform difference — Android's share sheet cannot reliably report which app the user picked or whether they canceled, so success for share means "the share sheet was opened." iOS distinguishes completion from cancellation and reports canceled. saveToDevice reports the actual save success/failure accurately on both platforms.

On this page