Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(admob-plus): Add admob-plus (#2753)
- Loading branch information
1 parent
a167bd8
commit 6c99ec8
Showing
1 changed file
with
93 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { Cordova, IonicNativePlugin, Plugin } from '@ionic-native/core'; | ||
import { Observable } from 'rxjs/Observable'; | ||
import { fromEvent } from 'rxjs/observable/fromEvent'; | ||
|
||
export type AdUnitIDOption = string | { | ||
android: string; | ||
ios: string; | ||
}; | ||
|
||
/** | ||
* @name AdMob Free | ||
* @description | ||
* AdMob Plus is the successor of cordova-plugin-admob-free, which provides a cleaner API and build with modern tools. | ||
*/ | ||
@Plugin({ | ||
plugin: 'cordova-admob-plus', | ||
pluginName: 'AdMob', | ||
pluginRef: 'admob.banner', | ||
}) | ||
export class Banner { | ||
@Cordova({ otherPromise: true }) | ||
hide(): Promise<any> { | ||
return Promise.resolve(); | ||
} | ||
|
||
@Cordova({ otherPromise: true }) | ||
show(opts: { id?: AdUnitIDOption }): Promise<any> { | ||
return Promise.resolve(); | ||
} | ||
} | ||
|
||
@Plugin({ | ||
plugin: 'cordova-admob-plus', | ||
pluginName: 'AdMob', | ||
pluginRef: 'admob.interstitial', | ||
}) | ||
export class Interstitial { | ||
@Cordova({ otherPromise: true }) | ||
load(opts: { id?: AdUnitIDOption }): Promise<any> { | ||
return Promise.resolve(); | ||
} | ||
|
||
@Cordova({ otherPromise: true }) | ||
show(): Promise<any> { | ||
return Promise.resolve(); | ||
} | ||
} | ||
|
||
@Plugin({ | ||
plugin: 'cordova-admob-plus', | ||
pluginName: 'AdMob', | ||
pluginRef: 'admob.rewardVideo', | ||
}) | ||
export class RewardVideo { | ||
@Cordova({ otherPromise: true }) | ||
load(opts: { id?: AdUnitIDOption }): Promise<any> { | ||
return Promise.resolve(); | ||
} | ||
|
||
@Cordova({ otherPromise: true }) | ||
show(): Promise<any> { | ||
return Promise.resolve(); | ||
} | ||
} | ||
|
||
@Plugin({ | ||
platforms: ['Android', 'iOS'], | ||
plugin: 'cordova-admob-plus', | ||
pluginName: 'AdMob', | ||
pluginRef: 'admob', | ||
repo: 'https://github.com/admob-plus/admob-plus', | ||
}) | ||
@Injectable() | ||
export class AdMob extends IonicNativePlugin { | ||
banner = new Banner(); | ||
interstitial = new Interstitial(); | ||
rewardVideo = new RewardVideo(); | ||
|
||
@Cordova({ otherPromise: true }) | ||
setAppMuted(value: boolean): Promise<any> { | ||
return Promise.resolve(); | ||
} | ||
|
||
@Cordova({ otherPromise: true }) | ||
setAppVolume(value: number): Promise<any> { | ||
return Promise.resolve(); | ||
} | ||
|
||
on(event: string): Observable<any> { | ||
return fromEvent(document, event); | ||
} | ||
} |