https://kotlinlang.org logo
Title
r

Rainer Schlonvoigt

05/11/2023, 11:48 AM
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.
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
@OptionalExpectation
expect annotation class RequiresPermission(
    val value: String,
    val allOf: Array<String>,
    val anyOf: Array<String>,
    val conditional: Boolean,
)
androidMain
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
thx