Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(applovin): add plugin #4307

Merged
merged 2 commits into from
Oct 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions docs/plugins/applovin/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Applovin

```
$ ionic cordova plugin add cordova-plugin-applovin-max
$ npm install @awesome-cordova-plugins/applovin
```

## [Usage Documentation](https://danielsogl.gitbook.io/awesome-cordova-plugins/plugins/applovin/)

Plugin Repo: [https://github.com/AppLovin/AppLovin-MAX-Cordova](https://github.com/AppLovin/AppLovin-MAX-Cordova)

This plugin allows you to easily configure, integrate and interact with Applovin ads.

## Supported platforms

- Android
- iOS



340 changes: 340 additions & 0 deletions src/@awesome-cordova-plugins/plugins/applovin/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,340 @@
import { Injectable } from '@angular/core';
import { AwesomeCordovaNativePlugin, Cordova, Plugin } from '@awesome-cordova-plugins/core';
import { Observable } from 'rxjs';

export interface InitializeConfig {
hasUserConsentValue: boolean;
isAgeRestrictedUserValue: boolean;
isDoNotSellValue: boolean;
isTabletValue: boolean;
}

export interface AdInfo {
adUnitId: string;
creativeId: string;
networkName: string;
placement: string;
revenue: number;
}

export enum AdViewPosition {
TOP_CENTER = 'top_center',
TOP_RIGHT = 'top_right',
CENTERED = 'centered',
CENTER_LEFT = 'center_left',
CENTER_RIGHT = 'center_right',
BOTTOM_LEFT = 'bottom_left',
BOTTOM_CENTER = 'bottom_center',
BOTTOM_RIGHT = 'bottom_right',
}

export enum ConsentDialogState {
UNKNOWN = 0,
APPLIES = 1,
DOES_NOT_APPLY = 2,
}

/**
* @name Applovin
* @description
* This plugin allows you to easily configure, integrate and interact with Applovin ads.
* @usage
* ```typescript
* import { Applovin } from '@awesome-cordova-plugins/applovin';
*
*
* constructor(private applovin: Applovin) { }
*
*
* this.applovin.initialize(sdkKey)
* .then((res: any) => console.log(res))
* .catch((error: any) => console.error(error));
*
*
* this.applovin.loadInterstitial(adUnitId)
* .then((res: any) => console.log(res))
* .catch((error: any) => console.error(error));
*
*
* this.applovin.showInterstitial(adUnitId, placement)
* .then((res: any) => console.log(res))
* .catch((error: any) => console.error(error));
* ```
*/
@Plugin({
pluginName: 'Applovin',
plugin: 'cordova-plugin-applovin-max',
pluginRef: 'applovin',
repo: 'https://github.com/AppLovin/AppLovin-MAX-Cordova',
platforms: ['Android', 'iOS'],
})
@Injectable()
export class Applovin extends AwesomeCordovaNativePlugin {
/**
* Initialize the AppLovin SDK.
*
* @param {string} sdkKey The SDK key generated for your AppLovin account.
*/
@Cordova()
initialize(sdkKey: string): Promise<InitializeConfig> {
return;
}

@Cordova()
showMediationDebugger(): Promise<any> {
return;
}

@Cordova()
getConsentDialogState(): Promise<ConsentDialogState> {
return;
}

@Cordova()
setHasUserConsent(hasUserConsent: boolean): Promise<any> {
return;
}

@Cordova()
hasUserConsent(): Promise<boolean> {
return;
}

@Cordova()
setIsAgeRestrictedUser(isAgeRestrictedUser: boolean): Promise<any> {
return;
}

@Cordova()
isAgeRestrictedUser(): Promise<boolean> {
return;
}

@Cordova()
setDoNotSell(isDoNotSell: boolean): Promise<any> {
return;
}

@Cordova()
isDoNotSell(): Promise<boolean> {
return;
}

@Cordova()
isTablet(): Promise<boolean> {
return;
}

@Cordova()
setUserId(userId: string): Promise<any> {
return;
}

@Cordova()
setMuted(): Promise<boolean> {
return;
}

@Cordova()
setVerboseLogging(verboseLoggingEnabled: boolean): Promise<any> {
return;
}

@Cordova()
setTestDeviceAdvertisingIds(advertisingIds: string[]): Promise<any> {
return;
}

@Cordova()
trackEvent(event: string, parameters?: object): Promise<any> {
return;
}

/** BANNERS */

@Cordova()
createBanner(adUnitId: string, position: AdViewPosition): Promise<any> {
return;
}

@Cordova()
setBannerBackgroundColor(adUnitId: string, hexColorCode: string): Promise<any> {
return;
}

@Cordova()
setBannerPlacement(adUnitId: string, placement: string): Promise<any> {
return;
}

@Cordova()
setBannerExtraParameter(adUnitId: string, key: string, value: string): Promise<any> {
return;
}

@Cordova()
showBanner(adUnitId: string): Promise<any> {
return;
}

@Cordova()
hideBanner(adUnitId: string): Promise<any> {
return;
}

@Cordova()
destroyBanner(adUnitId: string): Promise<any> {
return;
}

/** MRECS */

@Cordova()
createMRec(adUnitId: string, position: AdViewPosition): Promise<any> {
return;
}

@Cordova()
setMRecBackgroundColor(adUnitId: string, hexColorCode: string): Promise<any> {
return;
}

@Cordova()
setMRecPlacement(adUnitId: string, placement: string): Promise<any> {
return;
}

@Cordova()
setMRecExtraParameter(adUnitId: string, key: string, value: string): Promise<any> {
return;
}

@Cordova()
showMRec(adUnitId: string): Promise<any> {
return;
}

@Cordova()
hideMRec(adUnitId: string): Promise<any> {
return;
}

@Cordova()
destroyMRec(adUnitId: string): Promise<any> {
return;
}

/** INTERSTITIALS */

@Cordova()
loadInterstitial(adUnitId: string): Promise<any> {
return;
}

@Cordova()
showInterstitial(adUnitId: string, placement?: string): Promise<any> {
return;
}

@Cordova()
setInterstitialExtraParameter(adUnitId: string, key: string, value: string): Promise<any> {
return;
}

@Cordova({
eventObservable: true,
event: 'OnInterstitialLoadedEvent',
})
onInterstitialLoaded(): Observable<AdInfo> {
return;
}

@Cordova({
eventObservable: true,
event: 'OnInterstitialLoadFailedEvent',
})
onInterstitialLoadFailed(): Observable<AdInfo> {
return;
}

@Cordova({
eventObservable: true,
event: 'OnInterstitialDisplayedEvent',
})
onInterstitialDisplayed(): Observable<AdInfo> {
return;
}

@Cordova({
eventObservable: true,
event: 'OnInterstitialHiddenEvent',
})
onInterstitialHidden(): Observable<AdInfo> {
return;
}

@Cordova({
eventObservable: true,
event: 'OnInterstitialAdFailedToDisplayEvent',
})
onInterstitialAdFailedToDisplay(): Observable<AdInfo> {
return;
}

/** REWARDED ADS */

@Cordova()
loadRewardedAd(adUnitId: string): Promise<any> {
return;
}

@Cordova()
showRewardedAd(adUnitId: string, placement?: string): Promise<any> {
return;
}

@Cordova()
setRewardedAdExtraParameter(adUnitId: string, key: string, value: string): Promise<any> {
return;
}

@Cordova({
eventObservable: true,
event: 'OnRewardedAdLoadedEvent',
})
onRewardedAdLoaded(): Observable<AdInfo> {
return;
}

@Cordova({
eventObservable: true,
event: 'OnRewardedAdLoadFailedEvent',
})
onRewardedAdLoadFailed(): Observable<AdInfo> {
return;
}

@Cordova({
eventObservable: true,
event: 'OnRewardedAdDisplayedEvent',
})
onRewardedAdDisplayed(): Observable<AdInfo> {
return;
}

@Cordova({
eventObservable: true,
event: 'OnRewardedAdHiddenEvent',
})
onRewardedAdHidden(): Observable<AdInfo> {
return;
}

@Cordova({
eventObservable: true,
event: 'OnRewardedAdAdFailedToDisplayEvent',
})
onRewardedAdAdFailedToDisplay(): Observable<AdInfo> {
return;
}
}