Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can i get the microphone or camera permission in react-native-macOS, i am using react-native-permissions #2107

Open
MuhammadBilal164 opened this issue Apr 4, 2024 · 3 comments

Comments

@MuhammadBilal164
Copy link

i want to implement call functionality in macOS and i want mircrophone permission, but in app i am using react-native-permissions which is not available for macOS platform

@Saadnajmi
Copy link
Collaborator

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

@MuhammadBilal164
Copy link
Author

MuhammadBilal164 commented Apr 4, 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]; }

@Saadnajmi
Copy link
Collaborator

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants