{"id":43687839,"url":"https://github.com/EddyVerbruggen/nativescript-admob","last_synced_at":"2026-02-16T13:01:51.714Z","repository":{"id":48828554,"uuid":"46064865","full_name":"EddyVerbruggen/nativescript-admob","owner":"EddyVerbruggen","description":"NativeScript plugin to earn some precious :moneybag::moneybag: with ads by Google AdMob","archived":false,"fork":false,"pushed_at":"2021-07-09T16:24:21.000Z","size":2518,"stargazers_count":68,"open_issues_count":31,"forks_count":26,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-10-06T07:21:41.228Z","etag":null,"topics":["admob","advertisement","banner","nativescript","nativescript-plugin"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/EddyVerbruggen.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-11-12T16:17:20.000Z","updated_at":"2024-12-09T14:24:43.000Z","dependencies_parsed_at":"2022-09-26T20:11:27.594Z","dependency_job_id":null,"html_url":"https://github.com/EddyVerbruggen/nativescript-admob","commit_stats":null,"previous_names":[],"tags_count":27,"template":false,"template_full_name":null,"purl":"pkg:github/EddyVerbruggen/nativescript-admob","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EddyVerbruggen%2Fnativescript-admob","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EddyVerbruggen%2Fnativescript-admob/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EddyVerbruggen%2Fnativescript-admob/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EddyVerbruggen%2Fnativescript-admob/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/EddyVerbruggen","download_url":"https://codeload.github.com/EddyVerbruggen/nativescript-admob/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EddyVerbruggen%2Fnativescript-admob/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29508735,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-16T09:05:14.864Z","status":"ssl_error","status_checked_at":"2026-02-16T08:55:59.364Z","response_time":115,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["admob","advertisement","banner","nativescript","nativescript-plugin"],"created_at":"2026-02-05T03:00:21.768Z","updated_at":"2026-02-16T13:01:51.708Z","avatar_url":"https://github.com/EddyVerbruggen.png","language":"JavaScript","funding_links":[],"categories":["Awesome {N} [![Awesome](https://cdn.rawgit.com/sindresorhus/awesome/d7305f38d29fed78fa85652e3a63e154dd8e8829/media/badge.svg)](https://github.com/sindresorhus/awesome)"],"sub_categories":["Table of Contents"],"readme":"# NativeScript AdMob plugin\n\n[![NPM version][npm-image]][npm-url]\n[![Downloads][downloads-image]][npm-url]\n[![Twitter Follow][twitter-image]][twitter-url]\n\n[npm-image]:http://img.shields.io/npm/v/nativescript-admob.svg\n[npm-url]:https://npmjs.org/package/nativescript-admob\n[downloads-image]:http://img.shields.io/npm/dm/nativescript-admob.svg\n[twitter-image]:https://img.shields.io/twitter/follow/eddyverbruggen.svg?style=social\u0026label=Follow%20me\n[twitter-url]:https://twitter.com/eddyverbruggen\n\n## Installation\nFrom the command prompt go to your app's root folder and execute:\n```\ntns plugin add nativescript-admob\n```\n\n### iOS\n\u003e ⚠️ ⚠️ ⚠️ Important! Since version **4.0.0** it's required you to do this - or your app will crash on start-up! ⚠️\n\nOpen your App_Resources/iOS/Info.plist file and add this (replace the value by the actual App ID of [your app](https://apps.admob.com/)!):\n\n```xml\n  \u003ckey\u003eGADApplicationIdentifier\u003c/key\u003e\n  \u003cstring\u003eca-app-pub-9517346003011652~2508636525\u003c/string\u003e\n```\n\nAlso, run `pod repo update` from a Terminal, otherwise the required Pod version may not be available on your system.\n\n### Android\n\u003e ⚠️ ⚠️ ⚠️ Important! Plugin version **3.0.0+** requires you to do this - or your app will crash on start-up! ⚠️\n\nOpen your App_Resources/Android/AndroidManifest.xml file and add this `meta-data` line at [the right spot](https://github.com/EddyVerbruggen/nativescript-admob/blob/6bfa83c303023d0e8072148dcb45b8befb9cd0aa/demo/app/App_Resources/Android/src/main/AndroidManifest.xml#L28) (and replace the value by the actual App ID of [your app](https://apps.admob.com/)!):\n\n```xml\n\u003capplication\u003e\n  \u003c!-- this line needs to be added (replace the value!) --\u003e\n  \u003cmeta-data android:name=\"com.google.android.gms.ads.APPLICATION_ID\" android:value=\"ca-app-pub-3940256099942544~3347511713\" /\u003e\n\n  \u003cactivity\u003e\u003c/activity\u003e\n\u003c/application\u003e\n```\n\n## BANNER\n\nIf you want a quickstart, [clone our demo app](https://github.com/EddyVerbruggen/nativescript-admob-demo).\n\nHere are the supported functions:\n\n### createBanner\n\n#### TypeScript\n\n```typescript\nimport { AD_SIZE, createBanner, hideBanner } from \"nativescript-admob\";\nimport { isIOS } from \"tns-core-modules/platform\";\n\nconst testing = true;\ncreateBanner({\n  // if this 'view' property is not set, the banner is overlayed on the current top most view\n  // view: ..,\n  size: AD_SIZE.SMART_BANNER,\n  iosBannerId: \"ca-app-pub-9517346003011652/3985369721\",\n  androidBannerId: testing\n      ? \"ca-app-pub-3940256099942544/6300978111\"  // global test banner id\n      : \"ca-app-pub-9517346003011652/7749101329\", // our registered banner id\n  // Android automatically adds the connected device as test device with testing:true, iOS does not\n  // iosTestDeviceIds: [\"yourTestDeviceUDIDs\", \"canBeAddedHere\"],\n  margins: {\n    // if both are set, top wins\n    // top: 10\n    bottom: isIOS ? 50 : 0\n  },\n  keywords: [\"foo\", \"bar\"]\n}).then(\n    () =\u003e this.message = \"Banner created\",\n    error =\u003e this.message = \"Error creating banner: \" + error\n)\n```\n\n#### JavaScript\n```js\nvar admob = require(\"nativescript-admob\");\n\nadmob.createBanner({\n    // if this 'view' property is not set, the banner is overlayed on the current top most view\n    // view: ..,\n    testing: true, // set to false to get real banners\n    size: size, // anything in admob.AD_SIZE, like admob.AD_SIZE.SMART_BANNER\n    iosBannerId: \"ca-app-pub-XXXXXX/YYYYYY\", // add your own\n    androidBannerId: \"ca-app-pub-AAAAAAAA/BBBBBBB\", // add your own\n    // Android automatically adds the connected device as test device with testing:true, iOS does not\n    iosTestDeviceIds: [\"yourTestDeviceUDIDs\", \"canBeAddedHere\"],\n    margins: {\n      // if both are set, top wins\n      //top: 10\n      bottom: 50\n    },\n    keywords: [\"keyword1\", \"keyword2\"] // add keywords for ad targeting\n  }).then(\n      function() {\n        console.log(\"admob createBanner done\");\n      },\n      function(error) {\n        console.log(\"admob createBanner error: \" + error);\n      }\n)\n```\n\nNote that you can trigger the function above at any moment, and since version 1.1.4\nof this plugin you can even call it [from the `Page.loaded` event](https://github.com/EddyVerbruggen/nativescript-admob-demo/blob/master/AdMob/app/main-page.js#L9).\n\n### hideBanner\nNOTE: If you want to show a different banner than the one showing you don't need to call `hideBanner`\nsince `createBanner` will do that for you to prevent your app from crashing.\n\n```js\n// the .then(.. bit is optional btw\nadmob.hideBanner().then(\n      function() {\n        console.log(\"admob hideBanner done\");\n      },\n      function(error) {\n        console.log(\"admob hideBanner error: \" + error);\n      }\n)\n```\n\n## INTERSTITIAL\nTo show a fullscreen ad, you can use this function. Note that Interstitial banners need to be loaded before\nthey can be shown, and there are two ways to do that:\n\n* Use `createInterstitial` and have the plugin automatically preload the ad and show it when loaded. This is not recommended because there's a delay the user may notice.\n* (Since plugin version 2.0.0) Use `preloadInterstitial`, and (at any time after its Promise resolves) `showInterstitial`. This will hide the preloading delay for your users. Note that the parameters of `createInterstitial` and `preloadInterstitial` are exactly the same so migration should be easy. \n\nIf you want to get notified when an interstitial is closed, provide an `onAdClosed` callback as shown below.\n\n### createInterstitial\nAgain, not recommended.\n\n```js\nadmob.createInterstitial({\n    testing: true,\n    iosInterstitialId: \"ca-app-pub-XXXXXX/YYYYY2\", // add your own\n    androidInterstitialId: \"ca-app-pub-AAAAAAAA/BBBBBB2\", // add your own\n    // Android automatically adds the connected device as test device with testing:true, iOS does not\n    iosTestDeviceIds: [\"ce97330130c9047ce0d4430d37d713b2\"],\n    keywords: [\"keyword1\", \"keyword2\"], // add keywords for ad targeting\n    onAdClosed: function () { console.log(\"interstitial closed\") }\n  }).then(\n      function() {\n        console.log(\"admob createInterstitial done\");\n      },\n      function(error) {\n        console.log(\"admob createInterstitial error: \" + error);\n      }\n)\n```\n\n### preloadInterstitial\nUse this for instance while loading your view, so it's ready for the moment you want to actually show it (by calling `showInterstitial`).\n\nNote that the parameters are identical to `createInterstitial`.\n\n```js\nadmob.preloadInterstitial({\n    testing: true,\n    iosInterstitialId: \"ca-app-pub-XXXXXX/YYYYY2\", // add your own\n    androidInterstitialId: \"ca-app-pub-AAAAAAAA/BBBBBB2\", // add your own\n    // Android automatically adds the connected device as test device with testing:true, iOS does not\n    iosTestDeviceIds: [\"ce97330130c9047ce0d4430d37d713b2\"],\n    keywords: [\"keyword1\", \"keyword2\"], // add keywords for ad targeting\n    onAdClosed: function () { console.log(\"interstitial closed\") }\n  }).then(\n      function() {\n        console.log(\"interstitial preloaded - you can now call 'showInterstitial' whenever you're ready to do so\");\n      },\n      function(error) {\n        console.log(\"admob preloadInterstitial error: \" + error);\n      }\n)\n```\n\n### showInterstitial\nAt any moment after `preloadInterstitial` successfully resolves, you can call `showInterstitial`.\n\nNote that when you want to use `showInterstitial` again, you also have to use `preloadInterstitial` again because those ads can't be reused. \n\n```js\nadmob.showInterstitial().then(\n      function() {\n        // this will resolve almost immediately, and the interstitial is shown without a delay because it was already loaded\n        console.log(\"interstitial showing\");\n      },\n      function(error) {\n        console.log(\"admob showInterstitial error: \" + error);\n      }\n)\n```\n\n\n### preloadRewardedVideoAd\nUse this for instance while loading your view, so it's ready for the moment you want to actually show it (by calling `showRewardedVideoAd`).\n\n```js\nadmob.preloadRewardedVideoAd({\n    testing: true,\n    iosAdPlacementId: \"ca-app-pub-XXXXXX/YYYYY2\", // add your own\n    androidAdPlacementId: \"ca-app-pub-AAAAAAAA/BBBBBB2\", // add your own\n    keywords: [\"keyword1\", \"keyword2\"], // add keywords for ad targeting\n  }).then(\n      function() {\n        console.log(\"RewardedVideoAd preloaded - you can now call 'showRewardedVideoAd' whenever you're ready to do so\");\n      },\n      function(error) {\n        console.log(\"admob preloadRewardedVideoAd error: \" + error);\n      }\n)\n```\n\n### showRewardedVideoAd\nAt any moment after `preloadRewardedVideoAd` successfully resolves, you can call `showRewardedVideoAd`.\n\nNote that when you want to use `showRewardedVideoAd` again, you also have to use `preloadRewardedVideoAd` again because those ads can't be reused.\n\nonRewarded is probably the only callback you need to worry about.\n\n```js\nadmob.showRewardedVideoAd({\n  onRewarded: (reward) =\u003e {\n    console.log(\"onRewarded\");\n    this.message = \"watched rewarded video\";\n  },\n  onRewardedVideoAdLeftApplication: () =\u003e console.log(\"onRewardedVideoAdLeftApplication\"),\n  onRewardedVideoAdClosed: () =\u003e console.log(\"onRewardedVideoAdClosed\"),\n  onRewardedVideoAdOpened: () =\u003e console.log(\"onRewardedVideoAdOpened\"),\n  onRewardedVideoStarted: () =\u003e console.log(\"onRewardedVideoStarted\"),\n  onRewardedVideoCompleted: () =\u003e console.log(\"onRewardedVideoCompleted\"),\n}).then(\n      function() {\n        console.log(\"RewardedVideoAd showing\");\n      },\n      function(error) {\n        console.log(\"admob showRewardedVideoAd error: \" + error);\n      }\n)\n```\n\n## Tutorials\nNeed a little more help getting started? Check out these tutorials for using Admob in a NativeScript Android and iOS application.\n\n* [Monetize with Google Admob in a NativeScript Vanilla Application](https://www.thepolyglotdeveloper.com/2016/03/monetize-with-google-admob-in-a-nativescript-mobile-app/)\n* [Monetize with Google Admob in a NativeScript Angular Application](https://www.thepolyglotdeveloper.com/2016/11/google-admob-nativescript-angular-2/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FEddyVerbruggen%2Fnativescript-admob","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FEddyVerbruggen%2Fnativescript-admob","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FEddyVerbruggen%2Fnativescript-admob/lists"}