react-native-permissions – iOS – requestNotifications()

huangapple go评论64阅读模式
英文:

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&lt;NotificationsResponse&gt;;

答案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'

More information

英文:

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

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

More informations

huangapple
  • 本文由 发表于 2023年5月7日 22:53:27
  • 转载请务必保留本文链接:https://go.coder-hub.com/76194652.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定