platformBrowser.ts 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. import { _decorator} from 'cc';
  2. import MsgHints from '../core/utils/MsgHints';
  3. const { ccclass, property } = _decorator;
  4. class PlatformBrowser {
  5. adInstance: any = null;
  6. gtag: any = null;
  7. openAd: boolean = true;
  8. public initialize(): void {
  9. this.adInstance = (window as any)['adInstance'];
  10. try {
  11. window["__woso"]?.["TopCallback"]?.();
  12. } catch (error) {
  13. }
  14. console.log('web ads sdk初始化');
  15. }
  16. /**显示插屏广告*/
  17. public showInterstitialAd(cb?:Function): void {
  18. /*if(!constants.isRelease){
  19. console.log('模拟显示插屏广告回调');
  20. cb?.();
  21. return
  22. }*/
  23. try {
  24. window['showAd']('interstitial').then(() => {
  25. console.log("rewarded11111")
  26. }).catch(() => {
  27. console.log("rewarded22222")
  28. // GtagMgr.inst.doGameDot(GtagType.ad_error);
  29. });
  30. } catch (error) {
  31. // tgxUITips.show('The ad failed to load')
  32. }
  33. }
  34. /** 显示激励广告*/
  35. public showRewardVideo(cb:Function): void {
  36. // if(!constants.isRelease){
  37. // console.log('模拟激励广告回调');
  38. // cb?.(0);
  39. // return
  40. // }
  41. try {
  42. window["showAd"]('rewarded')
  43. .then(() => {
  44. MsgHints.show('rewarded11111')
  45. if (cb) cb(0);
  46. })
  47. .catch(() => {
  48. MsgHints.show('The ad failed to load')
  49. //上报信息
  50. // GtagMgr.inst.doGameDot(GtagType.ad_error);
  51. // cb && cb();
  52. })
  53. return
  54. } catch (error) {
  55. }
  56. //tgxUITips.show('The ads failed to load');
  57. }
  58. /** 显示激励广告*/
  59. public hideBannerAd(): void {
  60. }
  61. public showBannerAd(): void {
  62. }
  63. public vibrateShort(): void {
  64. }
  65. }
  66. export default new PlatformBrowser();