Commands
Request Permission
This command lets you request permission to send notifications to a user.
Using the command
Note this will only allow you to show 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.
worldcoin.org/settings/miniapps
Async handlersEvent listeners
Sending the command and handling the response
import { MiniKit, RequestPermissionPayload, Permission } from '@worldcoin/minikit-js'
// Example function of how to use the command
const requestPermission = useCallback(
async () => {
const requestPermissionPayload: RequestPermissionPayload = {
permission: Permission.Notifications,
};
const payload = await MiniKit.commandsAsync.requestPermission(requestPermissionPayload);
// Handle the response
},
[]
);
Response type
Success response payload
type MiniAppRequestPermissionSuccessPayload = {
status: 'success';
permission: 'notifications';
timestamp: string; // ISO-8601
version: number; // same version that was received from MiniKit
};
Error response payload
type MiniAppRequestPermissionErrorPayload = {
status: 'error';
error_code: RequestPermissionErrorCodes;
version: number;
}
The possible error codes are:
user_rejected
- User declined permission requestgeneric_error
- Request failed for unknown reasonalready_requested
- User has already declined turning on notifications oncepermission_disabled
- User has notification disabled for World Appalready_granted
- User has already granted this mini app permissionunsupported_permission
- Permission is not supported yet
Success Result on World App
If implemented correctly, the user will see the following drawer on World App.