icerockdev / moko-permissions

Runtime permissions controls for mobile (android & ios) Kotlin Multiplatform development

Home Page:https://moko.icerock.dev/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

java.lang.IllegalStateException: activityResultLauncher is null, `bind` function was never called

ismai117 opened this issue · comments

  val factory: PermissionsControllerFactory = rememberPermissionsControllerFactory()
        val controller: PermissionsController =
            remember(factory) { factory.createPermissionsController() }
        val coroutineScope: CoroutineScope = rememberCoroutineScope()

        PermissionsScreenContent(
            enablePostNotification = {
                coroutineScope.launch {
                    controller.providePermission(Permission.REMOTE_NOTIFICATION)
                }
            }
        )

I receive this E FATAL EXCEPTION: main
Process: org.ncgroup.myteethreminder, PID: 31764
java.lang.IllegalStateException: activityResultLauncher is null, bind function was never called, consider calling permissionsController.bind(activity) or BindEffect(permissionsController) in the composable function, check the documentation for more info: https://github.com/icerockdev/moko-permissions/blob/master/README.md
at dev.icerock.moko.permissions.PermissionsControllerImpl.awaitActivityResultLauncher(PermissionsControllerImpl.kt:129)
at dev.icerock.moko.permissions.PermissionsControllerImpl.access$awaitActivityResultLauncher(PermissionsControllerImpl.kt:34)
at dev.icerock.moko.permissions.PermissionsControllerImpl$awaitActivityResultLauncher$1.invokeSuspend(Unknown Source:14)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.internal.ScopeCoroutine.afterResume(Scopes.kt:28)
at kotlinx.coroutines.AbstractCoroutine.resumeWith(AbstractCoroutine.kt:99)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:46)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:102)
at androidx.compose.ui.platform.AndroidUiDispatcher.performTrampolineDispatch(AndroidUiDispatcher.android.kt:81)
at androidx.compose.ui.platform.AndroidUiDispatcher.access$performTrampolineDispatch(AndroidUiDispatcher.android.kt:41)
at androidx.compose.ui.platform.AndroidUiDispatcher$dispatchCallback$1.run(AndroidUiDispatcher.android.kt:57)
at android.os.Handler.handleCallback(Handler.java:959)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loopOnce(Looper.java:232)
at android.os.Looper.loop(Looper.java:317)
at android.app.ActivityThread.main(ActivityThread.java:8501)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:878)
Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: [androidx.compose.ui.platform.MotionDurationScaleImpl@a4a053f, androidx.compose.runtime.BroadcastFrameClock@cd79e0c, StandaloneCoroutine{Cancelling}@33e2355, AndroidUiDispatcher@8f7216a]

try to add BindEffect(permissionsController) something like this example

@ZiXOps that's working now, thank you!