{"id":14971140,"url":"https://github.com/azerion/h5-ad-wrapper","last_synced_at":"2025-10-26T14:31:07.208Z","repository":{"id":35059547,"uuid":"163851686","full_name":"azerion/h5-ad-wrapper","owner":"azerion","description":"Advertisement provider wrapper, similar to @azerion/phaser-ads but not tied into Phaser :)","archived":false,"fork":false,"pushed_at":"2023-01-04T21:38:43.000Z","size":3711,"stargazers_count":17,"open_issues_count":20,"forks_count":6,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-10-30T05:07:30.250Z","etag":null,"topics":["advertisement","advertising","html5","phaser","phaser-ads","pixi-js","unity-tiny"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/azerion.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-01-02T14:32:23.000Z","updated_at":"2024-09-19T10:20:29.000Z","dependencies_parsed_at":"2023-01-15T12:57:38.405Z","dependency_job_id":null,"html_url":"https://github.com/azerion/h5-ad-wrapper","commit_stats":null,"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/azerion%2Fh5-ad-wrapper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/azerion%2Fh5-ad-wrapper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/azerion%2Fh5-ad-wrapper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/azerion%2Fh5-ad-wrapper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/azerion","download_url":"https://codeload.github.com/azerion/h5-ad-wrapper/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238347605,"owners_count":19456966,"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":["advertisement","advertising","html5","phaser","phaser-ads","pixi-js","unity-tiny"],"created_at":"2024-09-24T13:44:46.131Z","updated_at":"2025-10-26T14:31:06.655Z","avatar_url":"https://github.com/azerion.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![npm version](https://badge.fury.io/js/%40azerion%2Fh5-ad-wrapper.svg)](https://badge.fury.io/js/%40azerion%2Fh5-ad-wrapper) \n[![jsDelivr Hits](https://data.jsdelivr.com/v1/package/npm/@azerion/h5-ad-wrapper/badge)](https://www.jsdelivr.com/package/npm/@azerion/h5-ad-wrapper)\n\n# h5-ad-wrapper\nThis ad wrapper that allows you to leverage different ad providers whilst providing the same simple API.\nAlso allows you to easily integrate mobile ads (via [Cordova](https://cordova.apache.org)).\nKey features:\n - Ads for your mobile web experience\n - Pluggable ad providers\n   - Gamedistribution.com\n   - IMA3 SDK\n   - Cordova (support for AdMob/HeyZap/MoPub/Chartboost)\n   - HeyZap for Cordova\n   - Ironsource for Cordova\n - Integrates nicely into any HTML5 gaming framework\n - Fullscreen ad support\n - Rewarded ad support\n\nGetting Started\n---------------\nFirst you want to get a fresh copy of the plugin. You can get it from [this repo](https://github.com/azerion/h5-ad-wrapper/releases) or from [npm](https://npmjs.com/package/@azerion/h5-ad-wrapper).\n```\nnpm install @azerion/h5-ad-wrapper\n```\nNext up you'd want to add it to your list of js sources you load into your game:\n```html\n\u003cscript src=\"path/to/h5-ad-wrapper.umd.js\"\u003e\u003c/script\u003e\n```\nYou could also opt for using the (free) jsdelivr cdn: \n```html\n\u003cscript src=\"https://cdn.jsdelivr.net/npm/@azerion/h5-ad-wrapper@latest/build/h5-ad-wrapper.umd.js\"\u003e\u003c/script\u003e\n```\nAnd you are done!\n\nUsage\n-----\nCheck the API docs right [here](https://azerion.github.io/h5-ad-wrapper/)\n\nFirst thing you need to do after loading the plugin is attaching a provider to the adManager. h5-ad-wrapper comes pre-compiled with multiple providers for you to choose from.\n\nFor web you can use:\n - [Gamedistribution.com](https://gamedistribution.com)\n - [IMA SDK](https://developers.google.com/interactive-media-ads/docs/sdks/html5)\n\nIf you're building an app you should use one of these:\n - [Cocoon.io ads](https://cocoon.io)\n - Cordova HeyZap\n - Cordova Ironsource\n\n### Gamedistribution.com\nIf you already have an account on Gamedistribution.com you can skip this introduction if not, head on over to [gamedistribution.com](https://gamedistribution.com) and sign up for a free account.\nOnce you're signed up you can check out [this guide](https://gamedistribution.com/sdk) for settings up a game. This is important because this will supply you with a gameId, which you need to supply to the plugin.\nSo when you have your gameId you can start by registering the provider to the plugin:\n```javascript\n// Let's create a new provider, first argument should be the game, second should be the ad tag URL\nvar provider = new h5ads.GameDistribution(\n   '2d77cfd4b1e5487d998465c29de195b3'           // Your gameId\n);\nh5ads.adWrapper.setAdProvider(provider);\n```\nAfter this it's as easy as calling:\n```javascript\nh5ads.adWrapper.showAd();\n```\n\n### IMA SDK\nA provider can use any number of arguments configured in order to make it work, it all depends on the implementation that was made by the developer. For our IMA Provider you can create one like this:\n```javascript\n// Let's create a new provider, first argument should be the game, second should be the ad tag URL\nvar provider = new h5ads.Ima3(\n   'https://pubads.g.doubleclick.net/gampad/ads?sz=640x480\u0026iu=/124319096/external/single_ad_samples\u0026ciu_szs=300x250\u0026impl=s\u0026gdfp_req=1\u0026env=vp\u0026output=vast\u0026unviewed_position_start=1\u0026correlator'\n);\nh5ads.adWrapper.setAdProvider(provider);\n```\n\n### Cordova Ironsource\nThe ironsource interstitial ads need to be preloaded before showing. The preload process might take up to two second, so its best to always have an ad preloaded after boot.\n```javascript\nh5ads.adWrapper.preloadAd(h5ads.AdType.interstitial);\n```\nPlease note that only intersticial and rewarded ads are currently implemented for ironsource.\n\nNow all you need to do is request an ad, and add an event listener that is called when the ad is completed/skipped/finished/done playing.\n```javascript\nh5ads.adWrapper.once('onContentResumed', function() {\n    // This gets called when the ad is complete\n    game.state.start('NextState');\n});\n// Here we request the ad\nh5ads.adWrapper.showAd();\n```\nYou can also send custom parameters by adding them as an object to the showAd function.\n\nF.A.Q.\n------\n### I Don't see any ads!\nThis can happen, sometimes the provider does something wrong, but most of the time (and when you are testing locally) your ads get blocked from showing.\nThat's right, ads don't show when testing locally. The easiest way to avoid this is by testing your game on a server (online).\nAnother work around would be to adjust your [/etc/hosts](https://howtogeek.com/howto/27350/beginner-geek-how-to-edit-your-hosts-file).\n\n### Why don't you support this ad provider!\nThe setup allows for a multitude of ad providers to work, but sadly we don't have the time and resources to add all of them.\nThat beeing said, this plugin is on GitHub, and you're welcome to shoot in a [PR](https://github.com/azerion/h5-ad-wrapper/compare) to add a new provider =)\n\nCredits\n=======\nCreated with https://github.com/alexjoverm/typescript-library-starter.git \n\nDisclaimer\n----------\nWe at Azerion just love playing and creating awesome games. We aren't affiliated with Phaser.io. We just needed some awesome ads in our awesome HTML5 games. Feel free to use it for enhancing your own awesome games!\nPhaser Ads is distributed under the MIT license. All 3rd party libraries and components are distributed under their\nrespective license terms.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fazerion%2Fh5-ad-wrapper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fazerion%2Fh5-ad-wrapper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fazerion%2Fh5-ad-wrapper/lists"}