Scalable way to ask for special and runtime permissions in one go

49 Views Asked by At

I'm creating a feature which uses two permissions

  1. SCHEDULE_EXACT_ALARM - Special Permission (Need to direct the user to settings screen via Intent)

  2. POST_NOTIFICATIONS - Runtime Permission (Can be handled by using rememberLauncherForActivityResult()

The main issue is that I have to handle cases 4 cases

  1. both are granted

  2. None of them is granted

  3. SCHEDULE_EXACT_ALARM is granted POST_NOTIFICATIONS is denied

  4. POST_NOTIFICATIONS is granted SCHEDULE_EXACT_ALARM is denied

How to the achieve the above in an elegant way first and then if possible devise a scalable way for the same.

I was able to achieve my goal but the code I wrote is too tightly coupled and doesn't follows SOLID principles.

0

There are 0 best solutions below