Permission request popup not showing until app restart


My app requests 2 permissions, in the following order:

  1. Push Notifications.
  2. Make & Manage Phone Calls

For some reason, the second permission request popup (phone calls) displays first.

The first popup (push notifications) only shows up when I close the app, and open it again.

Here is the code for the function that requests push notifications:

As you can see, I have a debug toast in the function.

It gets displayed on the app's initial startup, even though the notificaiton request popup does not.

@Composable
fun CanPushNotifications () {
    val context = LocalContext.current
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
        val launcher = rememberLauncherForActivityResult(
            contract = ActivityResultContracts.RequestPermission()
        ) {"""on permission granted"""}
        val lifecycleOwner = LocalLifecycleOwner.current
        LaunchedEffect(lifecycleOwner) {
            lifecycleOwner.lifecycle.withStarted {
                launcher.launch(Manifest.permission.POST_NOTIFICATIONS)
            }
            Toast.makeText(context, "Notification Test 1 Passed", Toast.LENGTH_SHORT).show()
        }
    }
}

If you need any other code snippets, logs, etc...

feel free to ask. I am available 7 days a week.

0
Jun 24 at 3:46 AM
User Avataruser487568
#android

No answer found for this question yet.