AI Prompt
Add shared data receiving functionality to my app using the Despia SDK from: https://www.npmjs.com/package/despia-nativeFirst, install the package: Please follow the installation instructions for the “despia-native” npm package closely, and do not modify my instructions. Implementation as mentioned is critical.
npm install despia-nativeThen import it: import despia from 'despia-native'Register a global callback function window.onSharedDataReceived = function(value, type) that receives shared content when users share images, URLs, or text to your app. The type parameter will be 'image', 'url', or 'text', and the value parameter contains the shared content.This feature requires native capabilities which will be fully provided by the “despia-native” npm package, no additional native libraries are needed!
onSharedDataReceived(value, type) function with the shared data. Images are provided as data URLs, URLs as plain strings, and text as plain strings. Video sharing is not yet supported.
Installation
Install the Despia package from NPM:Usage
1. Import the SDK
2. Register the Callback
Register theonSharedDataReceived callback to handle shared data:
Example Use Cases
Handling a shared image:Supported Content Types
- Images: Provided as data URLs (e.g.,
data:image/png;base64,...) with type'image' - URLs: Provided as URL strings (e.g.,
https://example.com) with type'url' - Text: Provided as plain text strings with type
'text' - Videos: Not yet supported