-
Notifications
You must be signed in to change notification settings - Fork 368
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added activity lifecycle handler to safe call android settings dialog #2088
Conversation
2cf4b7f
to
0cf1d47
Compare
0cf1d47
to
3d6691b
Compare
@caghp94 Thanks for the PR! I looked it over and I see 2 entries points to the code that is modified in this PR.
|
Hello @jkasten2 , the implementation of the
|
@caghp94 ah yes you are correct, it won't break However with that information, looking at the |
@jkasten2 you are right! just updated with the modification |
cca9fd3
to
3d20821
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested this on Android 6.0 (but probably happens on any Android version) and the prompt is not showing;
- Opened app
- Disabled notifications for the app in the settings
- Attempted to prompt with
requestPermission(true)
- Observe nothing happens in the app, and we get an error in the logcat.
2024-05-31 14:36:01.667 4250-4422 OneSignal com.onesignal.sdktest E Exception on thread
java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
at android.os.Handler.<init>(Handler.java:200)
at android.os.Handler.<init>(Handler.java:114)
at android.app.Dialog.<init>(Dialog.java:119)
at android.app.AlertDialog.<init>(AlertDialog.java:200)
at android.app.AlertDialog$Builder.create(AlertDialog.java:1086)
at android.app.AlertDialog$Builder.show(AlertDialog.java:1111)
at com.onesignal.core.internal.permissions.AlertDialogPrepromptForAndroidSettings$show$1$onActivityAvailable$1.invokeSuspend(AlertDialogPrepromptForAndroidSettings.kt:79)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
at kotlinx.coroutines.EventLoopImplBase.processNextEvent(EventLoop.common.kt:284)
at kotlinx.coroutines.BlockingCoroutine.joinBlocking(Builders.kt:85)
at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking(Builders.kt:59)
at kotlinx.coroutines.BuildersKt.runBlocking(Unknown Source)
at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking$default(Builders.kt:38)
at kotlinx.coroutines.BuildersKt.runBlocking$default(Unknown Source)
at com.onesignal.common.threading.ThreadUtilsKt$suspendifyOnThread$1.invoke(ThreadUtils.kt:69)
at com.onesignal.common.threading.ThreadUtilsKt$suspendifyOnThread$1.invoke(ThreadUtils.kt:67)
at kotlin.concurrent.ThreadsKt$thread$thread$1.run(Thread.kt:30)
Description
One Line Summary
Added a safe call for
AlertDialogPrepromptForAndroidSettings.show()
using an activity lifecycle handlerDetails
Motivation
This is a fix for #2014.
Affected code checklist
Checklist
Overview
Testing
Final pass
This change is