Skip to content

fix: 广告show报错添加 #989

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions Demo/API_V2/Assets/API/Ad/BannerAd/BannerAd.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using UnityEngine;
using WeChatWASM;

Expand Down Expand Up @@ -71,11 +72,21 @@ private void SwitchAdState()
else
{
// 展示广告
_bannerAd.Show();
WX.ShowToast(new ShowToastOption() { title = "已展示广告" });
_bannerAd.Show(ShowSuccess, ShowFail);
}
}

private Action<WXTextResponse> ShowSuccess = (res) =>
{
WX.ShowModal(new ShowModalOption() { content = "BannerAd Show Success:" + JsonUtility.ToJson(res) });
};


private Action<WXTextResponse> ShowFail = (res) =>
{
WX.ShowModal(new ShowModalOption() { content = "BannerAd Show Fail:" + JsonUtility.ToJson(res) });
};

// 销毁广告
private void DestroyAd()
{
Expand Down
15 changes: 13 additions & 2 deletions Demo/API_V2/Assets/API/Ad/CustomAd/CustomAd.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using UnityEngine;
using WeChatWASM;

Expand Down Expand Up @@ -72,11 +73,21 @@ private void SwitchAdState()
else
{
// 展示广告
_customAd.Show();
WX.ShowToast(new ShowToastOption() { title = "已展示广告" });
_customAd.Show(ShowSuccess, ShowFail);
}
}

private Action<WXTextResponse> ShowSuccess = (res) =>
{
WX.ShowModal(new ShowModalOption() { content = "CustomAd Show Success:" + JsonUtility.ToJson(res) });
};


private Action<WXTextResponse> ShowFail = (res) =>
{
WX.ShowModal(new ShowModalOption() { content = "CustomAd Show Fail:" + JsonUtility.ToJson(res) });
};

// 销毁广告
private void DestroyAd()
{
Expand Down
22 changes: 17 additions & 5 deletions Demo/API_V2/Assets/API/Ad/InterstitalAd/InterstitalAd.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using UnityEngine;
using WeChatWASM;

Expand Down Expand Up @@ -30,7 +31,7 @@ protected override void TestAPI(string[] args)
WX.ShowModal(
new ShowModalOption()
{
content = "RewardedVideoAd OnLoad Result:" + JsonUtility.ToJson(res)
content = "InterstitialAd OnLoad Result:" + JsonUtility.ToJson(res)
}
);
}
Expand All @@ -41,14 +42,14 @@ protected override void TestAPI(string[] args)
WX.ShowModal(
new ShowModalOption()
{
content = "RewardedVideoAd onError Result:" + JsonUtility.ToJson(res)
content = "InterstitialAd onError Result:" + JsonUtility.ToJson(res)
}
);
}
);
_interstitialAd.OnClose(() =>
{
WX.ShowModal(new ShowModalOption() { content = "RewardedVideoAd onClose" });
WX.ShowModal(new ShowModalOption() { content = "InterstitialAd onClose" });
});
// 预加载广告
_interstitialAd.Load();
Expand All @@ -59,10 +60,21 @@ protected override void TestAPI(string[] args)
// 展示广告
private void ShowAd()
{
_interstitialAd.Show();
WX.ShowToast(new ShowToastOption() { title = "已展示广告" });
_interstitialAd.Show(ShowSuccess, ShowFail);
}

private Action<WXTextResponse> ShowSuccess = (res) =>
{
WX.ShowModal(new ShowModalOption() { content = "InterstitialAd Show Success:" + JsonUtility.ToJson(res) });
};


private Action<WXTextResponse> ShowFail = (res) =>
{
WX.ShowModal(new ShowModalOption() { content = "InterstitialAd Show Fail:" + JsonUtility.ToJson(res) });
};


// 销毁广告
private void DestroyAd()
{
Expand Down
24 changes: 21 additions & 3 deletions Demo/API_V2/Assets/API/Ad/RewardedVideoAd/RewardedVideoAd.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using UnityEngine;
using WeChatWASM;

Expand Down Expand Up @@ -64,12 +65,29 @@ protected override void TestAPI(string[] args)
}

// 展示广告
private void ShowAd()
// private void ShowAd()
// {
// _rewardedVideoAd.Show();
// WX.ShowToast(new ShowToastOption() { title = "已展示广告" });
// }


private void ShowAd()
{
_rewardedVideoAd.Show();
WX.ShowToast(new ShowToastOption() { title = "已展示广告" });
_rewardedVideoAd.Show(ShowSuccess, ShowFail);
}

private Action<WXTextResponse> ShowSuccess = (res) =>
{
WX.ShowModal(new ShowModalOption() { content = "RewardedVideoAd Show Success:" + JsonUtility.ToJson(res) });
};


private Action<WXTextResponse> ShowFail = (res) =>
{
WX.ShowModal(new ShowModalOption() { content = "RewardedVideoAd Show Fail:" + JsonUtility.ToJson(res) });
};

// 销毁广告
private void DestroyAd()
{
Expand Down
Loading