This repository was archived by the owner on Apr 4, 2023. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -74,12 +74,15 @@ export function showBanner(arg: BannerOptions): Promise<any> {
7474 // Wrapping it in a timeout makes sure that when this function is loaded from a Page.loaded event 'frame.topmost()' doesn't resolve to 'undefined'.
7575 // Also, in NativeScript 4+ it may be undefined anyway.. so using the appModule in that case.
7676 setTimeout ( ( ) => {
77- if ( topmost ( ) !== undefined ) {
78- topmost ( ) . currentPage . android . getParent ( ) . addView ( adViewLayout , relativeLayoutParamsOuter ) ;
79- } else {
77+ const top = topmost ( ) ;
78+ if ( top !== undefined && top . currentPage && top . currentPage . android && top . currentPage . android . getParent ( ) ) {
79+ top . currentPage . android . getParent ( ) . addView ( adViewLayout , relativeLayoutParamsOuter ) ;
80+ } else if ( appModule . android && appModule . android . foregroundActivity ) {
8081 appModule . android . foregroundActivity . getWindow ( ) . getDecorView ( ) . addView ( adViewLayout , relativeLayoutParamsOuter ) ;
82+ } else {
83+ console . log ( "Could not find a view to add the banner to" ) ;
8184 }
82- } , 0 ) ;
85+ } , 100 ) ;
8386 } catch ( ex ) {
8487 console . log ( "Error in firebase.admob.showBanner: " + ex ) ;
8588 reject ( ex ) ;
You can’t perform that action at this time.
0 commit comments