【问题标题】:React Native access app notification permissionReact Native 访问应用通知权限
【发布时间】:2020-06-22 10:04:52
【问题描述】:

我想达到图中所示的权限。如何使用 React Native?

最好的问候

enter image description here

【问题讨论】:

    标签: android reactjs react-native permissions


    【解决方案1】:

    如果你有 Native Java 知识,那么你必须在 React native 中使用 Native Modules 来使用 Native Java 代码

     public void appDetailsSettings() {
        Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
        intent.setData(Uri.parse("package:" + reactContext.getPackageName()));
        if (intent.resolveActivity(reactContext.getPackageManager()) != null) {
            reactContext.startActivity(intent);
        }
     }
    

    否则你可以使用第三方库,例如https://github.com/levelasquez/react-native-android-open-settings

    【讨论】:

    • 感谢您的回答。如何在不将用户发送到设置屏幕的情况下获得许可?
    • 您可以使用 PermissionsAndroid for Android,它是一个 react native util 使用它您可以向用户请求权限并检查权限的状态。对于 iOS,您必须使用自定义解决方案,这需要一些创建 Naitve 模块的知识。
    猜你喜欢
    • 1970-01-01
    • 2021-02-18
    • 2019-11-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多