【发布时间】:2016-03-21 10:27:34
【问题描述】:
我使用 Cocos2d-x 版本制作游戏。 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]);
}
}
}
这是RootViewController.mm 中的按钮“showRewardedVideo”处理程序:
#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->AdNetworkSupport->Chartboost->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 中定义设置,但我应该怎么做呢?我没有找到这方面的信息。
请告诉我,还需要做什么。任何帮助将不胜感激。
【问题讨论】:
-
你有没有让这个工作??
-
不,我建议客户避免使用 MoPub 中介并仅使用 Chartboost。 Chartboost 自己运行良好。
标签: ios ads mopub chartboost