Skip to content
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

kotlin AppOpenExample not showing ads when app is moved to foreground #688

Open
pas-p opened this issue May 30, 2024 · 1 comment
Open

Comments

@pas-p
Copy link

pas-p commented May 30, 2024

The DefaultLifecycleObserver methods in MyApplication are not called at all. I think this can be solved moving the initialization methods (registerActivityLifecycleCallbacks(this), ProcessLifecycleOwner.get().lifecycle.addObserver(this)) from DefaultLifecycleObserver. onCreate(owner: LifecycleOwner) to Application.onCreate().

@SaimaUsman0333
Copy link

SaimaUsman0333 commented May 30, 2024

I have also been facing this issue. It always calls the onAdFailedToLoad callback but when I add a delay it shows fine. I am not sure if adding a delay in showing App Open Ad allowed or would it cause "Modified Ad Behavior" policy violation.
By delay I mean:

`override fun onStart(owner: LifecycleOwner) {
super.onStart(owner)
addDelay()
}

private fun addDelay() {
CoroutineScope(Dispatchers.Main).launch {
delay(100) // Delay for 2 seconds (2000 milliseconds)
// Code after delay
println("Delay finished.")
currentActivity?.let { appOpenAdManager.showAdIfAvailable(it) }
}`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants