nativescript-community / perms

An unified permissions API for NativeScript on iOS and Android.
https://nativescript-community.github.io/perms/
Apache License 2.0
12 stars 9 forks source link

Feature: Possible to open notification settings on Android #30

Open sivo1981 opened 9 hours ago

sivo1981 commented 9 hours ago

Currently for Android it is only possible to open default settings. Is it possible to add option to open notification settings.

Snippet code taken from ChatGPT:

        const context = Utils.android.getApplicationContext()
        const intent = new android.content.Intent()
        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
          intent.setAction(android.provider.Settings.ACTION_APP_NOTIFICATION_SETTINGS)
          intent.putExtra(android.provider.Settings.EXTRA_APP_PACKAGE, context.getPackageName())
        } else {
          intent.setAction(android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS)
          const uri = android.net.Uri.fromParts('package', context.getPackageName(), null)
          intent.setData(uri)
        }
        intent.addFlags(android.content.Intent.FLAG_ACTIVITY_NEW_TASK)
        context.startActivity(intent)