This repository has been archived on 2022-03-12. You can view files and clone it, but cannot push or open issues or pull requests.
2021-04-02 02:24:13 +03:00

25 lines
1.1 KiB
TypeScript

import { PermissionResponse, PermissionType } from './Permissions.types';
/**
* Get or ask permission for protected functionality within the app.
* It returns the permission response after fetching or asking it.
* The hook fetches the permissions when rendered, by default.
* To ask the user permission, use the `askPermission` callback or `ask` option.
*
* @see https://docs.expo.io/versions/latest/sdk/permissions/
* @example
* ```tsx
* const [permission, askPermission, getPermission] = usePermissions(Permissions.CAMERA);
*
* return permission?.granted
* ? <Camera ... />
* : <Button onPress={askPermission} />;
* ```
*/
export declare function usePermissions(type: PermissionType | PermissionType[], options?: PermissionsOptions): [PermissionResponse | undefined, () => Promise<void>, () => Promise<void>];
export interface PermissionsOptions {
/** If it should ask the permissions when mounted, defaults to `false` */
ask?: boolean;
/** If it should fetch information about the permissions when mounted, defaults to `true` */
get?: boolean;
}