drgame-cc 1.0.21 → 1.0.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/drscript/Info.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import TvUi from "./core/TvUi";
|
|
2
|
+
import { AnalyticsAction, AnalyticsEvent } from "./GameAnalytics";
|
|
3
|
+
import { PlatformAdapter } from "./PlatformAdapter";
|
|
2
4
|
import ToastManager from "./toast/ToastManager";
|
|
3
5
|
|
|
4
6
|
|
|
@@ -42,6 +44,7 @@ export function showRewardVideo(scene: string, rewardType: string, callback: Fun
|
|
|
42
44
|
};
|
|
43
45
|
let onSuccess = () => {
|
|
44
46
|
try {
|
|
47
|
+
PlatformAdapter.report(AnalyticsEvent.RewardVideoAd, AnalyticsAction.Exposure);
|
|
45
48
|
callback && callback.call(target);
|
|
46
49
|
}
|
|
47
50
|
finally {
|
|
@@ -2,15 +2,14 @@ import TvUiConfigManager from "../config/TvUiConfigManager";
|
|
|
2
2
|
import NativeBridge from "../core/NativeBridge";
|
|
3
3
|
import { TvUiAdChannelConfig } from "../config/TvUiConfig";
|
|
4
4
|
import IAdProvider, { AdRuntimeData, AdShowResult } from "./IAdProvider";
|
|
5
|
-
import {
|
|
5
|
+
import { AdErrorCode, AdPlatform, AdSdk, AdType } from "../ad-sdk/ad-sdk";
|
|
6
6
|
|
|
7
7
|
export default class AggregateAdProvider implements IAdProvider {
|
|
8
8
|
public type: string = "aggregate";
|
|
9
|
-
|
|
9
|
+
private GAME_VERSION: string = "1.0.0";
|
|
10
10
|
private static initialized: boolean = false;
|
|
11
11
|
private static initTask: Promise<void> | null = null;
|
|
12
12
|
private static gameReadyNotified: boolean = false;
|
|
13
|
-
private static GAME_VERSION: string = "1.0.0";
|
|
14
13
|
|
|
15
14
|
public isAvailable(): boolean {
|
|
16
15
|
return NativeBridge.hasBridge();
|
|
@@ -21,27 +20,27 @@ export default class AggregateAdProvider implements IAdProvider {
|
|
|
21
20
|
}
|
|
22
21
|
|
|
23
22
|
public show(data: AdRuntimeData): Promise<AdShowResult> {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
// return this.showPopup(data);
|
|
23
|
+
let options = data.options || {};
|
|
24
|
+
let mode = options.mode || data.slotConfig.mode || "popup";
|
|
25
|
+
if (mode == "reward") {
|
|
26
|
+
return this.showReward(data);
|
|
27
|
+
}
|
|
28
|
+
return this.showPopup(data);
|
|
31
29
|
}
|
|
32
30
|
|
|
33
31
|
public hide(slotId: string, channel?: TvUiAdChannelConfig): void {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
32
|
+
if (!AggregateAdProvider.initialized || !this.isAvailable()) return;
|
|
33
|
+
let runtime = TvUiConfigManager.getConfig();
|
|
34
|
+
try {
|
|
35
|
+
// TODO: fix
|
|
36
|
+
// AdSdk.hidePopupAd({
|
|
37
|
+
// cpId: runtime.cpId || "ppl",
|
|
38
|
+
// triggerScene: slotId || "",
|
|
39
|
+
// placementId: (channel && channel.placementId) || ""
|
|
40
|
+
// });
|
|
41
|
+
} catch (error) {
|
|
42
|
+
console.warn("[AggregateAdProvider] hide popup failed", error);
|
|
43
|
+
}
|
|
45
44
|
}
|
|
46
45
|
|
|
47
46
|
private showReward(data: AdRuntimeData): Promise<AdShowResult> {
|
|
@@ -51,8 +50,8 @@ export default class AggregateAdProvider implements IAdProvider {
|
|
|
51
50
|
return AdSdk.requestAd({
|
|
52
51
|
adType: AdType.RewardVideo,
|
|
53
52
|
cpId: options.cpId || runtime.cpId || "ppl",
|
|
54
|
-
rewardType: options.
|
|
55
|
-
triggerScene: options.
|
|
53
|
+
rewardType: options.rewardType || "reward",
|
|
54
|
+
triggerScene: options.scene || data.slotId,
|
|
56
55
|
extra: options.extra || {}
|
|
57
56
|
}).then((result: any) => {
|
|
58
57
|
if (!result || result.isCompleted !== true) {
|
|
@@ -70,28 +69,30 @@ export default class AggregateAdProvider implements IAdProvider {
|
|
|
70
69
|
});
|
|
71
70
|
}
|
|
72
71
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
72
|
+
private showPopup(data: AdRuntimeData): Promise<AdShowResult> {
|
|
73
|
+
let options = data.options || {};
|
|
74
|
+
let channel = data.channel || <any>{};
|
|
75
|
+
let runtime = TvUiConfigManager.getConfig();
|
|
76
|
+
return Promise.reject(new Error("Popup ad not implemented"));
|
|
77
|
+
// TODO: fix
|
|
78
|
+
// return AdSdk.requestPopupAd({
|
|
79
|
+
// adType: AdType.Interstitial,
|
|
80
|
+
// cpId: options.cpId || runtime.cpId || "ppl",
|
|
81
|
+
// rewardType: options.rewardType || channel.rewardType || "popup",
|
|
82
|
+
// triggerScene: options.scene || data.slotId,
|
|
83
|
+
// placementId: channel.placementId || "",
|
|
84
|
+
// extra: options.extra || {}
|
|
85
|
+
// }).then((result: any) => {
|
|
86
|
+
// if (result && result.isClosed) {
|
|
87
|
+
// if (options.onClose) options.onClose(result);
|
|
88
|
+
// return <AdShowResult>{ status: "closed", data: result };
|
|
89
|
+
// }
|
|
90
|
+
// if (options.onLoad) options.onLoad(result);
|
|
91
|
+
// return <AdShowResult>{ status: "loaded", data: result };
|
|
92
|
+
// }).catch((error: any) => {
|
|
93
|
+
// return <AdShowResult>{ status: "failed", error: error };
|
|
94
|
+
// });
|
|
95
|
+
}
|
|
95
96
|
|
|
96
97
|
private ensureSdk(): Promise<void> {
|
|
97
98
|
if (AggregateAdProvider.initialized) return Promise.resolve();
|
|
@@ -114,7 +115,7 @@ export default class AggregateAdProvider implements IAdProvider {
|
|
|
114
115
|
adapters: adapters
|
|
115
116
|
}).then(() => {
|
|
116
117
|
AggregateAdProvider.initialized = true;
|
|
117
|
-
this.notifyGameReady(runtime.version ||
|
|
118
|
+
this.notifyGameReady(runtime.version || this.GAME_VERSION);
|
|
118
119
|
}).catch((error: any) => {
|
|
119
120
|
AggregateAdProvider.initTask = null;
|
|
120
121
|
throw error;
|
|
@@ -126,7 +127,7 @@ export default class AggregateAdProvider implements IAdProvider {
|
|
|
126
127
|
if (AggregateAdProvider.gameReadyNotified) return;
|
|
127
128
|
AggregateAdProvider.gameReadyNotified = true;
|
|
128
129
|
try {
|
|
129
|
-
AdSdk.onGameReady(version ||
|
|
130
|
+
AdSdk.onGameReady(version || this.GAME_VERSION);
|
|
130
131
|
} catch (error) {
|
|
131
132
|
console.warn("[AggregateAdProvider] onGameReady failed", error);
|
|
132
133
|
}
|