简体   繁体   English

请求通知权限--Flutter

[英]Ask notification permission--Flutter

I am trying to show a pop up that ask user to grant permission notification.我正在尝试显示一个要求用户授予权限通知的弹出窗口。 Because as I know.. android api less than 33 always auto on for notification permission.因为据我所知.. android api 小于 33 总是自动开启以获得通知权限。 But not in android 33, we need to manually turn on notification permission.但是android 33中没有,我们需要手动开启通知权限。 So, is there a way to show alert dialog to ask notification permission?那么,有没有办法显示警报对话框来询问通知权限? So far I have been using permission_handler but as I know, it doesn't show pop up alert for bluetooth and notification request permission到目前为止,我一直在使用 permission_handler 但据我所知,它没有显示蓝牙和通知请求权限的弹出警报

Brother inside your manifest file you have to add a few lines you will find the build.gradle inside your project root -> android folder-> open this build.gradle file then adds these lines.兄弟在清单文件中,您必须添加几行,您会在项目根目录中找到 build.gradle -> android 文件夹 -> 打开此 build.gradle 文件,然后添加这些行。

    dependencies {
    classpath 'com.android.tools.build:gradle:7.1.2'
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    classpath 'com.google.gms:google-services:4.3.3'
}

after this go inside your android-> app-> build.gradle and add these.在您的 android-> app-> build.gradle 中的 go 之后并添加这些。

apply plugin: 'com.google.gms.google-services'


dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.google.firebase:firebase-messaging:20.1.0'
implementation("androidx.multidex:multidex:2.0.1")

} }

and for permission you need to add these lines in your manifest file you will find it inside your android -> app -> src-> main -> manifest open this manifest file and these lines.为了获得许可,您需要在清单文件中添加这些行,您会在 android -> app -> src-> main -> manifest 打开此清单文件和这些行。

<intent-filter>
            <action android:name="FLUTTER_NOTIFICATION_CLICK" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>

and you have to add google-services.json inside your android -> src folder.并且您必须在 android -> src 文件夹中添加 google-services.json 。

you can get your google-services.json from firebase official site.您可以从 firebase 官方网站获取您的 google-services.json。

if you need any other help please let me know如果您需要任何其他帮助,请告诉我

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM