Android Question Rewarded Ads....

Discussion in 'Android Questions' started by eps, Dec 2, 2018.

  1. eps

    eps Well-Known Member Licensed User

    I set this up for a new App I've created.

    The test reward ad showed and I thought it was all done and dusted, but now I'm not so sure that it is working any more - maybe due to sdk and b4a updates and my having misread or missed some of the requirements.

    My own reward ad wasn't showing - I had a return code of 0.

    So I reverted back to the test reward ad and it also gives a return code of 0. Which surely isn't possible is it? That ad should 'always' be available. I'll post some code in a moment - but was just wondering if anyone else had issues around newer sdk or b4a versions??
     
  2. eps

    eps Well-Known Member Licensed User

    Code:
    rewardAd.Initialize("rewardAd")
        rewardAd.LoadAd(
    "ca-app-pub-3940256099942544/5224354917")  'test id
    I've also got this

    Code:
    #AdditionalJar: com.google.android.gms:play-services-base
    Code:
    CreateResourceFromFile(Macro, FirebaseAnalytics.GooglePlayBase)
    CreateResourceFromFile(Macro, FirebaseAnalytics.Firebase)
    CreateResourceFromFile(Macro, FirebaseAdMob.FirebaseAds)
    I get a 0 response for the above.

    and am using v1.52 of the FireBaseAdmob library with B4A 8.5 minSDK 18 and targetSDK 27

    So what am I doing wrong here? I'm sure it's probably obvious to someone but I just can't fathom it and it feels like I've been going round and round in ever inter-entwining and decreasing circles.
     
  3. eps

    eps Well-Known Member Licensed User

    Is it that Admob recognises my gmail account as the primary one and therefore doesn't want to show ads to me?

    I've tried using this, but it just errors...

    Code:
    Dim builder As JavaObject
        builder.InitializeNewInstance(
    "com.google.android.gms.ads.AdRequest.Builder"Null)
        builder.RunMethod(
    "addTestDevice"Array("ID REMOVED"))
        
    Dim jo As JavaObject = rewardAd
        jo.RunMethod(
    "loadAd"Array(builder.RunMethod("build"Null)))
    LoadAd not matched...
     
    Last edited: Dec 2, 2018
  4. eps

    eps Well-Known Member Licensed User

    Hmm... I seem to have 2 Admob API keys for this App.... One for the App and one for Rewarded Ads... I guess I'm supposed to use the Rewarded Ads one - but should the google-services.json be linked to the app one or the Rewarded Ads one?
     
  5. Erel

    Erel Administrator Staff Member Licensed User

    google-services.json is not related to the ads.
     
  6. Computersmith64

    Computersmith64 Well-Known Member Licensed User

    I have rewarded ads running in one of my apps. I don't use:
    Code:
    #AdditionalJar: com.google.android.gms:play-services-base
    but I do use:
    Code:
    #AdditionalJar: com.google.android.gms:play-services-core
    The rest of my implementation is the same as your first example - ie:
    Code:
    rewardAd.Initialize("rewardAd")
        rewardAd.LoadAd(
    "ca-app-pub-3940256099942544/5224354917")
    & it works fine.

    - Colin.
     
  7. sorex

    sorex Expert Licensed User

    I think eps wants to use the GDPR proof method.

    Your method is not correct for EU people, Colin. :)
    The personalized trigger is not involved with the regular .loadAd

    I don't know how to do it right for rewarded videos tho as I only tested it with interstitials.
     
  8. Computersmith64

    Computersmith64 Well-Known Member Licensed User

    I didn't get that from his post. I just got that he was trying different ways of getting it to work.

    My implementation is fine for EU people, because I also use interstitials in the same app & show the consent form when I initialise them at the start of the app. :)

    - Colin.
     
  9. Computersmith64

    Computersmith64 Well-Known Member Licensed User

    Actually, I tell a lie. I show the consent form from the Starter service.

    - Colin.
     
  10. sorex

    sorex Expert Licensed User

    showing the consent form is 1 thing. showing non-personlized interstitials and rewarded videos is another thing.

    for interstitials you need to use that builder method based on that selected setting.
    so I guess you need to do the same thing for the rewarded videos that's why he posted that javaobject code.
     
  11. Computersmith64

    Computersmith64 Well-Known Member Licensed User

    Yeah, you're right. I do it with the interstitials, but I guess I overlooked it on the rewarded ads.

    - Colin.
     
  12. eps

    eps Well-Known Member Licensed User

    Thanks everyone, I'll take a look in a moment... I was mainly looking to just get it all working again and then to consider the EU GDPR consent BS
     
  13. eps

    eps Well-Known Member Licensed User

    Hi Erel - well that's interesting as I thought it was - it seems to mention my publisher and advert id in there...
     
  14. eps

    eps Well-Known Member Licensed User

    I've put together a test app.... Which doesn't work either.

    So far I've got it to tell me this :

    Use AdRequest.Builder.addTestDevice("REMOVED") to get test ads on this device.

    So if I add the code for that, as above it then tells me...

    LoadAd not Matched..

    So I'm at an impasse. I'll see if I can test on another device....
     
  15. Computersmith64

    Computersmith64 Well-Known Member Licensed User

    So according to the AdMob documentation, the LoadAd method looks like this:

    Code:
    private void loadRewardedVideoAd() {
        mRewardedVideoAd.loadAd(
    "ca-app-pub-3940256099942544/5224354917",
                new AdRequest.Builder().build());
    }
    That being the case, have you tried:

    Code:
    Dim builder As JavaObject
        builder.InitializeNewInstance(
    "com.google.android.gms.ads.AdRequest.Builder"Null)
        builder.RunMethod(
    "addTestDevice"Array("ID REMOVED"))
        
    Dim jo As JavaObject = rewardAd
        jo.RunMethod(
    "loadAd"Array("ca-app-pub-3940256099942544/5224354917", builder.RunMethod("build"Null)))
    - Colin.
     
    eps likes this.
  16. eps

    eps Well-Known Member Licensed User

    Hi Colin, I haven't - I'll give it a whirl, thanks!

    That's great - thank you! It didn't work initially but on reinstalling it does work. I now need to unpick my code to work out why my actual app doesn't work currently. Cheers!

    :)
     
    Last edited: Dec 4, 2018
  17. eps

    eps Well-Known Member Licensed User

    Ah - I see what the problem is here, I included :
    Code:
    CreateResourceFromFile(Macro, FirebaseAnalytics.Firebase)
    As well, which wanted the json file included. Now I've commented that Macro out it doesn't require the json file :)

    Now I just use :

    Code:
    CreateResourceFromFile(Macro, FirebaseAnalytics.GooglePlayBase)
    CreateResourceFromFile(Macro, FirebaseAdMob.FirebaseAds)
     
  18. eps

    eps Well-Known Member Licensed User

    This all works now, THANK YOU @Computersmith64 !! :)

    It even displays 'my' ads.

    I've put the analytics back in - the .json file for this is the App one. You can generate a 'json file for the rewardedAd Unit as well, which is where I was coming unstuck I think. The consent form displays and I can select it, etc.. it's quite ugly and painful but at least that works. Of course my next question is how to integrate the part where it talks about a Paid For version - or do I just not mention that on the Consent Form and then offer one on the App Store? Hm.... We're a bit of a way away from that!

    :D
     
  19. Computersmith64

    Computersmith64 Well-Known Member Licensed User

    Glad you got it working. I would recommend only having one app & using an IAP. I have done it both ways (IAP & different paid version) & it's much easier to have the IAP as you don't have to update multiple versions all the time. Even when you use the same code base with different build configurations (which I do), it can get a bit messy, plus you have 2 separate apps to maintain on Play Store.

    This is how I do it in Dice Match:

    Code:
    Public Sub ConsentStateAvailable(user As Boolean)
        
    Dim consent As ConsentManager = Starter.consent
        
    If (consent.ConsentState = consent.STATE_UNKNOWN And consent.IsRequestLocationInEeaOrUnknown) Or user Then
            
    'Set last parameter to False if you don't want to show the "pay for ad-free" option.
            'Change privacy policy URL.
            consent.ShowConsentForm("https://www.facebook.com/notes/computersmith/computersmith-data-consent-policy/2049613211975625/"TrueTrueTrue)
            
    Wait For Consent_FormResult (Success As Boolean, UserPrefersAdFreeOption As Boolean)
            
    If Success Then
                
    Log($"Consent form result: ${consent.ConsentState}, AdFree: ${UserPrefersAdFreeOption}"$)
                
    If consent.ConsentState = consent.STATE_PERSONALIZED Or consent.ConsentState = consent.STATE_NON_PERSONALIZED Then
                    
    If Starter.analytics.IsInitialized Then Starter.analytics.SendEvent(consent.ConsentState, Null)
                    MsgboxAsync(
    "Thank you! We will not ask you for your consent again. If you wish to change or cancel your consent, please use the Privacy option on the game menu.""Consent Saved")
                
    Else if UserPrefersAdFreeOption Then
                    Starter.wantsAdFree = 
    True
                    
    If Starter.analytics.IsInitialized Then Starter.analytics.SendEvent("AdFree"Null)
                    MsgboxAsync(
    "Thank you! You will be redirected to the purchase screen where you can buy the No Ads upgrade.""Ad Free Option")
                    
    Wait For MsgBox_Result(res As Int)
                    
    StartActivity(Purchase)
                
    End If
            
    Else
                
    Log($"Error: ${LastException}"$)
            
    End If
        
    End If
           
    End Sub
    - Colin.
     
    eps likes this.
  20. eps

    eps Well-Known Member Licensed User

    Cheers - I'll take a look and digest... I had already decided to not have the 'Go for Paid App' option anyway and allow Users to select Personalised or Non-Personalised. Hopefully this will give them enough choices!
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice