[英]Check always location services are enabled or not in React Native (iOS and Android both)
[英]How can i check push notification permission for both ios and android in react native?
我想检查 ios 和 android 的推送通知权限。 我想看看用户是否从他的设备设置中关闭了推送通知权限。 如果需要以本机编码,是否有任何插件或任何代码我可以参考。
官方方式https://github.com/react-native-community/react-native-permissions#checknotifications
import {requestNotifications} from 'react-native-permissions';
requestNotifications(['alert', 'sound']).then(({status, settings}) => {
// …
});
您可以检查react-native-permissions npm 。 集成后,您可以像这样使用它:
componentDidMount() {
Permissions.check('notification').then(response => {
// Response is one of: 'authorized', 'denied', 'restricted', or 'undetermined'
this.setState({ photoPermission: response })
})
}
还有另一个库可以提供帮助(我没有使用过)。
还有这里建议的本机实现。
安卓:
实际上,推送通知权限位于正常类别权限中,如 INTERNET 权限不在危险类别权限中。
您不必请求推送通知权限。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.