my.call("allowSystemSnapshot")
Function
my.call("allowSystemSnapshot",{allow: false})
Object object
Attribute | Type | Default Value | Mandatory | Description |
allow | Boolen | true | O | whether to allow screen capture & screen sharing. |
Values | Description | |||
true | Allow screen capture & screen sharing. | |||
false | Hide screen recording content and prohibit screenshot operations. | |||
success | Function | - | O | The callback function for successful invocation. |
fail | Function | - | O | The callback function for failed invocation. |
complete | Function | - | O | The callback function for the end of the invocation (executed whether the invocation is successful or failed). |
Limitations
iOS limitations:
- Versions below iOS 13 are not supported.
- System pop - up windows cannot prohibit screen capture.
- Due to the reason of the appx version, it needs to be called by the method of my.call('allowSystemSnapshot').
Android limitations:
- When the screen capture prohibition is enabled, the content of the Toast cannot be controlled, that is, the Toast content will be recorded.
- When the screen capture prohibition is enabled, other Activities cannot be controlled, such as setting, about, file browsing, etc.
Example
H5 mini program
copy
// disable screen capture
AlipayJSBridge.call('allowSystemSnapshot',{'allow':false},
function(data){alert(JSON.stringify(data));});
// allow screen capture
AlipayJSBridge.call('allowSystemSnapshot',{'allow':true},
function(data){alert(JSON.stringify(data));});
// allow screen capture without parameters
AlipayJSBridge.call('allowSystemSnapshot',{},
function(data){alert(JSON.stringify(data));});
// invalid parameters
AlipayJSBridge.call('allowSystemSnapshot',{'allow':'abc'},
function(data){alert(JSON.stringify(data));});
DSL mini program
copy
Page({
// enable screen capture, my.call('allowSystemSnapshot',{})
allowCaptureIncall1(){
my.call('allowSystemSnapshot',{
allow:true,
success:()=>{
my.showToast({content:"call.success",duration:3000})
},
fail: (res) => {
my.alert({
title: "call.failed",
content: "" + JSON.stringify(res)
});
}
});
},
// enable screen capture, my.call('allowSystemSnapshot',{})
allowCaptureIncall2(){
my.call('allowSystemSnapshot',{
success:()=>{
my.showToast({content:"call.success",duration:3000})
},
fail: (res) => {
my.alert({
title: "call.failed",
content: "" + JSON.stringify(res)
});
}
});
},
// disable screen capture, my.call('allowSystemSnapshot',{})
disallowCaptureIncall(){
my.call('allowSystemSnapshot',{
allow:false,
success:()=>{
my.showToast({content:"call.success",duration:3000})
},
fail: (res) => {
my.alert({
title: "call.failed",
content: "" + JSON.stringify(res)
});
}
});
},
// invalid parameters, error2
callCaptureIncallInvalidParams2(){
my.call('allowSystemSnapshot',{
allow:'abc',
success:()=>{
my.showToast({content:"call.success",duration:3000})
},
fail: (res) => {
my.alert({
title: "call.failed",
content: "" + JSON.stringify(res)
});
}
});
},
});