allowSystemSnapshot

The allowSystemSnapshot JSAPI is called by the my.call JSAPI, which allows or forbids the screenshots or screen recordings.

Prerequisites:

This JSAPI takes effect when the following conditions are met:

  • For Android: 2.59.2 and the above versions
  • For iOS: 2.59.0 and the above versions
  • For iOS: only iOS 13 and above

Parameters

The incoming parameter is of the Object type with the following properties:

Property

Type

Required

Description

allow

Boolean

No

It takes effect throughout the mini program except some setting pages (e.g. the about page, the settings page, the system pop-up window, and so on):

Valid values:

  • true (Default value): allows the screenshots or screen recordings.
  • false: forbids the screenshots or screen recordings. If you still do the screen capturing/recording when it is prohibited:
    • For iOS: the photos or videos saved to the album are completely black.
    • For Android: the screenshots cannot be saved to the photo album. The screen recordings are saved to the photo album, but they are completely black screen recordings.

success

Function

No

The callback function that is called upon successful call.

fail

Function

No

The callback function that is called when the JSAPI call fails. When executed, it receives an Error codes object.

complete

Function

No

The callback function that is called upon call completion (to be executed upon either successful or failed call).

Error codes

Error code

Error message

Solution

1

Invalid JSAPI interface.

Please check whether your current runtime supports this JSAPI.

2

Invalid JSAPI entry parameters.

Refer to the Parameters table and check whether all parameter types are correct and whether all required parameters are specified.

Sample code

copy
my.call('allowSystemSnapshot',{
      allow:true,
      success:()=>{
        console.log(res);
      },
      fail: (res) => {
        console.log(err);
      }
    });