Do you guys know any best practices about calling android methods that are annotated with
@RequiresPermission
when developing a Multiplatform SDK?
Normally i would say that handling the permissions is an App issue, not an SDK issue, so i would also annotate my own methods with the same
@RequiresPermission
annotation, but they are Android-only, so you can’t annotate common methods.
Rainer Schlonvoigt
05/11/2023, 11:50 AM
while creating expect/actual versions of all the methods is possible, it seams a lot of work
e
ephemient
05/11/2023, 12:20 PM
commonMain
Copy code
@OptionalExpectation
expect annotation class RequiresPermission(
val value: String,
val allOf: Array<String>,
val anyOf: Array<String>,
val conditional: Boolean,
)
androidMain
Copy code
actual typealias RequiresPermission = androidx.annotation.RequiresPermission
will allow you to use
@RequiresPermission
in common code
r
Rainer Schlonvoigt
05/11/2023, 1:09 PM
sucks that the default values for the parameters can not be set without a compiler error, but otherwise quite handy