# @azerion/cordova-ads

> Cordova plugin for Azerion Ads SDK

Latest version **2.0.0-rc.3** (published 2022-10-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install @azerion/cordova-ads
pnpm add @azerion/cordova-ads
yarn add @azerion/cordova-ads
bun add @azerion/cordova-ads
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.0-rc.3 |
| Published | 2022-10-10 |
| First published | 2022-05-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 113.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Azerion |
| Maintainers | torongo.azad, zakir.hossain |
| Keywords | ecosystem:cordova, cordova-android, cordova-ios |

## Links

- npm: https://www.npmjs.com/package/@azerion/cordova-ads
- Homepage: https://github.com/azerion/ad-sdk-cordova-plugin
- Issues: https://github.com/azerion/ad-sdk-cordova-plugin/issues
- npm.io page: https://npm.io/package/@azerion/cordova-ads

## Dependencies (3)

- [form-data](https://npm.io/package/form-data.md) ^4.0.0
- [eventemitter3](https://npm.io/package/eventemitter3.md) ^4.0.7
- [@types/es6-promise](https://npm.io/package/@types/es6-promise.md) ^3.3.0

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 2.0.0-rc.3 (latest) — 2022-10-10
- 2.0.0-rc.2 — 2022-10-07
- 2.0.0-rc.1 — 2022-10-04
- 1.0.0-alpha.0 — 2022-05-24

## README

# Integration

Execute the following command to integrate the plugin:

```
cordova plugin add @azerion/cordova-ads
```

# AdMob configuration
## Android
Add the AdMob `APPLICATION_ID` into `/platforms/android/app/src/AndroidManifest.xml`
```XML
    <application>
        ...
        <meta-data
            android:name="com.google.android.gms.ads.APPLICATION_ID"
            android:value="ca-app-pub-xxxxxxxxxxxxxxxx~yyyyyyyyyy" />
            ...
    </application>
```

## iOS
Update your app's `Info.plist` file to add a `GADApplicationIdentifier` key with a string value of your AdMob app ID.
```XML
<key>GADApplicationIdentifier</key>
	<string>ca-app-pub-XXXXXXXXXXXXXXXX~YYYYYYYYYY</string>
```
# Initialize Azerion Ads SDK
```JavaScript
// Initiate SDK initialization
// App should use its own machanism to get user consent to use personal data (such as AdID) to serve ads
// If isDebugModeEnabled is true then SDK will log network call operation
azerionAds.initialise(gdprConsentString, isCOPPACompliant, withUserConsent, isTestModeEnabled, isDebugModeEnabled);

// Recive the initialization status
azerionAds.on('InitializationCompleted', (initializationStatus) => {
    console.log(initializationStatus);
});
```
Sample `initializationStatus` response: 
```JavaScript
{
    // AdMob
    "com.google.android.gms.ads.MobileAds": {
        "description": "",
        "name": "com.google.android.gms.ads.MobileAds",
        "state": "READY"
    },
    "ImproveDigital": {
        "description": "",
        "name": "ImproveDigital",
        "state": "READY"
    }
}
```
---
**NOTE**
You can only request Ad after SDK successfully finished initialization. In production build `isTestModeEnabled` and `isDebugModeEnabled` should be `false`.
---
<br>

# Banner Ad

```JavaScript
// Request banner ad
azerionAds.requestBanner("azerionAdUnitId", AzerionAds.AdBannerPosition.BOTTOM, AzerionAds.AdBannerSize.BANNER);

// Show the banner and start refresh  timer
azerionAds.showBanner();

// Hide the banner and stop refresh timer
azerionAds.hideBanner();

// Listening Banner Events

azerionAds.on('BannerOnReceiveAd', () => {
});

azerionAds.on('BannerOnFailedToReceiveAd', (error) => {
});

azerionAds.on('BannerOnDisplay', () => {
});

azerionAds.on('BannerOnHide', () => {
});

azerionAds.on('BannerOnLeftApplication', () => {
});
```
<br>  

# Interstitial Ad
```JavaScript
// Request Interstitial Ad 
azerionAds.requestInterstitial("adUnitId");

// Listening Interstitial Ad Events
azerionAds.on('InterstitialOnAdLoaded', () => {
    azerionAds.showInterstitial();
});

azerionAds.on('InterstitialOnAdFailedToLoad', (error) => {
        // If you want to load another ad
    azerionAds.requestInterstitial("adUnitId");
});

azerionAds.on('InterstitialOnAdDisplayed', () => {
});

azerionAds.on('InterstitialOnAdFailedToDisplay', (error) => {
        // If you want to load another ad
    azerionAds.requestInterstitial("adUnitId");
});

azerionAds.on('InterstitialOnAdClosed', () => {
    // If you want to load another ad
    azerionAds.requestInterstitial("adUnitId");
});

azerionAds.on('InterstitialOnAdLeavingApplication', () => {
});
```
<br>

# Rewarded Ad
```JavaScript
azerionAds.requestRewardVideo("azerionAdUnitId");

// Listening Rewarded Ad Events
azerionAds.on('RewadedVideoOnAdLoaded', () => {
    azerionAds.showRewardVideo();
});

azerionAds.on('RewadedVideoOnAdFailedToLoad', (error) => {
    // If you want to load another ad
    azerionAds.requestRewardVideo("azerionAdUnitId");
});

azerionAds.on('RewadedVideoOnAdDisplayed', () => {
    
});

azerionAds.on('RewadedVideoOnAdFailedToDisplay', (error) => {
    // If you want to load another ad
    azerionAds.requestRewardVideo("azerionAdUnitId");
});

azerionAds.on('RewadedVideoOnAdClosed', () => {
    // If you want to load another ad
    azerionAds.requestRewardVideo("azerionAdUnitId");
});

azerionAds.on('RewadedVideoOnAdLeavingApplication', () => {
});

azerionAds.on('RewadedVideoOnUserRewardEarned', (rewardItem) => {
    console.log("rewarde amount: " + rewardItem.amount);
});
```


- Kotlin module issue
    ```config
    More than one file was found with OS independent path 'META-INF/annotation-experimental_release.kotlin_module'
    ```
    Please add the following config into `.../platforms/android/app/build.gradle`
    ```config
    android {
        ...
        packagingOptions {
            exclude("META-INF/*.kotlin_module")
        }
        ...
    }
    ```

- If you are using `firebase-analytics` please update it version to `21.0.0`

---
_Source: https://npm.io/package/@azerion/cordova-ads · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
