Hardik Kothari
Hardik Kothari

Reputation: 1766

How to check permission status of screen capture in electron (macOS catalina)

I am working on electron app.In the app, there is feature of screen recording and send that to server.We can check a microphone permission status using getMediaAccessStatus api but how can we check a screen recording permission status?

Upvotes: 2

Views: 5494

Answers (2)

Hardik Kothari
Hardik Kothari

Reputation: 1766

Here is the new solution

 if (process.platform === "darwin") {
    try {
      // prompt for permissions on macOS
      const types = ["camera", "microphone", "screen"];
      let accessPerms = {};

      for (const type of types) {
        const status = systemPreferences.getMediaAccessStatus(type);
        accessPerms[type] = status;
      }
     } catch (e) {
      console.error(e);
    }
  }

Upvotes: 2

Hardik Kothari
Hardik Kothari

Reputation: 1766

Here is npm plugin which provide the apis to Check and request permission to capture the screen on macOS (introduced with 10.15 Catalina)

mac-screen-capture-permissions

Upvotes: 3

Related Questions