12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- import { _decorator} from 'cc';
- import MsgHints from '../core/utils/MsgHints';
- import i18n from '../core/i18n/runtime-scripts/LanguageData';
- 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(() => {
- MsgHints.show(i18n('main.插屏广告加载成功'))
- }).catch(() => {
- MsgHints.show(i18n('main.插屏广告加载失败'))
- // 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(i18n('main.激励广告加载成功'))
- if (cb) cb(0);
- })
- .catch(() => {
- MsgHints.show(i18n('main.激励广告加载失败'))
- //上报信息
- // 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();
|