我使用Cocos2d-x ver制作游戏。 3.4。我在这个游戏中使用MoPub中介制作奖励视频。我在官方的github wiki上关注了这个guide
所以,首先我在项目中加入了MoPub iOS SDK和Chartboost SDK
我设置了AppDelegate.h
:
#import <UIKit/UIKit.h>
#import "MoPub.h"
#import "MPRewardedVideo.h"
@interface AppDelegate : UIResponder <UIApplicationDelegate, MPRewardedVideoDelegate>
@property (strong, nonatomic) UIWindow *window;
@property (nonatomic, assign) NSInteger coinAmount;
@end
AppDelegate.mm
中的:
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
…
[self loadRewardedVideo];
return YES;
}
- (void)loadRewardedVideo {
[[MoPub sharedInstance] initializeRewardedVideoWithGlobalMediationSettings:nil delegate:self];
[MPRewardedVideo loadRewardedVideoAdWithAdUnitID:@“[MyAdUnitID]“ withMediationSettings:nil];
}
#pragma mark - MPRewardedVideoDelegate
- (void)rewardedVideoAdShouldRewardForAdUnitID:(NSString *)adUnitID reward:(MPRewardedVideoReward *)reward {
if ([reward.currencyType isEqualToString:@"coin"]) {
if ([reward.amount integerValue] == kMPRewardedVideoRewardCurrencyAmountUnspecified)
{
singleton->addToTotalCoins(10); // for test
} else
{
singleton->addToTotalCoins([reward.amount integerValue]);
}
}
}
这是按钮&#34; showRewardedVideo&#34; RootViewController.mm
中的处理程序:
#import "RootViewController.h"
@implementation RootViewController
- (void) showRewardedVideo
{
if ([MPRewardedVideo hasAdAvailableForAdUnitID:@"MyAdUnitID"])
{
[MPRewardedVideo presentRewardedVideoAdForAdUnitID:@"MyAdUnitID" fromViewController:self];
}
else
{
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Error"
message:@"Something went wrong"
delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alertView show];
}
}
我设置了MoPubSDK
- &gt; AdNetworkSupport
- &gt; Chartboost
- &gt; ChartboostRewardedVideoCustomEvent.m
:
- (void)requestRewardedVideoWithCustomEventInfo:(NSDictionary *)info
{
NSString *appId = [info objectForKey:@"MyChartboostAppID"];
NSString *appSignature = [info objectForKey:@"MyChartboostAppSignature"];
…
}
但是当我运行应用程序时,我进入了
- (void)communicatorDidReceiveAdConfiguration:(MPAdConfiguration *)configuration
_networkType
属性= @"clear"
并收到消息
MOPUB:奖励视频广告正在获取广告网络类型:清除
视频未显示,我从RootViewController.mm
-(void)showRewardedVideo
方法获取了提醒窗口。
似乎MoPub并不了解Chartboost。我想,我需要在initializeRewardedVideoWithGlobalMediationSettings:nil
中定义设置,但我应该如何制作呢?我没有找到关于此的信息。
请告诉我,还有什么需要做。任何帮助将不胜感激。
答案 0 :(得分:0)
我认为您的问题在initializeRewardedVideoWithGlobalMediationSettings:nil
loadRewardedVideo
中不使用任何参数:AppDelegate.mm
In your guide他们说明了
中介设置可让您传入第三方网络特定设置,并可在奖励视频初始化调用期间作为附加参数提供
所以很可能你需要这个论点是非零的。此外,如果您不希望MoPub单独选择网络,则withMediationSettings
应为非空。他们说here:
中介设置数组应包含可针对给定广告单元ID加载的网络的广告网络特定对象