@@ -9,6 +9,7 @@ import android.provider.Settings
9
9
import androidx.activity.compose.rememberLauncherForActivityResult
10
10
import androidx.activity.result.ActivityResultLauncher
11
11
import androidx.activity.result.contract.ActivityResultContracts
12
+ import androidx.annotation.RequiresApi
12
13
import androidx.compose.runtime.Composable
13
14
import androidx.compose.runtime.DisposableEffect
14
15
import androidx.compose.runtime.Stable
@@ -106,10 +107,14 @@ internal actual class MutablePermissionState(
106
107
actual override fun openAppSettings () {
107
108
if (context == null ) return
108
109
109
- val intent = Intent ().apply {
110
- action = Settings .ACTION_APPLICATION_DETAILS_SETTINGS
111
- data = Uri .fromParts(" package" , context.packageName, null )
112
- flags = Intent .FLAG_ACTIVITY_NEW_TASK
110
+ val intent = when (permission) {
111
+ Permission .Notification -> if (supportsNotificationSettings()) {
112
+ createAppNotificationsIntent(context)
113
+ } else {
114
+ createAppSettingsIntent(context)
115
+ }
116
+
117
+ else -> createAppSettingsIntent(context)
113
118
}
114
119
context.startActivity(intent)
115
120
}
@@ -132,4 +137,20 @@ internal actual class MutablePermissionState(
132
137
PermissionStatus .Denied (activity.shouldShowRationale(androidPermission))
133
138
}
134
139
}
140
+
141
+ @RequiresApi(Build .VERSION_CODES .O )
142
+ private fun createAppNotificationsIntent (context : Context ) =
143
+ Intent (Settings .ACTION_APP_NOTIFICATION_SETTINGS ).apply {
144
+ putExtra(Settings .EXTRA_APP_PACKAGE , context.packageName)
145
+ }
146
+
147
+ private fun supportsNotificationSettings () =
148
+ Build .VERSION .SDK_INT >= Build .VERSION_CODES .TIRAMISU
149
+
150
+ private fun createAppSettingsIntent (context : Context ) =
151
+ Intent ().apply {
152
+ action = Settings .ACTION_APPLICATION_DETAILS_SETTINGS
153
+ data = Uri .fromParts(" package" , context.packageName, null )
154
+ flags = Intent .FLAG_ACTIVITY_NEW_TASK
155
+ }
135
156
}
0 commit comments