Member-only story
Handling Permissions in Compose Multiplatform
Recently I’ve been developing more Compose Multiplatform apps rather than separate apps for Android and iOS, so I’ve been searching for an easy way to manage permissions across the platforms w/o the need for third party libraries.
Someone could ask: Why would you need to write permission handling code on your own while there’s many good libraries out there to do the same?
Actually there’s more than one reason why one would do so.
First of all I wanted to clearly understand how permissions are handled across platforms (especially between Android and iOS), then I wanted to minimize the number of dependencies needed to develop a large app, finally I wanted to try and find my way through the permissions woods.
Obviously anyone can come out with the solution which better suits their needs, what follows is just my way, but you can try and find your own.
I went for expected/actual object classes and lambda expressions to implement my solution since they looked the most straightforward way to me, for you don’t have to instantiate new objects in the native code of the Android and iOS apps and you don’t need to define classes or interfaces for the callbacks, which means less boilerplate code.