PlatformDefault.ts 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. import { native, sys } from "cc";
  2. class PlatformDefault{
  3. public initialize(): void {
  4. console.log('初始化默认广告框架');
  5. }
  6. public showToast(param: { title: string, icon?: 'success' | 'loading' | 'none', image?: string, duration?: number, mask?: boolean, success?: (res?: any) => void, fail?: (res?: any) => void, complete?: (res?: any) => void }): void {
  7. console.log('显示toast ', param);
  8. }
  9. public shareAppMessage(param: { title?: string, imageUrl?: string, query?: string, imageUrlId?: string } = {}): void {
  10. console.log('分享 ', param);
  11. }
  12. public vibrateShort(param: any = {}): void {
  13. console.log('短震动 ', param);
  14. }
  15. public vibrateLong(param: any = {}): void {
  16. console.log('长震动 ', param);
  17. }
  18. public shareShowReward(handler: Function = null): void {
  19. console.log('直接执行分享回调');
  20. if (handler) handler();
  21. }
  22. public addDesk(handler: Function = null): void {
  23. console.log('添加到桌面回调');
  24. if (handler) handler();
  25. }
  26. public showRewardVideo(handler: Function = null): void {
  27. console.log('直接执行视频回调');
  28. if(sys.platform == sys.Platform.ANDROID){//安卓
  29. native.reflection.callStaticMethod("org/cocos2dx/javascript/AppActivity", "videoAd", "()V");
  30. //msgHints.show("移动客户端模拟视频点击成功!");
  31. if (handler) handler(true);
  32. //设置原生回调
  33. /*globalThis.videoCallback = function(status) {
  34. if (handler) handler(status);
  35. };*/
  36. }else if(sys.platform == sys.Platform.IOS){//苹果
  37. native.reflection.callStaticMethod("AppController", "videoAd",'');
  38. //msgHints.show("移动客户端模拟视频点击成功!");
  39. if (handler) handler(true);
  40. //设置原生回调
  41. /*globalThis.videoCallback = function(status) {
  42. if (handler) handler(status);
  43. };*/
  44. }else{
  45. //msgHints.show("非移动客户端模拟视频点击成功!");
  46. if (handler) handler(true);
  47. }
  48. }
  49. public showBannerAd(): void {
  50. console.log('显示banner广告');
  51. }
  52. public hideBannerAd(recreate: boolean = false): void {
  53. console.log('隐藏banner广告,刷新:', recreate);
  54. }
  55. public refreshBannerAd(): void {
  56. console.log('刷新banner广告');
  57. }
  58. public showInterstitialAd(): void {
  59. console.log('显示插屏广告');
  60. }
  61. public showCustomAd(): void {
  62. console.log('显示自定义广告');
  63. }
  64. public hideCustomAd(): void {
  65. console.log('隐藏自定义广告');
  66. }
  67. public showSigleCustomAd(): void {
  68. console.log('展示单个自定义广告');
  69. }
  70. public hideSigleCustomAd(): void {
  71. console.log('隐藏展示单个自定义广告');
  72. }
  73. public exitGame(): void {
  74. console.log('退出游戏');
  75. }
  76. private __createVideoAd(): void {
  77. console.log('创建视频广告');
  78. }
  79. private __createBannerAd(): void {
  80. console.log('创建banner广告');
  81. }
  82. private __createInterstitialAd(): void {
  83. console.log('创建插屏广告');
  84. }
  85. private __customAdExist(): void{
  86. console.log('格子广告是否存在');
  87. }
  88. /**
  89. * 是否支持添加桌面
  90. * @returns
  91. */
  92. public isSupportDesk(){
  93. return false;
  94. }
  95. }
  96. export default new PlatformDefault();