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

Load fail event is not triggered #30

Closed
merbin2012 opened this issue Nov 25, 2024 · 8 comments
Closed

Load fail event is not triggered #30

merbin2012 opened this issue Nov 25, 2024 · 8 comments
Assignees
Labels
bug Something isn't working

Comments

@merbin2012
Copy link
Contributor

merbin2012 commented Nov 25, 2024

I have seen this issue before, but I am not concerned about it due to some other testing on this plugin.

Ad load error, return the following errors

cordova.fireDocumentEvent('on.appOpenAd.failed.loaded, {"responseInfo":"{\n \"Response ID\": \"null\",\n \"Mediation Adapter Class Name\": \"\",\n \"Adapter Responses\": [],\n \"Response Extras\": {}\n}","code":3,"message":"Ad unit doesn't match format. <https:\/\/support.google.com\/admob\/answer\/9905175#4>","domain":"com.google.android.gms.ads","cause":"null"}');

Escape character issue, you can just copy the above code and paste it to the VSC in .js file.

The same thing I was seen for interstitial ads too, I think the same issue is existing in banner and other ads too.

error screenshot
error screenshot 2

"javascript:cordova.fireDocumentEvent('on.interstitial.failed.load', ${errorData});"
"javascript:cordova.fireDocumentEvent('on.interstitialAd.responseInfo', ${result});"
"javascript:cordova.fireDocumentEvent('on.appOpenAd.failed.loaded, ${errorData}');"
"javascript:cordova.fireDocumentEvent('on.interstitial.revenue', ${result});"
....
....
....
and etc.. places. Please fix this

I just get this from chatGPT, please check and update it

val escapedErrorData = errorData.replace("\"", "\\\"").replace("\n", "\\n")
cWebView!!.loadUrl(
    "javascript:cordova.fireDocumentEvent('on.appOpenAd.failed.loaded', \"$escapedErrorData\");"
)
@EMI-INDO EMI-INDO self-assigned this Nov 25, 2024
@EMI-INDO EMI-INDO added the bug Something isn't working label Nov 25, 2024
@EMI-INDO
Copy link
Owner

"javascript:cordova.fireDocumentEvent('on.interstitialAd.responseInfo', ${result});"

responseInfo has object{}, array[], string“”, (), /
then replace(“\”“,”\\“”).replace(“\n”,“\n”) will not fully work.

in logcat android studio it will look fine, but when executed by cWebView, it will not be like logcat, it has to be handled in detail.

it's pretty easy using the 'com.google.code.gson:gson:2.10.1' implementation but the 300-400 kb jar will add up.

Otherwise it should all be handled carefully.

EMI-INDO added a commit that referenced this issue Nov 25, 2024
fix event

#30

on.banner.failed.load
on.appOpenAd.failed.loaded
on.interstitial.failed.load
on.rewardedInt.failed.load
@EMI-INDO
Copy link
Owner

EMI-INDO commented Nov 25, 2024

[email protected]

Users should use their own methods

  • maybe this helps a little
<script src=“https://cdn.jsdelivr.net/npm/[email protected]/dist/index.min.js”></script>

document.addEventListener('on.interstitialAd.responseInfo', (data) => {

  • Cleansing data from unnecessary or invalid characters
  • Solve the escape character problem

});

If there is free time, I will create a function to handle Cleansing data from unnecessary or invalid characters
Solve the escape character problem,

it's simply from the document.addEventListener('on.interstitialAd.responseInfo block

@merbin2012
Copy link
Contributor Author

merbin2012 commented Nov 25, 2024

This is not a javascript side problem, while we calling the javascript method from java(kotlin) code, so we have to handle it from java(kotlin) code. The above mentioned code is kotlin

@EMI-INDO
Copy link
Owner

EMI-INDO commented Nov 25, 2024

sorry I only fixed Load fail event is not triggered

I tested the method you suggested doesn't work on a real device.

val escapedErrorData = errorData.replace("\"", "\\\"").replace("\n", "\\n")
cWebView!!.loadUrl(
    "javascript:cordova.fireDocumentEvent('on.appOpenAd.failed.loaded', \"$escapedErrorData\");"
)
  • Have you tested what you suggest

@merbin2012
Copy link
Contributor Author

No, I'm not tested . Did you understand the error?
If not just copy and paste this code in visual studio code, you can exactly identify the issue.

cordova.fireDocumentEvent('on.appOpenAd.failed.loaded, {"responseInfo":"{\n \"Response ID\": \"null\",\n \"Mediation Adapter Class Name\": \"\",\n \"Adapter Responses\": [],\n \"Response Extras\": {}\n}","code":3,"message":"Ad unit doesn't match format. <https:\/\/support.google.com\/admob\/answer\/9905175#4>","domain":"com.google.android.gms.ads","cause":"null"}');
This is the code created in kotlin. Here it is 4AM, I'm in mobile, I will also try to fix it while I'm in the system.

@EMI-INDO
Copy link
Owner

I tested several times with the original adUnitId, everything was fine.

I don't get any error

  • try checking again whether adUnitId is really adUnitId AppOpenAd.

  • or try creating a new adUnitId.

https://groups.google.com/g/google-admob-ads-sdk/c/T7uNaa7AoFo

googleads/googleads-mobile-android-examples#626

@merbin2012
Copy link
Contributor Author

This issue is not related to that. Whenever call the javascript methode from kotlin with the error details as a parameter this issue is occurring. I think it is easy to solve, I will check and let you know the status.

@merbin2012
Copy link
Contributor Author

@EMI-INDO Great, this issue has been resolved.
Thank you

EMI-INDO added a commit that referenced this issue Nov 26, 2024
loadAdError responseInfo get obj val

Escape character issue: #30

- code
- message
- domain
- responseInfoId
- responseInfoExtras
- responseInfoAdapter
- responseInfoMediationAdapterClassName
- responseInfoAdapterResponses
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants