-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathAdKit.cpp
83 lines (66 loc) · 1.8 KB
/
AdKit.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
//
// AdKit.cpp
// Maw Kit
//
// Created by Lluís Ulzurrun de Asanza Sàez on 18/02/16.
//
//
#include "AdKit.hpp"
#include "_AdKit.hpp"
#include "cocos2d.h"
#include "Device.hpp"
#include "Features.hpp"
#include "KVDatabase.hpp"
#include "Range.hpp"
namespace MK {
namespace AdKit {
void init( std::string interstitialUnitID,
std::string bottomBannerUnitID,
BannerSize bottomBannerSize,
std::string topBannerUnitID,
BannerSize topBannerSize,
std::string videoRewardUnitID,
std::string adColonyAppID,
std::string adColonyZoneID,
std::string adColonyCustomID,
std::vector<std::string>
testingDevices )
{
if ( !enabled() ) return;
_init( interstitialUnitID, bottomBannerUnitID, bottomBannerSize,
topBannerUnitID, topBannerSize, videoRewardUnitID, adColonyAppID,
adColonyZoneID, adColonyCustomID, testingDevices );
}
void showInterstitial( std::string adUnitID )
{
if ( !enabled() ) return;
_showInterstitial( adUnitID );
}
void showTopBanner( std::string adUnitID )
{
if ( !enabled() ) return;
_showTopBanner( adUnitID );
}
void showBottomBanner( std::string adUnitID )
{
if ( !enabled() ) return;
_showBottomBanner( adUnitID );
}
void showVideoReward( std::string adUnitID, std::function<void( bool )> callback )
{
if ( !videoRewardsAvailable() ) {
callback( false );
return;
}
_showVideoReward( adUnitID, callback );
}
bool enabled()
{
if ( MK::Device::isOSX() ) return false; // Not enabled on OS X.
if ( !MK::Features::AdKit ) return false; // Not enabled if AdKit disabled.
// Not enabled if database tells so.
return MK::KVDatabase::getLongValueForKey( MK::KVDatabase::Key::ADS_DISABLED ) ==
MK::KVDatabase::Default::LONG;
}
}; // namespace AdKit
}; // namespace MK