Phonegap build - Admob plugin

I have tried a number of phongap build plugins for Admob but whatever I do I can not get it to work.

Can anyone help ?

I am looking for the same help. Has anyone been able to display admob ads in a native android app made with phonegap?

Hi, Yes we display Admob adds some in of our free apps built with Phonegap build.
Change the publisherId to your own ID you get from Admob.

Form1_onshow()
admob.createBannerView({publisherId: "ca-app-pub-2485962283878959/9340556"});
End function.

You will need to add this plugin in your config.xml

<gap:plugin name="phonegap-admob" source="npm"/>

Thanks for the reply. I tried this but I get the error below. Column 42 appears to be at the first double quote.

Uncaught SyntaxError: Invalid or unexpected token.
line 3 column 42

@Pro_Certs, could you review the code you posted? I see a few errors.

Function Form1_onshow()
admob.createBannerView({publisherId: “your pubID”});
End Function

Has anyone been able to display AdMob ads in a native android app made with voltbuilder?

Yes I use this plugin, admob-plus-cordova https://www.npmjs.com/package/admob-plus-cordova Getting Started | AdMob Plus

Hi, i have 2 free app and 7 paid app in google playstore.i discover most of the free app in the playstore have ads in their app .frankly,all my 7 paid app have zero earnings.i think the crucial point would be admob.but i have difficulty implementing this plugin,in fact,i have zero encourter with npm plug in.would nsb team consider writing one sample with admob and bundle it in the appstudio ide.this would benefit all appstudio user in the new future to come.hopefully,my request would not be ignored .placing best hope,tst aka TsTan

Thanks for the suggestion! We will see if this is possible.

like tick beside basic,it can also be tick beside admin,made it as easy as possible in the ide,let the slogan of nsbasic Spirit joins in.cheers!

It’s quite easy to implement ads, after setting up your adds in How to Sign Up & Get Started - Google Admob

Config:
Note: Only use one at at time i.e. if building for Android comment out the iOS plugin.

<plugin name="cordova-plugin-consent" source="npm" />
<!-- Android admob -->
<plugin name="admob-plus-cordova" ><variable name="APP_ID_ANDROID" value="your_addmob_pub_id"/></plugin>

<!-- iOS admob -->
<plugin name="admob-plus-cordova" ><variable name="APP_ID_IOS" value="your_addmob_pub_id"/></plugin>

Then in your code file: (if your code file is set to javascript you then remove the “JavaScript” and “End JavaScript” tags.

Dim interstitial
Dim banner
JavaScript 
document.addEventListener('deviceready', async () => {
  console.log('ready')
  
  await admob.start()
  
  if ( (navigator.userAgent.match(/(ios|iPhone|iPod|iPad|Macintosh)/)) ) {
     console.log('iOS')
     const trackingAuthorizationStatus = await admob.requestTrackingAuthorization()
      /*
      trackingAuthorizationStatus:
      0 = notDetermined
      1 = restricted
      2 = denied
      3 = authorized
      */
     
     const consentStatus = await consent.getConsentStatus()
     /* consentStatus:  Unknown = 0, Required = 1, NotRequired = 2, Obtained = 3 */
     //alert('consent Status: ' +consentStatus)
     if (consentStatus === consent.ConsentStatus.Required) {
     await consent.requestInfoUpdate()
     }
     
     const formStatus = await consent.getFormStatus()
     /* formStatus: Unknown: 0, Available = 1, NotAvailable = 2 */
     //alert('form Status: ' +formStatus)
     if (formStatus === consent.FormStatus.Available) {
     const form = await consent.loadForm()
     form.show()
     }
     
     console.log('Banner Ad trackAuth: ' +trackingAuthorizationStatus)
     banner = new admob.BannerAd({
     adUnitId: 'your_admob_ad_unit_id', //<=iOS Banner Ad
     npa: trackingAuthorizationStatus,
     })
    
     console.log('Interst. Ad trackAuth: ' +trackingAuthorizationStatus)
     interstitial = new admob.InterstitialAd({
     adUnitId: 'your_admob_ad_unit_id', //<iOS Interstitial Ad
     npa: trackingAuthorizationStatus,
     })
   
  } else {
     console.log('Android')
     const trackingAuthorizationStatus = await admob.requestTrackingAuthorization()
      /*
      trackingAuthorizationStatus:
      0 = notDetermined
      1 = restricted
      2 = denied
      3 = authorized
      */
     
     const consentStatus = await consent.getConsentStatus()
     /* consentStatus:  Unknown = 0, Required = 1, NotRequired = 2, Obtained = 3 */
     console.log('consent Status: ' +consentStatus)
     if (consentStatus === consent.ConsentStatus.Required) {
     await consent.requestInfoUpdate()
     }
     
     const formStatus = await consent.getFormStatus()
     /* formStatus: Unknown: 0, Available = 1, NotAvailable = 2 */
     console.log('form Status: ' +formStatus)
     if (formStatus === consent.FormStatus.Available) {
     const form = await consent.loadForm()
     form.show()
     }
     
     console.log('Banner Ad trackAuth: ' +trackingAuthorizationStatus)
     banner = new admob.BannerAd({
     adUnitId: 'your_admob_ad_unit_id', //<=Android Banner Ad
     npa: trackingAuthorizationStatus,
     })
     
     console.log('Interst. Ad trackAuth: ' +trackingAuthorizationStatus)
     interstitial = new admob.InterstitialAd({
     adUnitId: 'your_admob_ad_unit_id', //<=Android Interstitial Ad
     npa: trackingAuthorizationStatus,
     })
  }
  
  //'Show Ads
  banner.show()
  await interstitial.load()
  await interstitial.show()
  //myOtherFunction(); <- call your other functions here (if applicable).
  
}, false)

////////////////
document.addEventListener('admob.interstitial.dismiss', async () => {
  //' Once a interstitial ad is shown, it cannot be shown again.
  //' Start loading the next interstitial ad as soon as it is dismissed.
  console.log("Inter Ad Dismissed")
  await interstitial.load()
})
End JavaScript 

“your_addmob_pub_id” = Your admob “Publisher id” is obtained from admob website.
“your_admob_ad_unit_id” = Your admob “Add unit id” is obtained from admob website.

Once you have setup the adds in Admob website it can take a while for them to start showing. If using interstitial ads dont forget to set “Frequency capping” when you set up the add, otherwise the interstitial add will pop up again as soon as you dismiss it.

Thanks for the prompt reply,anyway,what is interstitial ad?

Answering my question,an advertisement that appears while a chosen website or page is download ing

interstitial ad is a full screen popup ad which could be a video and such like.

I have 11 device with issues. 1a)unable to get provider com. Google. Android. Admob. Mobileabloadprovider. 2b)the com. Google. Android. Gms. Ads. Application-ID_metadata must have a string value. (2)for admob account page, I don’t know how to get consent in private and messaging. (3)where is admob ad_unit_id? (4


)see attached file, what should I do with this page, I add ad_unit_id… Thanks in advance, TsTan