Open farhazulmullick-pw opened 1 year ago
Hello, try this:
LaunchedEffect(Unit) {
// code for just once permission to provide...
}
I have the same crash, and it occurs only on one of 4 my phones, crap
Same issue, it looks like it doesn't throw the exception in controller.providePermission()
throws it somewhere else.
dev.icerock.moko.permissions.RequestCanceledException
2024-10-14 18:48:09.343 22652-22652 System.err xyz.teamgravity.mokopermissionsdemo W at dev.icerock.moko.permissions.PermissionsControllerImpl.bind$lambda$1(PermissionsControllerImpl.kt:62)
2024-10-14 18:48:09.343 22652-22652 System.err xyz.teamgravity.mokopermissionsdemo W at dev.icerock.moko.permissions.PermissionsControllerImpl.$r8$lambda$ssanpq_AuAXa1Gs9w4o6Ga8mzFs(Unknown Source:0)
2024-10-14 18:48:09.343 22652-22652 System.err xyz.teamgravity.mokopermissionsdemo W at dev.icerock.moko.permissions.PermissionsControllerImpl$$ExternalSyntheticLambda0.onActivityResult(D8$$SyntheticClass:0)
2024-10-14 18:48:09.343 22652-22652 System.err xyz.teamgravity.mokopermissionsdemo W at androidx.activity.result.ActivityResultRegistry.doDispatch(ActivityResultRegistry.kt:371)
2024-10-14 18:48:09.344 22652-22652 System.err xyz.teamgravity.mokopermissionsdemo W at androidx.activity.result.ActivityResultRegistry.dispatchResult(ActivityResultRegistry.kt:331)
2024-10-14 18:48:09.344 22652-22652 System.err xyz.teamgravity.mokopermissionsdemo W at androidx.activity.ComponentActivity.onRequestPermissionsResult(ComponentActivity.kt:811)
2024-10-14 18:48:09.346 22652-22652 System.err xyz.teamgravity.mokopermissionsdemo W at android.app.Activity.onRequestPermissionsResult(Activity.java:5780)
2024-10-14 18:48:09.346 22652-22652 System.err xyz.teamgravity.mokopermissionsdemo W at android.app.Activity.dispatchRequestPermissionsResult(Activity.java:9532)
2024-10-14 18:48:09.346 22652-22652 System.err xyz.teamgravity.mokopermissionsdemo W at android.app.Activity.internalDispatchActivityResult(Activity.java:9387)
2024-10-14 18:48:09.346 22652-22652 System.err xyz.teamgravity.mokopermissionsdemo W at android.app.Activity.dispatchActivityResult(Activity.java:9356)
2024-10-14 18:48:09.346 22652-22652 System.err xyz.teamgravity.mokopermissionsdemo W at android.app.ActivityThread.deliverResults(ActivityThread.java:5867)
2024-10-14 18:48:09.346 22652-22652 System.err xyz.teamgravity.mokopermissionsdemo W at android.app.ActivityThread.handleSendResult(ActivityThread.java:5917)
2024-10-14 18:48:09.346 22652-22652 System.err xyz.teamgravity.mokopermissionsdemo W at android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:69)
2024-10-14 18:48:09.346 22652-22652 System.err xyz.teamgravity.mokopermissionsdemo W at android.app.servertransaction.ActivityTransactionItem.execute(ActivityTransactionItem.java:60)
2024-10-14 18:48:09.346 22652-22652 System.err xyz.teamgravity.mokopermissionsdemo W at android.app.servertransaction.TransactionExecutor.executeNonLifecycleItem(TransactionExecutor.java:174)
2024-10-14 18:48:09.346 22652-22652 System.err xyz.teamgravity.mokopermissionsdemo W at android.app.servertransaction.TransactionExecutor.executeTransactionItems(TransactionExecutor.java:109)
2024-10-14 18:48:09.346 22652-22652 System.err xyz.teamgravity.mokopermissionsdemo W at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:81)
2024-10-14 18:48:09.346 22652-22652 System.err xyz.teamgravity.mokopermissionsdemo W at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2636)
2024-10-14 18:48:09.346 22652-22652 System.err xyz.teamgravity.mokopermissionsdemo W at android.os.Handler.dispatchMessage(Handler.java:107)
2024-10-14 18:48:09.346 22652-22652 System.err xyz.teamgravity.mokopermissionsdemo W at android.os.Looper.loopOnce(Looper.java:232)
2024-10-14 18:48:09.346 22652-22652 System.err xyz.teamgravity.mokopermissionsdemo W at android.os.Looper.loop(Looper.java:317)
2024-10-14 18:48:09.346 22652-22652 System.err xyz.teamgravity.mokopermissionsdemo W at android.app.ActivityThread.main(ActivityThread.java:8705)
2024-10-14 18:48:09.346 22652-22652 System.err xyz.teamgravity.mokopermissionsdemo W at java.lang.reflect.Method.invoke(Native Method)
2024-10-14 18:48:09.346 22652-22652 System.err xyz.teamgravity.mokopermissionsdemo W at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:580)
2024-10-14 18:48:09.346 22652-22652 System.err xyz.teamgravity.mokopermissionsdemo W at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:886)
This is my code to request permission. but every time I get RequestCanceledException
fun RequestPermission(
factory: PermissionsControllerFactory = rememberPermissionsControllerFactory(),
controller: PermissionsController = remember(factory) { factory.createPermissionsController() },
permission: Permission,
onResult: (PermissionState) -> Unit
) {
BindEffect(controller)
LaunchedEffect(Unit) {
runCatching {
controller.providePermission(permission)
onResult(PermissionState.Granted)
}.onFailure { exception ->
when (exception) {
is DeniedAlwaysException -> onResult(PermissionState.DeniedAlways)
is DeniedException -> onResult(PermissionState.Denied)
is RequestCanceledException -> onResult(PermissionState.NotGranted)
}
}
}
}
Trying to show notification permission as soon as app starts. My device throw
dev.icerock.moko.permissions.RequestCanceledException
Activity saysCan request only one set of permissions at a time
I have attached sample code and error logs. Please check this and tell me if anything from my end is not well.
code
error Logs: