setClipboardData(params: Object)

Requires:
BaseKit≥2.0.1@ray-js/ray≥0.3.23
Platforms:
iOSAndroid
import { setClipboardData } from '@ray-js/ray';

// Promise usage
try {
  const res = await setClipboardData({ ...params });
  console.log(res);
} catch (err) {
  console.log(err.errorMsg);
}

Description

Set the system clipboard content

Parameters

PropertyTypeRequiredDefaultDescriptionBaseKit Since
isSensitivebooleanNofalseWhether the content is sensitive true: yes; false: no; default is non-sensitive If sensitive, it can prevent sensitive content from appearing in any content preview shown in the clipboard copy visual confirmation on Android 13 and later Note: This property only applies to devices running Android 13 or laterv3.2.0
datastringYes-Clipboard content-
complete() => voidNo-Completion callback (executed on both success and failure)-
success() => voidNo-Callback on successful API call-
fail(params: Object) => voidNo-Failure callback-
fail callback parameters
PropertyTypeDescription
errorMsgstringError message
errorCodestring | numberError code
Error extension

Return Value

None

Examples

import { setClipboardData } from '@ray-js/ray'

// Set system clipboard content (isSensitive marks whether the data is sensitive; effective on Android 13+ only)
setClipboardData({
  data: "Hello Tuya",
  isSensitive: false,
  success: () => console.log("Copied to clipboard"),
  fail: error => console.error(error),
});