may*_*yal 4 javascript android ios react-native
我想检查 ios 和 android 的推送通知权限。我想看看用户是否从他的设备设置中关闭了推送通知权限。如果需要以本机编码,是否有任何插件或任何代码我可以参考。
您可以检查react-native-permissions npm。集成后,您可以像这样使用它:
componentDidMount() {
Permissions.check('notification').then(response => {
// Response is one of: 'authorized', 'denied', 'restricted', or 'undetermined'
this.setState({ photoPermission: response })
})
}
Run Code Online (Sandbox Code Playgroud)
还有另一个库可以提供帮助(我没有使用过)。
还有本机实现,如此处建议的那样。
官方方式https://github.com/react-native-community/react-native-permissions#checknotifications
import {requestNotifications} from 'react-native-permissions';
requestNotifications(['alert', 'sound']).then(({status, settings}) => {
// …
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
10737 次 |
| 最近记录: |