Parameters
Code Example
Basic Usage
Show Share Prompt
Track Screenshot Events
Sensitive Content Warning
Related APIs
my.offUserCaptureScreen
Stop listening for screenshots
my.showSharePanel
Show share panel
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Listen for user screenshot events.
| Property | Type | Required | Description |
|---|---|---|---|
| callback | Function | Yes | Callback function when user takes a screenshot |
my.onUserCaptureScreen(() => {
console.log('User took a screenshot');
});
Page({
onLoad() {
my.onUserCaptureScreen(() => {
my.confirm({
title: 'Screenshot Captured',
content: 'Would you like to share this screenshot?',
confirmButtonText: 'Share',
cancelButtonText: 'Cancel',
success: (res) => {
if (res.confirm) {
my.showSharePanel();
}
}
});
});
},
onUnload() {
my.offUserCaptureScreen();
}
});
App({
onLaunch() {
my.onUserCaptureScreen(() => {
// Log screenshot event for analytics
this.logEvent('screenshot_taken', {
page: getCurrentPages().pop()?.route,
timestamp: Date.now()
});
});
},
logEvent(name, data) {
my.request({
url: 'https://api.example.com/analytics',
method: 'POST',
data: { event: name, ...data }
});
}
});
Page({
onLoad() {
if (this.data.containsSensitiveInfo) {
my.onUserCaptureScreen(() => {
my.alert({
title: 'Privacy Notice',
content: 'This page contains sensitive information. Please be careful when sharing screenshots.'
});
});
}
},
onUnload() {
my.offUserCaptureScreen();
}
});