This command only supports requesting one permission at a time. Additionally, it will only show the user the modal once. If a user rejects it, you will need to direct them to settings in order to re-enable the permission.
If a user removes your mini app from their World App home screen, you will need to request the permission again.
Copy
Ask AI
worldcoin.org/settings/miniapps
Permission Types:
Copy
Ask AI
// Types of permissions you can request. You can only request one at a time.export enum Permission { Notifications = 'notifications', Microphone = 'microphone',}
import { MiniKit, RequestPermissionPayload, Permission } from '@worldcoin/minikit-js'// Example function of how to use the commandconst requestPermission = useCallback( async () => { const requestPermissionPayload: RequestPermissionPayload = { permission: Permission.Notifications, }; const payload = await MiniKit.commandsAsync.requestPermission(requestPermissionPayload); // Handle the response }, []);
type MiniAppRequestPermissionSuccessPayload = { status: 'success'; permission: 'notifications'; timestamp: string; // ISO-8601 version: number; // same version that was received from MiniKit};
type MiniAppRequestPermissionErrorPayload = { status: 'error'; error_code: RequestPermissionErrorCodes; version: number;}
The possible error codes are:
user_rejected - User declined permission request
generic_error - Request failed for unknown reason
already_requested - User has already declined turning on notifications once
permission_disabled - User has notification disabled for World App
already_granted - User has already granted this mini app permission
unsupported_permission - Permission is not supported yet
world_app_permission_not_enabled - User has not granted permission to World App. This means you need to prompt the user to enable microphone for World App first.