GithubHelp home page GithubHelp logo

How can i get the microphone or camera permission in react-native-macOS, i am using react-native-permissions about react-native-macos HOT 3 OPEN

MuhammadBilal164 avatar MuhammadBilal164 commented on June 2, 2024
How can i get the microphone or camera permission in react-native-macOS, i am using react-native-permissions

from react-native-macos.

Comments (3)

Saadnajmi avatar Saadnajmi commented on June 2, 2024

I think you'd have to open an issue or contribute a change in the react-native-permissions repo to support macOS. I'm not sure how easy or simple that task would be

from react-native-macos.

MuhammadBilal164 avatar MuhammadBilal164 commented on June 2, 2024

@Saadnajmi i have created native method which takes permission of camera and microphone and export that method to JS and call that method from JS

create a method in native Module
`- (void)requestForCameraAndMicrophonePermission {
[AVCaptureDevice requestAccessForMediaType:AVMediaTypeAudio completionHandler:^(BOOL granted) {
if (granted) {
..... Your logic/ send event to JS
} else {
..... Your logic/ send event to JS
}
}];

[AVCaptureDevice requestAccessForMediaType:AVMediaTypeVideo completionHandler:^(BOOL granted) {
    if (granted) {
       ..... Your logic/ send event to JS 
    } else {
       ..... Your logic/ send event to JS 
    }
}];

}`

You can also export this method directly but i call this method separately
RCT_EXPORT_METHOD(requestForPermission){ [self requestCameraAndMicrophonePermission]; }

from react-native-macos.

Saadnajmi avatar Saadnajmi commented on June 2, 2024

@MuhammadBilal164 is that the same code as iOS, implying that most of the permission requesting code is cross platform between iOS and macOS? If so, it might be easy to add macOS support to react-native-permissions

from react-native-macos.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.