如何将Chartboost奖励视频与iOS的MoPub中介集成

时间:2016-03-21 10:27:34

标签: ios ads mopub chartboost

我使用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中定义设置,但我应该如何制作呢?我没有找到关于此的信息。
请告诉我,还有什么需要做。任何帮助将不胜感激。

1 个答案:

答案 0 :(得分:0)

我认为您的问题在initializeRewardedVideoWithGlobalMediationSettings:nil

中的loadRewardedVideo中不使用任何参数:AppDelegate.mm

In your guide他们说明了

  

中介设置可让您传入第三方网络特定设置,并可在奖励视频初始化调用期间作为附加参数提供

所以很可能你需要这个论点是非零的。此外,如果您不希望MoPub单独选择网络,则withMediationSettings应为非空。他们说here

  

中介设置数组应包含可针对给定广告单元ID加载的网络的广告网络特定对象