Search code examples
react-nativereact-native-permissions

react-native-permissions - iOS - requestNotifications()


What is the right way to use the "requestNotifications" function? Defined in the library "react-native-permissions".

I tried:

await requestNotifications({
            sound: true,
            vibrate: true,
            alert: true,
        });

but i get the error "... if type NSMutableDisctionary cannot be converted to NSArray"

What is wrong with the function call?

Function declare is requestNotifications(options: NotificationOption[]): Promise<NotificationsResponse>;


Solution

  • Your function require arrays with string instead of object. So your code should looks like requestNotifications(['alert', 'sound'])

    Possible options: 'alert' | 'badge' | 'sound' | 'criticalAlert' | 'carPlay' | 'provisional' | 'providesAppSettings';

    More informations