Open calebeaires opened 8 years ago
Can you try fiddling with these lines to fix it?
Removing timeout the problem disappears!
I've had a problem with this plugin crashing only on certain phones and not every time.
I was able to gain a lot more stability by modifying the plugins code to only use appModule
Changed the following lines in admob.android.js from this:
if (frame_1.topmost() !== undefined) {
frame_1.topmost().currentPage.android.getParent().addView(adViewLayout_1, relativeLayoutParamsOuter_1);
} else {
appModule.android.foregroundActivity.getWindow().getDecorView().addView(adViewLayout_1, relativeLayoutParamsOuter_1);
}
To this:
appModule.android.foregroundActivity.getWindow().getDecorView().addView(adViewLayout_1, relativeLayoutParamsOuter_1);
After that the crashes stopped.
I even put a check for frame topmost around the firebase instantiation and that didn't help. I found that sometimes popups (permission requests) would interfere with the plugin.
If appModule works more often, why bother with the frame topmost method?
Ok, so if you use the appModule method, it puts the banner behind the navigation buttons.
Going back to the script....
setTimeout(function () {
if (frame_1.topmost() !== undefined) {
var topMost = frame_1.topmost();
var currentPage = topMost.currentPage;
var currentPageParent = currentPage.android.getParent();
console.log(currentPageParent); // null
currentPageParent.addView(adViewLayout_1, relativeLayoutParamsOuter_1);
Even though it finds frame_1.topmost(), the current page parent is null, causing an error when trying to addView.
After topmost goBack, when calling the admob create banner again, I get this error
nativescript-admob: 1.1.4 nativescript: 2.0 emulator: android 6.0