1

[here shows notification is dialog is opens on splash screen where I want to shows automactially and had a bad flow for userenter image description hereere](https://i.stack.imgur.com/D2YJj.png)

I added only notification permission and it shows always when user opens app for the first time.

<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
Midhun MP
  • 103,496
  • 31
  • 153
  • 200
Ved Prakash
  • 11
  • 2
  • 4

2 Answers2

1

Add this code in your main activity (not in Splash Activity) to take permission. `@RequiresApi(Build.VERSION_CODES.TIRAMISU)

private fun getNotificationPermission() {
    if (ContextCompat.checkSelfPermission(
            this, android.Manifest.permission.POST_NOTIFICATIONS
        ) != PackageManager.PERMISSION_GRANTED
    ) {
        Log.e("TAG33", "getNotificationPermission: ", )
        shouldShowRequestPermissionRationale(android.Manifest.permission.POST_NOTIFICATIONS)
        requestPermissionLauncher.launch(
            Manifest.permission.POST_NOTIFICATIONS
        )
    }
}`
monjur
  • 19
  • 7
0

From my understanding, below might be the issue you're facing. As a workaround, you can create your notification channel in your main activity.

If your app targets 12L (API level 32) or lower, the system shows the permission dialog the first time your app starts an activity after you create a notification channel, or when your app starts an activity and then creates its first notification channel. This is usually on app startup.

https://developer.android.com/develop/ui/views/notifications/notification-permission

Malik Bilal
  • 869
  • 8
  • 25