I make the game using Cocos2d-x ver. 3.4. I make the rewarded video with MoPub mediation in this game. I followed this guide on official github wiki.
So, first I incorporated the MoPub iOS SDK and Chartboost SDK in the project.
I set in 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
in 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]);
}
}
}
This is buttons "showRewardedVideo" handler in 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];
}
}
I set in MoPubSDK->AdNetworkSupport->Chartboost->ChartboostRewardedVideoCustomEvent.m:
- (void)requestRewardedVideoWithCustomEventInfo:(NSDictionary *)info
{
NSString *appId = [info objectForKey:@"MyChartboostAppID"];
NSString *appSignature = [info objectForKey:@"MyChartboostAppSignature"];
…
}
But when I run the application, I get in
- (void)communicatorDidReceiveAdConfiguration:(MPAdConfiguration *)configuration
the _networkType propertie = @"clear"
and get a message
MOPUB: Rewarded video ad is fetching ad network type: clear
The video is not displayed, and I get my alert window from RootViewController.mm -(void)showRewardedVideo method.
Seems MoPub doesn't know about Chartboost. I think, I need define settings in initializeRewardedVideoWithGlobalMediationSettings:nil, but how I should make this? I didn't found info about this.
Please tell me, what else needs to be done. Any help will be appreciated.