[Free] Admob Extension - Add different types of android ads in your application

Admob Extension

This extension will help you to add different types of admob ads in your app-inventor application. This extension is divided into different extensions according to the ad-type.

Get Started :

You should first integrate the necessary libraries required to display ad in your application. I've added all the libraries required in AdmobSdk Extension. So, to integrate any of the ad-type, you should first download this extension and add in your application & initialize sdk in the application. As well as, now you can change Child-directed setting, Users under the age of consent & Ad content filtering from this extension.

Download Latest Version Of AdmobSdk Extension From Github

This extension got these blocks :

  1. InitializeSdk

    component_method
    You should call this method to initialize the required sdks. On Successful, It will trigger the event SdkInitialized.
    I suggest you to call this method on Screen1.initalize .

  2. SdkInitialized

    component_event
    This event is triggered if sdk is initialized successfully in your application. Now you can call other ads to be loaded.

  3. TagForChildDirectedTreatment


    Now you can change tag for child directed treatment from the extension. You can find more about this from here. It aceept integer value and value can either be 0,1 or -1. For true it should be 1, for false it should be 0 & for unspecified it should be -1.

  4. TagForUnderAgeOfConsent


    Now you can change tag for under age of consent from the extension. You can find more about this from here. For true, it should be 1, for false it should be 0 & for unspecified it should be -1.

  5. MaxAdContentRating


    You can add max content rating using this method. You can find more about this from here. The values can be G,MA,PG or T. G represents that content are suitable for general audiences, including families. MA represents that content are suitable for only matured audiences. PG represents that content are are suitable for most audiences with parental guidance & T represents content are suitable for teen and older audiences.

Adding Admob Ad Id in androidmanifest.xml

You should add admob App Id in androidmanifest.xml of your application. So, you need to create an extension by yourself. Don't panic, I'll go through an easy method so that you can successfully do it. Follow these methods:

  1. Go to https://ide.niotron.com/ , create a new account if you don't have one.

  2. Create a new project, with any project name and package name & continue. In my case, like this:

    image

  3. Add this to your imports

  import com.google.appinventor.components.annotations.androidmanifest.*;
  1. Then add this after @UsesPermissions
   @UsesApplicationMetadata(metaDataElements={@MetaDataElement(name="com.google.android.gms.ads.APPLICATION_ID", value="your-app-id")})

Like this :

  1. Change the value of "your-app-id" to your AdMob app id. In my case, I am using test app id which you can use if you are testing.
    ca-app-pub-3940256099942544~3347511713
  1. Now, tap on CompileExtension and an extension will be downloaded. Just add that extension in your application where you wanted to show admob ads.

AdMob Banner Ads

This extension will help you to show a banner ad in your extension. If you have initialized sdk successfully then you can use this extension to load and show the banner ads.

Download Latest Version Of AdMob Banner Extension From Github

This extension has following blocks :

  1. AdUnit

    component_set_get
    This method helps you to set your banner ad unit id. Remember to check TestMode to false if you are not developing the application for testing.

  2. TestMode

    component_set_get (1)

    component_set_get (2)
    This method helps you to load and show test ads in your application. You should always use TestMode if you are just testing the application and app is not yet for the production.

  3. LoadBanner

    component_method (1)

    component_event (1)

    component_event (2)
    This method will help you to load banner ad with different size like Banner, LargeBanner, MediumRectangle, FullSize & Custom Size from height and width. After you loaded, you can show your ad in the arrangement using ShowBanner method. If banner is successfully loaded then it will trigger AdLoaded event . If it is failed to load banner ad then it will trigger AdFailedToLoad event with an error message.

  4. ShowAd



    component_event (6)

    component_event (5)

    component_event (4)

    component_event (3)

ShowAd method will help you to show your loaded banner ad in particular arrangement. Also, if ad opens an overlay, It will trigger AdOpened event, if user clicks on ad then it will trigger AdClicked event, if ad is closed then it will trigger AdClosed event & more.

AdMob Interstitial Ad

This extension will help you to show the interstitial ad in your application. If you have initialized sdk successfully first then you can use this extension to load and show interstitial ad.

Download Latest Version Of AdMob Interstitial Extension From Github

This extension has following blocks :

  1. AdUnitId

    component_set_get (3)
    This method helps you to set your interstitial ad unit id. Remember to check TestMode to false if you are not developing the application for testing.

  2. TestMode

    component_set_get (4)

    component_set_get (5)
    This method helps you to load and show test ads in your application. You should always use TestMode if you are just testing the application and app is not yet for the production.

  3. LoadIntersititalAd

    component_method (2)
    component_event
    component_event (1)
    LoadInterstitialAd method helps you to load intersitial ad. If success, it will trigger AdLoaded event and if failed it will trigger AdFailedToLoad event. You can show ads after sucessfully loading interstitial ad.

  4. ShowAd

    component_method (3)







    component_event (5)

    component_event (6)

    component_event (7)
    ShowAd method helps to show loaded interstitial ad. If Ad is failed to show because ad was not loaded then it will call FailedToShowAd event. If Ad is failed to show FullScreenContent then it will trigger FailedToShowFullScreenContent event. If Ad is shown then it will trigger ShowedFullScreenContent event. If Ad is dismissed then it will call DismissedFullScreenContent event. If Ad is on impression then it will call AdImpression event & finally, if Ad is clicked then it will call AdClicked event.

AdMob Rewarded Ad

This extension will help you to show the rewarded ad in your application. If you have initialized sdk successfully first then you can use this extension to load and show rewarded ad.

Download Latest Version Of AdMob Rewarded Extension From Github

Similar to Admob Interstitial above, this extension has following blocks ( I guess, you don't need documentation of each block, since its similar to Interstitial blocks, you can understand it through Interstitial documentation above)
image

AdMob Rewarded Interstitial Ad

This extension will help you to show the rewarded-interstitial ad in your application. If you have initialized sdk successfully first then you can use this extension to load and show rewarded-interstitial ad.

Download Latest Version Of AdMob Rewarded-Interstitial Extension From Github

This extension has following blocks similar to Admob Interstitial. You can head over to its documentation above to understand each blocks.

Admob AppOpen Ad

This extension will help you to load and show the App-Open ads in your application. You can use this extension after you initialized sdk successfully. Also, LoadAd method needs orientation which can either be Portrait or Landscape.

Download Latest Version Of AdMob AppOpen Extension From Github

This extension has similar blocks like Admob Interstitial extension. You can head over to its documentation to learn about each blocks.
image


I'll add Native Ad here. Your suggestions are always welcomed.

These Extension are open-sourced at Github at here :

If you loved my works then you can support me my donating me :

12 Likes

Excellent work @oseamiya
What a trick :scream::scream:

2 Likes

Great work @oseamiya ! :partying_face:

1 Like

Very Great @oseamiya
Thanks a lot!
:star_struck:

3 Likes

great work, Extremely incredibly useful extension

2 Likes

@Faraz_Firoz @SRIKAR_B.S.S @Aquib_Khan @Hades

Thankyou so much !


Also, Some extension has been updated aswell as App-Open Ad is added. I've edited these changes in documentation too.

  1. Admob Sdk extension is updated commit. It now have total of 5 blocks. Now you can set/change targeting of audience from this extension. You can find about targeting from here.

  2. Admob Banner extension is updated commit. Now you can customize size of banner ads while loading the banner ad. Now you can set size to banner size, medium rectangle size, large banner size, full banner size and your own custom size.

  3. Added AppOpen Ad commits. Now you can add App-Open ad in your application.

7 Likes

A post was split to a new topic: Error while compiling extension

the extension is not working at all
Ad failed to load error message: No ad config
Interstitial ads shows runtime error and it can`t be rebuilt using rush after fixing this error

1 Like

Are you using companion ?

This error occurs if Ad request was not filled due to lack of availability of ads. If you are getting in Test Rewarded id then try with your own admob reward ad. I guess you will not get this error in real id.

whether I am using the companion or the compiled app, no ads load
would you please upload an aia file? :eyes:

AdsApp.aia (2.0 MB)
This uses test ids.

1 Like

works great for me now :sweat_smile:, thanks :grin:

I called this method on Screen1.initalize, it worked for some time but now it gives me this error.
What can be the problem?

You need to ask a permission when screen Initialize

 When Screen1 Initialize 
     Call Screen1 AskForPermission permission name = android.permission.ACCESS_NETWORK_STATE

Delete old AdmobSdk extension & use this : com.oseamiya.admobsdks

I have not added this permission in manifest thinking that it will added by default :sweat_smile:. Later on I read this post but forgot to update the extension. Extension has been updated now.

Now it works thanks :blush:

My application consists of 3 screens, do I have to initialize sdk on each screen?


rewarded ad test code is wrong

and please add

thank u for all

no :slight_smile: I tried

1 Like

You can initialize AdMob once the application starts (Screen1), you also can initialize it in other screens but you don't need to, once is enough.

1 Like

You can use SetAdUnitId block to set your ad unit id .

1 Like