ratson / cordova-plugin-admob-free

New development has been moved to "admob-plus-cordova", https://github.com/admob-plus/admob-plus/tree/master/packages/cordova
https://github.com/admob-plus/admob-plus
MIT License
499 stars 214 forks source link

Ionic 4 won’t show ads but in console is successful #368

Open robertnicjoo opened 4 years ago

robertnicjoo commented 4 years ago

I am trying to get Admob in my app, I get console log success message but no ad showing in my app.

This is what I have:

app.module

import { AdMobFree } from '@ionic-native/admob-free/ngx';

providers: [
    AdMobFree,
]

posts.page.ts

import { AdMobFree, AdMobFreeBannerConfig } from '@ionic-native/admob-free/ngx';

constructor(
    private admobFree: AdMobFree
) { }

ionViewDidEnter() {
    this.showBannerAds();
}

showBannerAds() {
    const bannerConfig: AdMobFreeBannerConfig = {
      id: 'ca-app-pub-xxxxxx/xxxxxxxxxx',
      isTesting: false,
      autoShow: true,
      bannerAtTop: false
    };
    this.admobFree.banner.config(bannerConfig);
    console.log('start to prepare banner ads...'); //shows in console

    this.admobFree.banner.prepare()
      .then(() => {
        console.log('start to show banner ads...'); //shows in console
        this.admobFree.banner.show();
      })
      .catch(err => {
        console.log('show banner ads error: ', err);
      });
}

PS: At the first I thought maybe i need to add my app in google play then they show, but even that my app is live on google play store yet no ads showing.

Any idea what could be wrong?

robertnicjoo commented 4 years ago

Nobody?

tominou commented 4 years ago

To try if it works, set isTesting: true and use a debug build, so an ad should always be displayed.

Also, listen on admob events to be sure you are not missing anything:

document.addEventListener('admob.interstitial.events.LOAD', function(data){ console.log('admob.interstitial.events.LOAD', data); });
document.addEventListener('admob.interstitial.events.LOAD_FAIL', function(data){ console.log('admob.interstitial.events.LOAD_FAIL', data); });
document.addEventListener('admob.interstitial.events.OPEN', function(data){ console.log('admob.interstitial.events.OPEN', data); });
document.addEventListener('admob.interstitial.events.CLOSE', function(data){ console.log('admob.interstitial.events.CLOSE', data); });
document.addEventListener('admob.banner.events.LOAD', function(data){ console.log('admob.banner.events.LOAD', data); });
document.addEventListener('admob.banner.events.LOAD_FAIL', function(data){ console.log('admob.banner.events.LOAD_FAIL', data); });
document.addEventListener('admob.banner.events.OPEN', function(data){ console.log('admob.banner.events.OPEN', data); });
document.addEventListener('admob.banner.events.CLOSE', function(data){ console.log('admob.banner.events.CLOSE', data); });
robertnicjoo commented 4 years ago

@tominou where do i place this codes?

tominou commented 4 years ago

I am not familiar with ionic, but you should put it in your main file, somewhere it will be executed only once.

robertnicjoo commented 4 years ago

thanks, i keep trying

robertnicjoo commented 4 years ago

@tominou this is what i get:

admob.banner.events.LOAD_FAIL 
Event {isTrusted: false, error: 0, reason: "Internal error", adType: "banner", type: "admob.banner.events.LOAD_FAIL", …}
adType: "banner"
bubbles: false
cancelBubble: false
cancelable: false
composed: false
currentTarget: null
defaultPrevented: false
error: 0
eventPhase: 0
isTrusted: false
path: (2) [document, Window]
reason: "Internal error"
returnValue: true
srcElement: document
target: document
timeStamp: 222712.69999997457
type: "admob.banner.events.LOAD_FAIL"
__proto__: Event
tominou commented 4 years ago

Can you show me the content of platform/android/project.properties and platform/android/app/src/main/AndroidManifest.xml

robertnicjoo commented 4 years ago

@tominou

project.properties

# This file was originally created by the Android Tools, but is now
# used by cordova-android to manage the state of the various third party
# libraries used in your application

# This is the Library Module that contains the Cordova Library, this is not
# required when using an AAR

# This is the application project.  This is only required for Android Studio Gradle projects

# Project target.
target=android-28
android.library.reference.1=CordovaLib
android.library.reference.2=app
cordova.system.library.1=com.google.android.gms:play-services-base:11.0.4
cordova.system.library.2=com.google.android.gms:play-services-ads:11.0.4
cordova.system.library.3=com.squareup.okhttp3:okhttp-urlconnection:3.10.0
cordova.system.library.4=com.android.support:support-annotations:27.+
cordova.system.library.5=com.android.support:support-v4:24.1.1+
cordova.system.library.6=com.onesignal:OneSignal:3.10.8
cordova.gradle.include.1=onesignal-cordova-plugin/studio-build-extras-onesignal.gradle

AndroidManifest.xml

<?xml version='1.0' encoding='utf-8'?>
<manifest android:hardwareAccelerated="true" android:versionCode="112" android:versionName="0.1.12" package="com.XXXX.XXXX" xmlns:android="http://schemas.android.com/apk/res/android">
    <supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:resizeable="true" android:smallScreens="true" android:xlargeScreens="true" />
    <uses-permission android:name="android.permission.INTERNET" />
    <application android:hardwareAccelerated="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:networkSecurityConfig="@xml/network_security_config" android:supportsRtl="true">
        <activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" android:label="@string/activity_name" android:launchMode="singleTop" android:name="MainActivity" android:theme="@android:style/Theme.DeviceDefault.NoActionBar" android:windowSoftInputMode="adjustResize">
            <intent-filter android:label="@string/launcher_name">
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" android:name="com.google.android.gms.ads.AdActivity" android:theme="@android:style/Theme.Translucent" />
        <meta-data android:name="com.google.android.gms.ads.APPLICATION_ID" android:value="ca-app-pub-7831025766780177~9989918044" />
        <receiver android:enabled="true" android:name="nl.xservices.plugins.ShareChooserPendingIntent">
            <intent-filter>
                <action android:name="android.intent.action.SEND" />
            </intent-filter>
        </receiver>
        <provider android:authorities="${applicationId}.sharing.provider" android:exported="false" android:grantUriPermissions="true" android:name="nl.xservices.plugins.FileProvider">
            <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/sharing_paths" />
        </provider>
        <amazon:enable-feature android:name="com.amazon.device.messaging" android:required="false" xmlns:amazon="http://schemas.amazon.com/apk/res/android" />
        <service android:exported="false" android:name="com.onesignal.ADMMessageHandler" />
        <receiver android:name="com.onesignal.ADMMessageHandler$Receiver" android:permission="com.amazon.device.messaging.permission.SEND">
            <intent-filter>
                <action android:name="com.amazon.device.messaging.intent.REGISTRATION" />
                <action android:name="com.amazon.device.messaging.intent.RECEIVE" />
                <category android:name="com.XXXX.XXXX" />
            </intent-filter>
        </receiver>
    </application>
    <uses-sdk android:minSdkVersion="19" android:targetSdkVersion="28" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="com.amazon.device.messaging.permission.RECEIVE" />
    <permission android:name="com.XXXX.XXXX.permission.RECEIVE_ADM_MESSAGE" android:protectionLevel="signature" />
    <uses-permission android:name="com.XXXX.XXXX.permission.RECEIVE_ADM_MESSAGE" />
</manifest>
robertnicjoo commented 4 years ago

@tominou Are you there bro?

robertnicjoo commented 4 years ago

👆 👀

robertnicjoo commented 4 years ago

@tominou please help?!

ShellsOfSilver commented 4 years ago

@robertnicjoo try test your app on another device.