123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- import { native, sys } from "cc";
- class PlatformDefault{
- public initialize(): void {
- console.log('初始化默认广告框架');
- }
- 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 {
- console.log('显示toast ', param);
- }
- public shareAppMessage(param: { title?: string, imageUrl?: string, query?: string, imageUrlId?: string } = {}): void {
- console.log('分享 ', param);
- }
- public vibrateShort(param: any = {}): void {
- console.log('短震动 ', param);
- }
- public vibrateLong(param: any = {}): void {
- console.log('长震动 ', param);
- }
- public shareShowReward(handler: Function = null): void {
- console.log('直接执行分享回调');
- if (handler) handler();
- }
- public addDesk(handler: Function = null): void {
- console.log('添加到桌面回调');
- if (handler) handler();
- }
- public showRewardVideo(handler: Function = null): void {
- console.log('直接执行视频回调');
- if(sys.platform == sys.Platform.ANDROID){//安卓
- native.reflection.callStaticMethod("org/cocos2dx/javascript/AppActivity", "videoAd", "()V");
- //msgHints.show("移动客户端模拟视频点击成功!");
- if (handler) handler(true);
- //设置原生回调
- /*globalThis.videoCallback = function(status) {
- if (handler) handler(status);
- };*/
- }else if(sys.platform == sys.Platform.IOS){//苹果
- native.reflection.callStaticMethod("AppController", "videoAd",'');
- //msgHints.show("移动客户端模拟视频点击成功!");
- if (handler) handler(true);
- //设置原生回调
- /*globalThis.videoCallback = function(status) {
- if (handler) handler(status);
- };*/
- }else{
- //msgHints.show("非移动客户端模拟视频点击成功!");
- if (handler) handler(true);
- }
- }
- public showBannerAd(): void {
- console.log('显示banner广告');
- }
- public hideBannerAd(recreate: boolean = false): void {
- console.log('隐藏banner广告,刷新:', recreate);
- }
- public refreshBannerAd(): void {
- console.log('刷新banner广告');
- }
- public showInterstitialAd(): void {
- console.log('显示插屏广告');
- }
- public showCustomAd(): void {
- console.log('显示自定义广告');
- }
- public hideCustomAd(): void {
- console.log('隐藏自定义广告');
- }
- public showSigleCustomAd(): void {
- console.log('展示单个自定义广告');
- }
- public hideSigleCustomAd(): void {
- console.log('隐藏展示单个自定义广告');
- }
-
- public exitGame(): void {
- console.log('退出游戏');
- }
- private __createVideoAd(): void {
- console.log('创建视频广告');
- }
- private __createBannerAd(): void {
- console.log('创建banner广告');
- }
- private __createInterstitialAd(): void {
- console.log('创建插屏广告');
- }
-
- private __customAdExist(): void{
- console.log('格子广告是否存在');
- }
- /**
- * 是否支持添加桌面
- * @returns
- */
- public isSupportDesk(){
- return false;
- }
- }
- export default new PlatformDefault();
|