Clipboard
Overview
You may save text to your device clipboard and retrieve the current clipboard contents via the Median JavaScript Bridge.
Developer Demo
Display our demo page in your app to test during development https://median.dev/clipboard/
Implementation Guide
Save Text to the Clipboard
Use the median.clipboard.set
method to copy a string to the device clipboard.
↔️Median JavaScript Bridge
median.clipboard.set({"data": "Save to Clipboard"});
This method sends the specified string to the system clipboard. You can use it to allow users to copy content with a single click or tap.
Retrieve Text from the Clipboard
You can retrieve the most recent clipboard content using either Promises or Callback Functions.
Using a Promise
↔️Median JavaScript Bridge
median.clipboard.get().then(function (result){ if (result.data) { alert('Received Clipboard item: ', result.data); } else { // error receiving clipboard item alert(result.error); } });
Using a Callback
↔️Median JavaScript Bridge
median.clipboard.get({"callback": "clipboardCallback"}); function clipboardCallback(result) { if (result.data) { alert('Received Clipboard item: ', result.data); } else { // error receiving clipboard item alert(result.error); } }
Updated about 2 months ago
Next Steps