|
AddNewAdNetwork
How to add a new ad network
IntroductionThere are three ways to add a new ad network:
Full IntegrationThere are a few steps for full integration:
Implementation DetailsClient SideiPhoneYou can add a new ad network by modifying and adding files under the AdWhirl/adapters directory.
+ (AdWhirlAdNetworkType)networkType {
return AdWhirlAdNetworkTypeQuattro;
}
+ (void)load {
[[AdWhirlAdNetworkRegistry sharedRegistry] registerClass:self];
}
- (void)didReceiveAd:(AdMobView *)adView {
[adWhirlView adapter:self didReceiveAdView:adView];
}
- (void)didFailToReceiveAd:(AdMobView *)adView {
[adWhirlView adapter:self didFailAd:nil];
}
- (void)willPresentFullScreenModal {
[self helperNotifyDelegateOfFullScreenModal];
}
- (void)didDismissFullScreenModal {
[self helperNotifyDelegateOfFullScreenModalDismissal];
}AndroidYou can add a new ad network by modifying and adding files under the src/com/adwhirl/adapters directory.
adWhirlLayout.adWhirlManager.resetRollover(); adWhirlLayout.nextView = adView; adWhirlLayout.handler.post(adWhirlLayout.viewRunnable); adWhirlLayout.rotateThreadedDelayed(); On failure to receive an ad you'll want to do something similar to the following: adView.setAdListener(null); adWhirlLayout.rollover(); Server SideIn order to fully integrate a new ad network, you will need to modify both the website and mobile server code. In the website file "includes/inc_global_no_session.php", you will see a block of code containing ad networks. Simply add a new network to the end. Take care not to renumber any existing networks. $allNetworksGlobal = array(
array( 'ID' => 1,
'Name' => 'AdMob',
'Website' => 'http://www.admob.com',
'MobilePrefix' => 'admob_',
'Show' => true,
'IsServer' => false)
...
)
)If the network has multiple api keys, you will also need to add code to "main.php" in order to display the inputs correctly. else if($oneNetwork['ID'] == 3) { //VideoEgg
$keys = explode(KEY_SPLIT,$apikey);
if(count($keys) != 2) {
$keys = array();
$keys[0] = $keys[1] = '';
}
$apiText = '<tr><td width="100">PartnerID: </td><td><input name="apikey[]" type="text" class="text" value="'.$keys[0].'" maxlength="255"/></td></tr>
<tr><td width="100">SiteID: </td><td><input name="videoegg_key" type="text" class="text" value="'.$keys[1].'" maxlength="255"/></td></tr>';
}Next, you will need to edit the mobile server code utility file "src/util/AdWhirlUtil.java" to include an enumeration and network prefix for the new network. public static enum NETWORKS... public static String getNetworkPrefix(int type)... Finally, you will need to modify the configuration servlet "src/servlet/ConfigServlet.java" to handle multiple api keys (if neccessary). else if(ration.getType() == AdWhirlUtil.NETWORKS.QUATTRO.ordinal()) {
String[] temp = ration.getNetworkKey().split(AdWhirlUtil.KEY_SPLIT);
jsonWriter = jsonWriter.object()
.key("siteID")
.value(temp[0])
.key("publisherID")
.value(temp[1])
.endObject();
}
|