{"id":19435408,"url":"https://github.com/cozycodegh/cordova-plugin-ads","last_synced_at":"2025-04-24T21:30:30.753Z","repository":{"id":65954737,"uuid":"603325657","full_name":"cozycodegh/cordova-plugin-ads","owner":"cozycodegh","description":"Cordova plugin for adding Google AdMob ads to an app","archived":false,"fork":false,"pushed_at":"2024-03-31T14:43:21.000Z","size":1240,"stargazers_count":1,"open_issues_count":1,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-10-05T02:17:13.716Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","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/cozycodegh.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,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2023-02-18T06:49:41.000Z","updated_at":"2024-04-13T16:45:20.000Z","dependencies_parsed_at":"2024-03-30T19:24:39.831Z","dependency_job_id":"8e67437a-8e2e-4f49-90ea-07eb2d8eb287","html_url":"https://github.com/cozycodegh/cordova-plugin-ads","commit_stats":{"total_commits":22,"total_committers":2,"mean_commits":11.0,"dds":0.2727272727272727,"last_synced_commit":"5c773b83cc243f4e3b06a24ded1ab63b2e026aa2"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cozycodegh%2Fcordova-plugin-ads","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cozycodegh%2Fcordova-plugin-ads/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cozycodegh%2Fcordova-plugin-ads/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cozycodegh%2Fcordova-plugin-ads/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cozycodegh","download_url":"https://codeload.github.com/cozycodegh/cordova-plugin-ads/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223736904,"owners_count":17194345,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2024-11-10T15:06:13.088Z","updated_at":"2024-11-10T15:06:13.643Z","avatar_url":"https://github.com/cozycodegh.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Cordova-Plugin-Ads\n\njump to: [PLUGIN USAGE](#plugin-usage) | [Cordova](#create-app) | [ADD ADS](#add-ads) | [More](#more-plugin) | [cozycode.ca](#more-cozycode) | [Open Source License](#license) \n\u003chr/\u003e\n\nUpdated __2023__ for [Cordova](https://cordova.apache.org/) with tracking consent:\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"docs/trackingConsent.png\" alt=\"iOS request tracking consent\" width=\"300\" align=\"center\" /\u003e\n\u003c/p\u003e\n\nTo include ads without any tracking, see: [cordova-plugin-ads-donottrack](https://github.com/cozycodegh/cordova-plugin-ads-donottrack)\n\n***Cordova*** plugin to add ***ads*** (by Google AdMob) into an app. \u003cbr\u003e\nUse JavaScript to include ads in your app.\n\nIf you notice any issues, submit here: [github issues](https://github.com/cozycodegh/cordova-plugin-ads/issues)\u003cbr\u003e\n\nHave a good one!\n\n# PLUGIN USAGE\u003ca id=\"plugin-usage\"\u003e\u003c/a\u003e\u003cbr\u003e\n\nAdd these calls inside of your cordova JavaScript to show ads: \u003cbr\u003e\n\n\u003cins\u003ebanner ads\u003c/ins\u003e \u003cbr\u003e\n[`adMob.banner(bannerId,adMob.ad_sizes.RESIZE,adMob.ad_positions.TOP)`](docs/banner.md) \u003cbr\u003e\n[`adMob.removeBanner()`](docs/banner.md#remove-banner) \u003cbr\u003e\n\n\u003cins\u003efull screen ads \u003c/ins\u003e\u003cbr\u003e\n[`adMob.interstitial(interstitialId)`](docs/interstitial.md)  \u003cbr\u003e\n[`adMob.showInterstitial()`](docs/interstitial.md#show-interstitial)  \u003cbr\u003e\n\n\u003cins\u003erewarded video ads \u003c/ins\u003e\u003cbr\u003e\n[`adMob.rewarded(rewardedId)`](docs/rewarded.md)  \u003cbr\u003e\n[`adMob.showRewarded()`](docs/rewarded.md#show-rewarded)  \u003cbr\u003e\n\n\u003cins\u003erewarded full screen video ads\u003c/ins\u003e (new, and better supported than rewarded ads) \u003cbr\u003e\n[`adMob.rewardedInterstitial(rewardedInterstitialId)`](docs/rewardedInterstitial.md)  \u003cbr\u003e\n[`adMob.showRewardedInterstitial()`](docs/rewardedInterstitial.md#show-rewarded-interstitial)  \u003cbr\u003e\n\nThe plugin creates an `adMob` object that can request to load new ads. \u003cbr\u003e\nNote: to fund the development of the plugin, the plugin requests 2% of ads for the plugin developer. It seems there are a lot of Cordova ad plugins that request this lol, it can there even if not said. \u003cbr\u003e\n\n# CREATE AN APP WITH CORDOVA\u003ca id=\"create-app\"\u003e\u003c/a\u003e\u003cbr\u003e\n\nHow to create a Cordova app: \u003cbr\u003e\n```properties\nnpm install -g cordova\ncordova create directory_name com.your_name_or_company.your_app_name\n```\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"docs/cordova.png\" alt=\"cordova app\" width=\"300\" align=\"center\" /\u003e\n\u003c/p\u003e\n\nCordova is an open source project maintained by Apache that lets you make apps written in HTML, css, and JavaScript. You can create cross-platform apps to publish on the Google Play Store for Android, and the Appstore for iOS, MacOS, and Apple devices.\n\n# ADD ADS\u003ca id=\"add-ads\"\u003e\u003c/a\u003e\u003cbr\u003e\n\n1. Add the plugin\u003cbr\u003e\n```properties\ncordova plugin add cordova-plugin-ads\n```\n    \n2. Test that ads are working using test ads. Use the id `\"test\"` to load test ads from the plugin.\n```js\nvar test_ad_id = \"test\";\n\nasync function runAllOfTheAds(){\n    await adMob.banner(test_ad_id).then(function(){\n        alert(\"loaded banner ads\");\n    }).catch(function(err){\n        alert(\"unable to load ads: \"+JSON.stringify(err));\n    });\n    \n    await adMob.interstitial(test_ad_id).then(function(){\n        alert(\"loaded interstitial ads\");;\n        return adMob.showInterstitial();\n    }).then(function(){\n        alert(\"showed interstitial ads\");\n    }).catch(function(err){\n        alert(\"unable to load ads: \"+JSON.stringify(err));\n    });\n    \n    await adMob.rewarded(test_ad_id).then(function(){\n        console.log(\"loaded rewarded ads\");\n        return adMob.showRewarded();\n    }).then(function(reward){\n        alert(\"showed rewarded ads\"+JSON.stringify(reward));\n    }).catch(function(err){\n        alert(\"unable to load rewarded ads: \"+JSON.stringify(err));\n    });\n    \n    await adMob.rewardedInterstitial(test_ad_id).then(function(){\n        alert(\"loaded rewarded ads\");\n        return adMob.showRewardedInterstitial();\n    }).then(function(reward){\n        alert(\"showed rewarded ads\"+JSON.stringify(reward));\n    }).catch(function(err){\n        alert(\"unable to load rewarded ads: \"+JSON.stringify(err));\n    });\n\n}\n\nfunction onDeviceReady() {\n    runAllOfTheAds();\n}\n```\n\n3. In your Google AdMob account, create ad units for your apps - note that the ads may return LOAD_AD_ERRORS errors (especially iOS) until the app has been approved, or while during testing\n```js\nvar admob_ids = {\n    'android' : {\n        'banner': \"ca-app-pub-4029587076166791/6431168058\",\n        'interstitial': \"ca-app-pub-4029587076166791/1370413062\",\n        'rewarded': \"ca-app-pub-4029587076166791/9712771663\",\n        'rewardedInterstitial': \"ca-app-pub-4029587076166791/3530506691\"\n    }, 'ios' : {\n        'banner': \"ca-app-pub-4029587076166791/6694891931\",\n        'interstitial': \"ca-app-pub-4029587076166791/2436352227\",\n        'rewarded': \"ca-app-pub-4029587076166791/5286441495\",\n        'rewardedInterstitial': \"ca-app-pub-4029587076166791/2300620853\"\n    }\n};\n\nadMob.banner(admob_ids).then(function(){\n    console.log(\"loaded banner ad\");\n}).catch(function(err){\n    console.log(\"unable to load banner ad: \"+JSON.stringify(err));\n});\n    \nadMob.interstitial(admob_ids).then(function(){\n    console.log(\"loaded interstitial ads\");;\n    return adMob.showInterstitial();\n}).then(function(){\n    console.log(\"showed interstitial ads\");\n}).catch(function(err){\n    console.log(\"unable to load interstitial ads: \"+JSON.stringify(err));\n});\n\nadMob.rewarded(admob_ids).then(function(){\n    console.log(\"loaded rewarded ads\");\n    return adMob.showRewarded();\n}).then(function(reward){\n    console.log(\"showed rewarded ads\"+JSON.stringify(reward));\n}).catch(function(err){\n    console.log(\"unable to load rewarded ads: \"+JSON.stringify(err));\n});\n\nadMob.rewardedInterstitial(admob_ids).then(function(){\n    console.log(\"loaded rewarded ads\");\n    return adMob.showRewardedInterstitial();\n}).then(function(reward){\n    console.log(\"showed rewarded ads\"+JSON.stringify(reward));\n}).catch(function(err){\n    console.log(\"unable to load rewarded ads: \"+JSON.stringify(err));\n});\n```\n\n## More on the plugin: \u003ca id=\"more-plugin\"\u003e\u003c/a\u003e\u003cbr\u003e\n- wait for `deviceready` to fire before calling any functions \u003cbr\u003e\n- errors can be automatically retried after a timeout or ignored \u003cbr\u003e\n- `adMob` uses a promise-based API to load ads \u003cbr\u003e\n- since the API returns a promise, it is asynchronous... call it and continue with other actions, or await for it to finish from within an async function to wait for the call to finish \u003cbr\u003e\n\n# More from [cozycode.ca](https://cozycode.ca)\u003ca id=\"more-cozycode\"\u003e\u003c/a\u003e\u003cbr\u003e\n\n  * [make apps with JavaScript](https://cozycode.ca/post?pon=make-an-app-with-cordova)\n  * [how to make an in-app purchases with Cordova](https://cozycode.ca/post?pon=cordova-plugin-inapppurchases)\n  * [a testing app for in-app purchases](https://cozycode.ca/post?pon=cordova-plugin-inapppurchases-TEST-APP)\n  * [a demo app for in-app purchases](https://cozycode.ca/post?pon=cordova-plugin-inapppurchases-DEMO-APP)\n\n# Open Source License\u003ca id=\"license\"\u003e\u003c/a\u003e\u003cbr\u003e\n\nMIT Licensed (MIT)\n\nCopyright © 2023 [cozycode.ca](https://cozycode.ca)\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do  so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all  copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcozycodegh%2Fcordova-plugin-ads","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcozycodegh%2Fcordova-plugin-ads","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcozycodegh%2Fcordova-plugin-ads/lists"}