Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Android 13 run time notification permission #2398

Closed
ashish-kshirsagar opened this issue Jul 8, 2022 · 5 comments · Fixed by #2440
Closed

Support Android 13 run time notification permission #2398

ashish-kshirsagar opened this issue Jul 8, 2022 · 5 comments · Fixed by #2440

Comments

@ashish-kshirsagar
Copy link

Problem description

Android 13 is changing the requirement for notification permission to run-time grant by user instead of auto grant. Refer this link.

Due to this change for apps that are not changing target SDK version to 33 have no control over permission rationale dialog and it is shown to user as soon as a notification channel is created or a notification is posted by app. With using LeakCanary, notification channel is created upon finding first leak and hence causes a permission dialog to be shown. Refer screenshot displayed in third screen at this link. So app has no control on when this permission dialog shows up. This affects the user behavior and there isn't any work around.

Expecting a way to control the leak canary notifications to be generated only after a certain point after notification permission is granted.

Potential solutions

There can be couple of solutions possible.

  1. Allow app to control enablement of notifications for LeakCanary. So App can control run time permission before any notification is shown.
  2. LeakCanary can check if notification permission granted for an app and only then show leak notifications.

Additional information

Not specific with app but can be checked with any app that targets lower than 33 API and includes leak canary.
Refer to a comment for related change #2395 (comment)

@pyricau
Copy link
Member

pyricau commented Jul 13, 2022

Thx. The linked PR would help with disabling / delaying notifications until the permission is granted.

However, I'm not clear what the default behavior when you don't set anything should be.

@pyricau
Copy link
Member

pyricau commented Nov 9, 2022

One of the drivers here is to allow apps to control when we should attempt to show notifications, for scenarios where we don't want that permission to show up.

pyricau added a commit that referenced this issue Nov 10, 2022
@pyricau
Copy link
Member

pyricau commented Nov 10, 2022

As a first step, we'll add a control to allow disabling all LeakCanary notifications.

@SunnyBe
Copy link

SunnyBe commented Jan 26, 2023

@pyricau I still want the notifications, but I want to be the one to request for the permission and Leak Canary should show notifications after that.
Is that possible at the moment?

@pyricau
Copy link
Member

pyricau commented Feb 7, 2023

I believe yes, just set LeakCanary.config.showNotifications to false (=> won't show notifications) and then set it to true once you've gotten the permission.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants