英文:
react-native-permissions - iOS - requestNotifications()
问题
"requestNotifications" 函数的正确使用方式是什么?它定义在库 "react-native-permissions" 中。
我尝试了:
await requestNotifications({
sound: true,
vibrate: true,
alert: true,
});
但我收到了错误信息 "如果类型 NSMutableDisctionary 无法转换为 NSArray"。
函数调用有什么问题?
函数声明是 requestNotifications(options: NotificationOption[]): Promise<NotificationsResponse>;
。
英文:
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>;
答案1
得分: 1
Your function requires arrays with strings instead of objects. So your code should look like:
requestNotifications(['alert', 'sound'])
Possible options:
'alert'
| 'badge'
| 'sound'
| 'criticalAlert'
| 'carPlay'
| 'provisional'
| 'providesAppSettings'
英文:
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';
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论