123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- import { _decorator} from 'cc';
- import MsgHints from '../core/utils/MsgHints';
- const { ccclass, property } = _decorator;
- class PlatformBrowser {
- adInstance: any = null;
- gtag: any = null;
- openAd: boolean = true;
- public initialize(): void {
- this.adInstance = (window as any)['adInstance'];
- try {
- window["__woso"]?.["TopCallback"]?.();
- } catch (error) {
- }
- console.log('web ads sdk初始化');
- }
-
- /**显示插屏广告*/
- public showInterstitialAd(cb?:Function): void {
- /*if(!constants.isRelease){
- console.log('模拟显示插屏广告回调');
- cb?.();
- return
- }*/
- try {
- window['showAd']('interstitial').then(() => {
- console.log("rewarded11111")
- }).catch(() => {
- console.log("rewarded22222")
- // GtagMgr.inst.doGameDot(GtagType.ad_error);
- });
- } catch (error) {
- // tgxUITips.show('The ad failed to load')
- }
- }
- /** 显示激励广告*/
- public showRewardVideo(cb:Function): void {
- // if(!constants.isRelease){
- // console.log('模拟激励广告回调');
- // cb?.(0);
- // return
- // }
- try {
- window["showAd"]('rewarded')
- .then(() => {
- MsgHints.show('rewarded11111')
- if (cb) cb(0);
- })
- .catch(() => {
- MsgHints.show('The ad failed to load')
- //上报信息
- // GtagMgr.inst.doGameDot(GtagType.ad_error);
- // cb && cb();
- })
- return
- } catch (error) {
- }
- //tgxUITips.show('The ads failed to load');
- }
- /** 显示激励广告*/
- public hideBannerAd(): void {
- }
-
- public showBannerAd(): void {
- }
- public vibrateShort(): void {
- }
- }
- export default new PlatformBrowser();
|