diff --git a/docs/how-to/client/installation.mdx b/docs/how-to/client/installation.mdx index 9bfb5e9..fbbd5bc 100644 --- a/docs/how-to/client/installation.mdx +++ b/docs/how-to/client/installation.mdx @@ -221,12 +221,10 @@ export default function App() { ## Camera and Microphone Permissions :::info -You don't need to explicitly request permissions as they're automatically asked for when your app needs them. +You don't need to explicitly request permissions — they're automatically requested when your app calls `initializeDevices()`. ::: -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. - -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. +If you need manual control over when permissions are requested, see [Managing Permissions](./managing-devices#managing-permissions-mobile-only). diff --git a/docs/how-to/client/managing-devices.mdx b/docs/how-to/client/managing-devices.mdx index a5559cb..f261e36 100644 --- a/docs/how-to/client/managing-devices.mdx +++ b/docs/how-to/client/managing-devices.mdx @@ -252,3 +252,53 @@ export function MicrophoneControl() { ); } ``` + +## Managing Permissions (Mobile only) + +The SDK provides built-in hooks for querying and requesting device permissions: `useCameraPermissions` and `useMicrophonePermissions` from `@fishjam-cloud/react-native-client`. + +Both hooks return a `[query, request]` tuple: + +- **`query()`** — checks the current permission status without prompting the user +- **`request()`** — triggers the native permission dialog and returns the resulting status + +The returned `PermissionStatus` is one of: `'granted'`, `'denied'`, or `'prompt'`. + +#### Usage Example + +```tsx +// @noErrors: 2305 +import React, { useEffect } from "react"; +import { + useCameraPermissions, + useMicrophonePermissions, + useInitializeDevices, +} from "@fishjam-cloud/react-native-client"; + +function RoomScreen() { + const [queryCamera, requestCamera] = useCameraPermissions(); // [!code highlight] + const [queryMicrophone, requestMicrophone] = useMicrophonePermissions(); // [!code highlight] + const { initializeDevices } = useInitializeDevices(); // [!code highlight] + + useEffect(() => { + const setup = async () => { + let cam = await queryCamera(); + let mic = await queryMicrophone(); + + if (cam !== "granted") cam = await requestCamera(); + if (mic !== "granted") mic = await requestMicrophone(); + + if (cam === "granted" && mic === "granted") { + await initializeDevices(); // [!code highlight] + } + }; + setup(); + }, [ + queryCamera, + requestCamera, + queryMicrophone, + requestMicrophone, + initializeDevices, + ]); +} +``` diff --git a/packages/web-client-sdk b/packages/web-client-sdk index 2b23a8f..f3014ba 160000 --- a/packages/web-client-sdk +++ b/packages/web-client-sdk @@ -1 +1 @@ -Subproject commit 2b23a8fa8f8da3ccee29eb2093031fa6a2943286 +Subproject commit f3014ba8c7e37f905c1c16946b576d4a02ab7903