@alokjkumar97 wrote:
Ionic v5 with Angular using https://github.com/rahadur/capacitor-admob
Hi I have followed the set up guide and am seeing a splashscreen at the bottom of the page for banner ads:
I also get this view whilst the app is starting up - if there’s any way to prevent the splashscreen in the corner that would be great
I have abstracted the plugin to a separate service called admob.service.ts as so:
To initialize the plugin:
constructor(private platform: Platform) { if(this.platform.is('mobileweb') || this.platform.is('desktop')) { // pass } else if(this.platform.is('ios')) { AdMob.initialize('ca-app-pub-ios-key'); } else { AdMob.initialize('ca-app-pub-android-key'); } }
To show a banner ad:
public async showBannerAd(position: any = AdPosition.BOTTOM_CENTER, adSize: any = AdSize.SMART_BANNER): Promise<any> { if(this.platform.is('mobileweb') || this.platform.is('desktop')) { return; } // This is a test ID const adId = 'ca-app-pub-3940256099942544/6300978111'; const options: AdOptions = { adId: adId, adSize: adSize, position: position, hasTabBar: false, } AdMob.addListener('onAddFailedToLoad', async (info: any) => { this.removeBannerAd(); }); return AdMob.showBanner(options) }
I had to upgrade the plugin to AndroidX which is where I think the problem is:
AdMob.java
import androidx.coordinatorlayout.widget.CoordinatorLayout;
bridge_layout_main.xml
<?xml version="1.0" encoding="utf-8"?> <androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.getcapacitor.BridgeActivity" > <WebView android:id="@+id/webview" android:layout_width="fill_parent" android:layout_height="fill_parent" /> </androidx.coordinatorlayout.widget.CoordinatorLayout>
Appreciate any thoughts
Posts: 1
Participants: 1