Skip to content

Commit 269d439

Browse files
FCE-2869: Add permission helpers docs (#234)
## Description - **managing-devices.mdx**: Add "Managing Permissions (Mobile only)" section documenting `useCameraPermissions` and `useMicrophonePermissions` hooks with query/request API and usage example - **installation.mdx**: Replace `expo-permissions`/`react-native-permissions` recommendation with a link to the new Managing Permissions section - Bump `web-client-sdk` submodule ## Motivation and Context The mobile SDK now ships built-in permission hooks (`useCameraPermissions`, `useMicrophonePermissions`), so the docs should guide users to those instead of third-party libraries.
1 parent aef26c8 commit 269d439

2 files changed

Lines changed: 57 additions & 4 deletions

File tree

docs/how-to/client/installation.mdx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -221,12 +221,10 @@ export default function App() {
221221
## Camera and Microphone Permissions
222222

223223
:::info
224-
You don't need to explicitly request permissions as they're automatically asked for when your app needs them.
224+
You don't need to explicitly request permissions they're automatically requested when your app calls `initializeDevices()`.
225225
:::
226226

227-
The SDK automatically requests camera and microphone permissions when you call `initializeDevices()`. The system permission dialog will be shown to the user if permissions haven't been granted yet.
228-
229-
If you need manual control over permissions, you can use the [expo-permissions](https://docs.expo.dev/versions/latest/sdk/permissions/) or [react-native-permissions](https://github.com/zoontek/react-native-permissions) libraries.
227+
If you need manual control over when permissions are requested, see [Managing Permissions](./managing-devices#managing-permissions-mobile-only).
230228

231229
</TabItem>
232230
</Tabs>

docs/how-to/client/managing-devices.mdx

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,3 +252,58 @@ export function MicrophoneControl() {
252252
);
253253
}
254254
```
255+
256+
## Managing Permissions (Mobile only)
257+
258+
The SDK provides built-in hooks for querying and requesting device permissions: `useCameraPermissions` and `useMicrophonePermissions` from `@fishjam-cloud/react-native-client`.
259+
260+
Both hooks return a `[query, request]` tuple:
261+
262+
- **`query()`** — checks the current permission status without prompting the user
263+
- **`request()`** — triggers the native permission dialog and returns the resulting status
264+
265+
The returned `PermissionStatus` is one of: `'granted'`, `'denied'`, or `'prompt'`.
266+
267+
:::info
268+
Requesting permissions manually is optional — `initializeDevices()` will automatically prompt for any permissions that haven't been granted yet.
269+
However, you must always call `initializeDevices()` to set up camera and microphone devices.
270+
:::
271+
272+
#### Usage Example
273+
274+
```tsx
275+
// @noErrors: 2305
276+
import React, { useEffect } from "react";
277+
import {
278+
useCameraPermissions,
279+
useMicrophonePermissions,
280+
useInitializeDevices,
281+
} from "@fishjam-cloud/react-native-client";
282+
283+
function RoomScreen() {
284+
const [queryCamera, requestCamera] = useCameraPermissions(); // [!code highlight]
285+
const [queryMicrophone, requestMicrophone] = useMicrophonePermissions(); // [!code highlight]
286+
const { initializeDevices } = useInitializeDevices(); // [!code highlight]
287+
288+
useEffect(() => {
289+
const setup = async () => {
290+
let cam = await queryCamera();
291+
let mic = await queryMicrophone();
292+
293+
if (cam !== "granted") cam = await requestCamera();
294+
if (mic !== "granted") mic = await requestMicrophone();
295+
296+
if (cam === "granted" && mic === "granted") {
297+
await initializeDevices(); // [!code highlight]
298+
}
299+
};
300+
setup();
301+
}, [
302+
queryCamera,
303+
requestCamera,
304+
queryMicrophone,
305+
requestMicrophone,
306+
initializeDevices,
307+
]);
308+
}
309+
```

0 commit comments

Comments
 (0)