Take Screenshots

Make a Screenshot of the User's Current Screen for Offline Storage

The Despia Take Screenshot SDK enables your application to capture the current screen instantly. This feature enhances sharing capabilities by allowing users to capture the screen, save to camera roll, enable quick sharing, support user feedback, and simplify content capture.

Quick Start

1. Initiate Screenshot Capture

Capture the current screen with a simple command.

// Take screenshot
window.despia = "takescreenshot://"

How It Works

The Take Screenshot SDK provides a straightforward mechanism to capture the current screen state of your application. When triggered, it takes a snapshot of whatever is currently displayed on the user's device screen. This functionality works by interfacing with the device's native screenshot capabilities through the Despia bridge.

The screenshot is processed efficiently without interrupting the user experience, making it ideal for feedback collection, documentation, or sharing features within your application.

Implementation Examples

Here's a basic implementation of the Take Screenshot SDK that demonstrates how to capture the current screen:

// Take screenshot
window.despia = "takescreenshot://"

Data Structure

The Take Screenshot SDK doesn't return a specific data structure, as it triggers a native action that saves the screenshot to the device's camera roll.

Best Practices

User Experience

  • Inform users before taking screenshots

  • Provide visual feedback when a screenshot is taken

  • Allow users to preview screenshots before sharing

Implementation

  • Include error handling for devices that don't support the feature

  • Consider privacy implications when capturing screens with sensitive information

  • Test the feature across different device types and screen sizes

Complete Implementation Example

Here's a complete implementation that includes user notification and error handling:

function captureScreenshot() {
  try {
    // Notify user that screenshot is being taken
    displayNotification("Capturing screenshot...");
    
    // Take screenshot
    window.despia = "takescreenshot://";
    
    // Confirm successful capture
    displayNotification("Screenshot saved to camera roll");
  } catch (error) {
    console.error("Screenshot capture failed:", error);
    displayNotification("Failed to capture screenshot");
  }
}

// Example usage
document.getElementById("screenshotButton").addEventListener("click", captureScreenshot);

Troubleshooting

Common Issues

Permission Denied

  • Ensure the app has proper permissions to save to camera roll

  • Request permissions explicitly before attempting to capture

  • Check device privacy settings

Screenshot Not Saving

  • Verify the Despia bridge is properly initialized

  • Check for storage permission issues

  • Ensure there is sufficient storage space on the device

Need Help?

For additional support or questions, please contact our support team at support@despia.com

Updated on