B4A Library FirebaseAdMob - Admob ads integrated with Firebase backend

Status
Not open for further replies.

sorex

Expert
Licensed User
Longtime User
@Erel,

in the FireBaseAdmob.xml is this reference

B4X:
<event>AdLeftApplication</event>

is this a

B4X:
sub AdI_AdLeftApplication

even that can be used to know when the app is being closed due to a clicked interstitial so that we can save settings?
 

sorex

Expert
Licensed User
Longtime User
it is... altho the event happends after the ad gets closed since it gets queued. so not really usefull to save app data there.

Edit: silly me, I can save before using the .show command
 

mesutaslan

Member
Licensed User
Longtime User


What do you mean reinstalling google play services ?

I am using Google Play Services 31
also
google repistory 29 and android support repistory 33 is installed.

i am getting "not Received - Error Code: 0"

any idea ?
 

Douglas Farias

Expert
Licensed User
Longtime User
delete google play services on android sdk, check and press unistall.
later install again. it works for me
 

Jack Cole

Well-Known Member
Licensed User
Longtime User
Any way we could get this updated to support NativeExpressAds?

Here is a good start for the java code. I can't get it to compile because Eclipse can't find the class due to the new library referencing system.

B4X:
    @BA.ShortName(value="NativeExpressAd")
    public static class NativeExpressAdWrapper
    extends ViewWrapper<NativeExpressAdView> {
    public void Initialize(final BA ba, String EventName, String AdUnitId, Integer Width, Integer Height) {
        NativeExpressAdView ad = new NativeExpressAdView((Context)ba.activity);
        AdSize adSize=new AdSize(Width,Height);
        ad.setAdSize(adSize);
        ad.setAdUnitId(AdUnitId);
        this.setObject((Object)ad);
        super.Initialize(ba, EventName);
        final String eventName = EventName.toLowerCase(BA.cul);
       
       
        ((NativeExpressAdView)this.getObject()).setAdListener(new AdListener(){

            public void onAdFailedToLoad(int e) {
                ba.raiseEvent(NativeExpressAdViewWrapper.this.getObject(), String.valueOf(eventName) + "_failedtoreceivead", new Object[]{String.valueOf(e)});
            }

            public void onAdLoaded() {
                ba.raiseEvent(NativeExpressAdViewWrapper.this.getObject(), String.valueOf(eventName) + "_receivead", new Object[0]);
            }

            public void onAdClosed() {
                ba.raiseEventFromDifferentThread(NativeExpressAdViewWrapper.this.getObject(), (Object)null, 0, String.valueOf(eventName) + "_adscreendismissed", false, null);
            }

            public void onAdLeftApplication() {
            }

            public void onAdOpened() {
                ba.raiseEventFromDifferentThread(NativeExpressAdViewWrapper.this.getObject(), (Object)null, 0, String.valueOf(eventName) + "_presentscreen", false, null);
            }
        });
    }
    public void LoadAd() {
        AdRequest req = new AdRequest.Builder().build();
        ((NativeExpressAdView)this.getObject()).loadAd(req);
    }

    public void Pause() {
        ((NativeExpressAdView)this.getObject()).pause();
    }

    public void Resume() {
        ((NativeExpressAdView)this.getObject()).resume();
    }   
    }
 

Erel

B4X founder
Staff member
Licensed User
Longtime User

abhishek007p

Active Member
Licensed User
Longtime User
Do all AdMob users need to move to firebase admob? or only those who wish to use analytical in their ads.

can anyone tell me, thanks.
 

stefanoa

Active Member
Licensed User
Longtime User
Hi,
I'm trying to replace admob, integrating Firebase as described in the tutorial, but when i compile I get this error:

B4X:
B4A version: 6.00
Parsing code.    (0.73s)
Compiling code.    (1.58s)
Compiling layouts code.    (0.07s)
Organizing libraries.    (0.00s)
Generating R file.    (0.61s)
Compiling debugger engine code.    (7.40s)
Compiling generated Java code.    Error
javac 1.8.0_102
src\xxxxxxx\xxxxxxxxx\events.java:411: error: cannot find symbol
public anywheresoftware.b4a.admobwrapper.AdViewWrapper.InterstitialAdWrapper _iad = null;
                                                      ^
  symbol:   class InterstitialAdWrapper
  location: class AdViewWrapper
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 error

Can you help me? thanks
 

zhonghua

Member
Licensed User
I have 2 questions:

1. Must I publish the app on Google Play to get Ads? I can get Ads by using the test ID ,but when I use my id and my json file, it doesn't show the banner.

2. Can I add some code to set a test device?
 
Last edited:

Erel

B4X founder
Staff member
Licensed User
Longtime User
Are you handling the FailedToReceiveAd event? It will give more information about the reason for the lack of ads.

You can use this sub to load ads and set the test device id:
B4X:
Sub LoadAdWithTestDevice(Ad As AdView, TestId As String)
   Dim jo As JavaObject
   jo.InitializeNewInstance("com.google.android.gms.ads.AdRequest$Builder", Null)
   jo = jo.RunMethodJO("addTestDevice", Array(TestId)).RunMethod("build", Null)
   Dim jo2 As JavaObject = Ad
   jo2.RunMethod("loadAd", Array(jo))
End Sub

You can see the device id in the unfiltered logs.
 

zhonghua

Member
Licensed User
Actually the log shows "Received",but the banner doesn't show, the IAD ( interstitial ad ) does show when I click ,but only a black screen without any content and with a big 'X' button on the left top.

However, when I use this 'LoadAdWithTestDevice' sub that you provided , it does show a test banner ad.
Maybe my app is too simple (a edit ,some buttons ), Admob does not want to show ads on my app.
I'll try to publish a more complicated app on google play to make sure whether my code is correct or not.
 

StefanoAccorsi

Member
Licensed User
Longtime User
Hi there. Please, as usual, excuse me for my "noobing"

This is the first time I'm tring to use AdMod and, obviously, the first time I'm tring to configure it in B4A.

I followed the tutorials, all went ok: now in my app (still not released!) I can see the test-ads-banner.

But ... how to switch to the "real one"?

I mean: I registered in Firebase as suggested, but there's a key or something I've to put in my app?

I mean something to substitute this line of code:

B4X:
BannerAd.Initialize2("BannerAd", "ca-app-pub-3940256099942544/6300978111", BannerAd.SIZE_SMART_BANNER)

anyway I can't find it in my Firebase control panel ...

Thank you!
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…