https://github.com/maximnara/cordova-plugin-mytarget-ads
MyTarget Ads for Ionic and Cordova apps
https://github.com/maximnara/cordova-plugin-mytarget-ads
Last synced: 4 days ago
JSON representation
MyTarget Ads for Ionic and Cordova apps
- Host: GitHub
- URL: https://github.com/maximnara/cordova-plugin-mytarget-ads
- Owner: maximnara
- License: mit
- Created: 2022-04-23T22:06:21.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2022-04-29T05:46:50.000Z (about 3 years ago)
- Last Synced: 2025-05-20T07:52:08.522Z (29 days ago)
- Language: Java
- Homepage:
- Size: 12.7 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# MyTarget Ads for Ionic and Cordova apps
### Interstitial and Rewarded ads are available now!
## [Demo video](https://drive.google.com/file/d/1FEbdX-voNsW_51o2mBjdP5z5ce_Zvbh4/view?usp=sharing)
--------
## Table of Contents
- [State of Development](#state-of-development)
- [Install](#install)
- [Usage](#usage)## State of Development
- [x]![]()
- [x]![]()
- [ ]--------
## Install
```bash
npm i cordova-plugin-mytarget-ads --save
```--------
## Usage- [Initialization](#initialization)
- [Rewarded Videos](#rewarded-videos)
- [Load Rewarded Video](#load-rewarded-video)
- [Show Rewarded Video](#show-rewarded-video)
- [Rewarded Video Events](#rewarded-video-events)
- [Interstitials](#interstitials)
- [Load Interstitial](#load-interstitial)
- [Show Interstitial](#show-interstitial)
- [Interstitial Events](#interstitial-events)
All methods support optional `onSuccess` and `onFailure` parameters### Initialization
```javascript
import * as MyTargetAds from 'cordova-plugin-mytarget-ads/www/mytargetads';
await MyTargetAds.init({
rewardedBlockId: 'YOUR_REWARDER_BLOCK_ID',
interstitialBlockId: 'YOUR_INTERSTITIAL_ID',
});
```
### Set user consent for GDPR
```javascript
MyTargetAds.setUserConsent(true);
```
***
### Rewarded Videos#### Load Rewarded Video
```javascript
MyTargetAds.loadRewardedVideo({
onSuccess: function () {},
onFailure: function () {},
});
```#### Show Rewarded Video
```javascript
MyTargetAds.showRewardedVideo();
```#### Rewarded Video Events
**Rewarded Video Loaded**```javascript
window.addEventListener("rewardedVideoLoaded", function () {
MyTargetAds.showRewardedVideo();
});
```
**Rewarded Video Rewarded**
```javascript
window.addEventListener("rewardedVideoRewardReceived", function(){
// some logics
});
```
**Rewarded Video Started**
```javascript
window.addEventListener("rewardedVideoStarted", function(){});
```
**Rewarded Video Closed**
```javascript
window.addEventListener("rewardedVideoClosed", function(){});
```
**Rewarded Video Failed**
```javascript
window.addEventListener("rewardedVideoFailed", function(){});
```
***
### Interstitial#### Load Interstitial
_Must be called before `showInterstitial````javascript
MyTargetAds.loadInterstitial();
```
***
#### Show Interstitial```javascript
MyTargetAds.showInterstitial();
```
***
#### Interstitial Events**Interstitial Loaded**
```javascript
window.addEventListener("interstitialLoaded", function () {
MyTargetAds.showInterstitial();
});
```
**Interstitial Shown**
```javascript
window.addEventListener("interstitialShown", function(){});
```
**Interstitial Closed**
```javascript
window.addEventListener("interstitialClosed", function(){});
```
**Interstitial Failed To Load**
```javascript
window.addEventListener("interstitialFailedToLoad", function(){});
```### Feel free to make your PRs for code structure or new functions