![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
cordova-plugin-ads
Advanced tools
Cordova plugin to add ads into an app. Use javascript to request ads by AdMob.
jump to: PLUGIN USAGE | Cordova | ADD ADS | More | cozycode.ca | Open Source License
Updated 2023 for Cordova with tracking consent:
To include ads without any tracking, see: cordova-plugin-ads-donottrack
Cordova plugin to add ads (by Google AdMob) into an app.
Use JavaScript to include ads in your app.
If you notice any issues, submit here: github issues
Have a good one!
Add these calls inside of your cordova JavaScript to show ads:
banner ads
adMob.banner(bannerId,adMob.ad_sizes.RESIZE,adMob.ad_positions.TOP)
adMob.removeBanner()
full screen ads
adMob.interstitial(interstitialId)
adMob.showInterstitial()
rewarded video ads
adMob.rewarded(rewardedId)
adMob.showRewarded()
rewarded full screen video ads (new, and better supported than rewarded ads)
adMob.rewardedInterstitial(rewardedInterstitialId)
adMob.showRewardedInterstitial()
The plugin creates an adMob
object that can request to load new ads.
Note: 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.
How to create a Cordova app:
npm install -g cordova
cordova create directory_name com.your_name_or_company.your_app_name
Cordova 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.
cordova plugin add cordova-plugin-ads
"test"
to load test ads from the plugin.var test_ad_id = "test";
async function runAllOfTheAds(){
await adMob.banner(test_ad_id).then(function(){
alert("loaded banner ads");
}).catch(function(err){
alert("unable to load ads: "+JSON.stringify(err));
});
await adMob.interstitial(test_ad_id).then(function(){
alert("loaded interstitial ads");;
return adMob.showInterstitial();
}).then(function(){
alert("showed interstitial ads");
}).catch(function(err){
alert("unable to load ads: "+JSON.stringify(err));
});
await adMob.rewarded(test_ad_id).then(function(){
console.log("loaded rewarded ads");
return adMob.showRewarded();
}).then(function(reward){
alert("showed rewarded ads"+JSON.stringify(reward));
}).catch(function(err){
alert("unable to load rewarded ads: "+JSON.stringify(err));
});
await adMob.rewardedInterstitial(test_ad_id).then(function(){
alert("loaded rewarded ads");
return adMob.showRewardedInterstitial();
}).then(function(reward){
alert("showed rewarded ads"+JSON.stringify(reward));
}).catch(function(err){
alert("unable to load rewarded ads: "+JSON.stringify(err));
});
}
function onDeviceReady() {
runAllOfTheAds();
}
var admob_ids = {
'android' : {
'banner': "ca-app-pub-4029587076166791/6431168058",
'interstitial': "ca-app-pub-4029587076166791/1370413062",
'rewarded': "ca-app-pub-4029587076166791/9712771663",
'rewardedInterstitial': "ca-app-pub-4029587076166791/3530506691"
}, 'ios' : {
'banner': "ca-app-pub-4029587076166791/6694891931",
'interstitial': "ca-app-pub-4029587076166791/2436352227",
'rewarded': "ca-app-pub-4029587076166791/5286441495",
'rewardedInterstitial': "ca-app-pub-4029587076166791/2300620853"
}
};
adMob.banner(admob_ids).then(function(){
console.log("loaded banner ad");
}).catch(function(err){
console.log("unable to load banner ad: "+JSON.stringify(err));
});
adMob.interstitial(admob_ids).then(function(){
console.log("loaded interstitial ads");;
return adMob.showInterstitial();
}).then(function(){
console.log("showed interstitial ads");
}).catch(function(err){
console.log("unable to load interstitial ads: "+JSON.stringify(err));
});
adMob.rewarded(admob_ids).then(function(){
console.log("loaded rewarded ads");
return adMob.showRewarded();
}).then(function(reward){
console.log("showed rewarded ads"+JSON.stringify(reward));
}).catch(function(err){
console.log("unable to load rewarded ads: "+JSON.stringify(err));
});
adMob.rewardedInterstitial(admob_ids).then(function(){
console.log("loaded rewarded ads");
return adMob.showRewardedInterstitial();
}).then(function(reward){
console.log("showed rewarded ads"+JSON.stringify(reward));
}).catch(function(err){
console.log("unable to load rewarded ads: "+JSON.stringify(err));
});
deviceready
to fire before calling any functions adMob
uses a promise-based API to load ads MIT Licensed (MIT)
Copyright © 2023 cozycode.ca
Permission 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:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE 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.
FAQs
Cordova plugin to add ads into an app. Use javascript to request ads by AdMob.
The npm package cordova-plugin-ads receives a total of 4 weekly downloads. As such, cordova-plugin-ads popularity was classified as not popular.
We found that cordova-plugin-ads demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.