Skip to content

Commit

Permalink
1.14.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
MoJRen committed Sep 12, 2013
1 parent 8e8bfee commit 6cefa6b
Show file tree
Hide file tree
Showing 52 changed files with 752 additions and 289 deletions.
7 changes: 4 additions & 3 deletions AdNetworkSupport/InMobi/InMobiBannerCustomEvent.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
//

#import "MPBannerCustomEvent.h"
#import "IMAdView.h"
#import "IMBanner.h"
#import "IMInMobiNetworkExtras.h"

/*
* Compatible with version 3.7.0 of the InMobi SDK.
* Compatible with version 4.0.0 of the InMobi SDK.
*/

@interface InMobiBannerCustomEvent : MPBannerCustomEvent <IMAdDelegate>
@interface InMobiBannerCustomEvent : MPBannerCustomEvent <IMBannerDelegate>

@end
89 changes: 49 additions & 40 deletions AdNetworkSupport/InMobi/InMobiBannerCustomEvent.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,15 @@

@interface MPInstanceProvider (InMobiBanners)

- (IMAdView *)buildIMAdViewWithFrame:(CGRect)frame appId:(NSString *)appId adSize:(int)adSize;
- (IMAdRequest *)buildIMAdBannerRequest;
- (IMBanner *)buildIMBannerWithFrame:(CGRect)frame appId:(NSString *)appId adSize:(int)adSize;

@end

@implementation MPInstanceProvider (InMobiBanners)

- (IMAdView *)buildIMAdViewWithFrame:(CGRect)frame appId:(NSString *)appId adSize:(int)adSize
- (IMBanner *)buildIMBannerWithFrame:(CGRect)frame appId:(NSString *)appId adSize:(int)adSize
{
return [[[IMAdView alloc] initWithFrame:frame
imAppId:appId
imAdSize:adSize] autorelease];
}

- (IMAdRequest *)buildIMAdBannerRequest
{
return [IMAdRequest request];
return [[[IMBanner alloc] initWithFrame:frame appId:appId adSize:adSize] autorelease];
}

@end
Expand All @@ -40,7 +32,7 @@ - (IMAdRequest *)buildIMAdBannerRequest

@interface InMobiBannerCustomEvent ()

@property (nonatomic, retain) IMAdView *inMobiAdView;
@property (nonatomic, retain) IMBanner *inMobiBanner;

- (int)imAdSizeConstantForCGSize:(CGSize)size;

Expand All @@ -53,27 +45,30 @@ @implementation InMobiBannerCustomEvent
- (void)requestAdWithSize:(CGSize)size customEventInfo:(NSDictionary *)info
{
MPLogInfo(@"Requesting InMobi banner");

int imAdSizeConstant = [self imAdSizeConstantForCGSize:size];
if (imAdSizeConstant == INVALID_INMOBI_AD_SIZE) {
MPLogInfo(@"Failed to create an inMobi Banner with invalid size %@", NSStringFromCGSize(size));
[self.delegate bannerCustomEvent:self didFailToLoadAdWithError:nil];
return;
}
self.inMobiAdView = [[MPInstanceProvider sharedProvider] buildIMAdViewWithFrame:CGRectMake(0, 0, size.width, size.height)
appId:kInMobiAppID
adSize:imAdSizeConstant];
self.inMobiAdView.delegate = self;
self.inMobiAdView.refreshInterval = REFRESH_INTERVAL_OFF;

IMAdRequest *request = [[MPInstanceProvider sharedProvider] buildIMAdBannerRequest];
request.paramsDictionary = [NSDictionary dictionaryWithObject:@"c_mopub" forKey:@"tp"];

self.inMobiBanner = [[MPInstanceProvider sharedProvider] buildIMBannerWithFrame:CGRectMake(0, 0, size.width, size.height) appId:kInMobiAppID adSize:imAdSizeConstant];
self.inMobiBanner.delegate = self;
self.inMobiBanner.refreshInterval = REFRESH_INTERVAL_OFF;
IMInMobiNetworkExtras *inmobiExtras = [[IMInMobiNetworkExtras alloc] init];
NSMutableDictionary *paramsDict = [[NSMutableDictionary alloc] init];
[paramsDict setObject:@"c_mopub" forKey:@"tp"];
[paramsDict setObject:MP_SDK_VERSION forKey:@"tp-ver"];
inmobiExtras.additionaParameters = paramsDict; // For supply source identification

if (self.delegate.location) {
[request setLocationWithLatitude:self.delegate.location.coordinate.latitude
[InMobi setLocationWithLatitude:self.delegate.location.coordinate.latitude
longitude:self.delegate.location.coordinate.longitude
accuracy:self.delegate.location.horizontalAccuracy];
}
[self.inMobiAdView loadIMAdRequest:request];
[self.inMobiBanner addAdNetworkExtras:inmobiExtras];
[self.inMobiBanner loadBanner];

}

- (int)imAdSizeConstantForCGSize:(CGSize)size
Expand All @@ -89,43 +84,57 @@ - (int)imAdSizeConstantForCGSize:(CGSize)size
}
}

- (BOOL)enableAutomaticImpressionAndClickTracking
{
// Override this method to return NO to perform impression and click tracking manually.

return NO;
}

- (void)dealloc
{
[self.inMobiAdView setDelegate:nil];
self.inMobiAdView = nil;
[self.inMobiBanner setDelegate:nil];
self.inMobiBanner = nil;
[super dealloc];
}

#pragma mark - IMAdDelegate

- (void)adViewDidFinishRequest:(IMAdView *)adView
{
#pragma mark InMobiAdDelegate methods

- (void)bannerDidReceiveAd:(IMBanner *)banner {
MPLogInfo(@"InMobi banner did load");
[self.delegate bannerCustomEvent:self didLoadAd:adView];
[self.delegate trackImpression];
[self.delegate bannerCustomEvent:self didLoadAd:banner];
}

- (void)adView:(IMAdView *)view didFailRequestWithError:(IMAdError *)error
{
- (void)banner:(IMBanner *)banner didFailToReceiveAdWithError:(IMError *)error {
MPLogInfo(@"InMobi banner did fail with error: %@", error.localizedDescription);
[self.delegate bannerCustomEvent:self didFailToLoadAdWithError:error];
}

- (void)adViewWillPresentScreen:(IMAdView *)adView
{
MPLogInfo(@"InMobi banner will present modal");
[self.delegate bannerCustomEventWillBeginAction:self];
- (void)bannerDidDismissScreen:(IMBanner *)banner {
MPLogInfo(@"adViewDidDismissScreen");
[self.delegate bannerCustomEventDidFinishAction:self];
}

- (void)adViewDidDismissScreen:(IMAdView *)adView
{
MPLogInfo(@"InMobi banner did dismiss modal");
[self.delegate bannerCustomEventDidFinishAction:self];
- (void)bannerWillDismissScreen:(IMBanner *)banner {
MPLogInfo(@"adViewWillDismissScreen");
}

- (void)adViewWillLeaveApplication:(IMAdView *)adView
{
- (void)bannerWillPresentScreen:(IMBanner *)banner {
MPLogInfo(@"InMobi banner will present modal");
[self.delegate bannerCustomEventWillBeginAction:self];
}

- (void)bannerWillLeaveApplication:(IMBanner *)banner {
MPLogInfo(@"InMobi banner will leave application");
[self.delegate bannerCustomEventWillLeaveApplication:self];
}

- (void)bannerDidInteract:(IMBanner *)banner withParams:(NSDictionary *)dictionary {
MPLogInfo(@"InMobi banner was clicked");
[self.delegate trackClick];
}

@end
9 changes: 5 additions & 4 deletions AdNetworkSupport/InMobi/InMobiInterstitialCustomEvent.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@

#import "MPInterstitialCustomEvent.h"

#import "IMAdInterstitial.h"
#import "IMAdInterstitialDelegate.h"
#import "IMInterstitial.h"
#import "IMInterstitialDelegate.h"
#import "IMInMobiNetworkExtras.h"

/*
* Compatible with version 3.7.0 of the InMobi SDK.
* Compatible with version 4.0.0 of the InMobi SDK.
*/

@interface InMobiInterstitialCustomEvent : MPInterstitialCustomEvent <IMAdInterstitialDelegate>
@interface InMobiInterstitialCustomEvent : MPInterstitialCustomEvent <IMInterstitialDelegate>

@end
70 changes: 30 additions & 40 deletions AdNetworkSupport/InMobi/InMobiInterstitialCustomEvent.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,38 +9,30 @@
#import "MPInstanceProvider.h"
#import "MPLogging.h"

#define kInMobiAppID @"YOUR_INMOBI_APP_ID"

@interface MPInstanceProvider (InMobiInterstitials)

- (IMAdInterstitial *)buildIMAdInterstitialWithDelegate:(id<IMAdInterstitialDelegate>)delegate appId:(NSString *)appId;
- (IMAdRequest *)buildIMAdInterstitialRequest;
- (IMInterstitial *)buildIMInterstitialWithDelegate:(id<IMInterstitialDelegate>)delegate appId:(NSString *)appId;

@end

@implementation MPInstanceProvider (InMobiInterstitials)

- (IMAdInterstitial *)buildIMAdInterstitialWithDelegate:(id<IMAdInterstitialDelegate>)delegate appId:(NSString *)appId;
{
IMAdInterstitial *inMobiInterstitial = [[[IMAdInterstitial alloc] init] autorelease];
- (IMInterstitial *)buildIMInterstitialWithDelegate:(id<IMInterstitialDelegate>)delegate appId:(NSString *)appId {
IMInterstitial *inMobiInterstitial = [[[IMInterstitial alloc] initWithAppId:appId] autorelease];
inMobiInterstitial.delegate = delegate;
inMobiInterstitial.imAppId = appId;
return inMobiInterstitial;
}

- (IMAdRequest *)buildIMAdInterstitialRequest
{
return [IMAdRequest request];
}

@end

////////////////////////////////////////////////////////////////////////////////////////////////////


#define kInMobiAppID @"YOUR_INMOBI_APP_ID"

@interface InMobiInterstitialCustomEvent ()

@property (nonatomic, retain) IMAdInterstitial *inMobiInterstitial;
@property (nonatomic, retain) IMInterstitial *inMobiInterstitial;

@end

Expand All @@ -53,18 +45,19 @@ @implementation InMobiInterstitialCustomEvent
- (void)requestInterstitialWithCustomEventInfo:(NSDictionary *)info
{
MPLogInfo(@"Requesting InMobi interstitial");

self.inMobiInterstitial = [[MPInstanceProvider sharedProvider] buildIMAdInterstitialWithDelegate:self
appId:kInMobiAppID];

IMAdRequest *request = [[MPInstanceProvider sharedProvider] buildIMAdInterstitialRequest];
request.paramsDictionary = [NSDictionary dictionaryWithObject:@"c_mopub" forKey:@"tp"];
self.inMobiInterstitial = [[MPInstanceProvider sharedProvider] buildIMInterstitialWithDelegate:self appId:kInMobiAppID];
IMInMobiNetworkExtras *inmobiExtras = [[IMInMobiNetworkExtras alloc] init];
NSMutableDictionary *paramsDict = [[NSMutableDictionary alloc] init];
[paramsDict setObject:@"c_mopub" forKey:@"tp"];
[paramsDict setObject:MP_SDK_VERSION forKey:@"tp-ver"];
inmobiExtras.additionaParameters = paramsDict; // For supply source identification
if (self.delegate.location) {
[request setLocationWithLatitude:self.delegate.location.coordinate.latitude
[InMobi setLocationWithLatitude:self.delegate.location.coordinate.latitude
longitude:self.delegate.location.coordinate.longitude
accuracy:self.delegate.location.horizontalAccuracy];
}
[self.inMobiInterstitial loadRequest:request];
[self.inMobiInterstitial addAdNetworkExtras:inmobiExtras];
[self.inMobiInterstitial loadInterstitial];
}

- (void)showInterstitialFromRootViewController:(UIViewController *)rootViewController
Expand All @@ -81,20 +74,19 @@ - (void)dealloc

#pragma mark - IMAdInterstitialDelegate

- (void)interstitialDidFinishRequest:(IMAdInterstitial *)ad
{

- (void)interstitialDidReceiveAd:(IMInterstitial *)ad {
MPLogInfo(@"InMobi interstitial did load");
[self.delegate interstitialCustomEvent:self didLoadAd:ad];
}

- (void)interstitial:(IMAdInterstitial *)ad didFailToReceiveAdWithError:(IMAdError *)error
{
MPLogInfo(@"InMobi interstitial did fail with error: %@", error.localizedDescription);
- (void)interstitial:(IMInterstitial *)ad didFailToReceiveAdWithError:(IMError *)error {

MPLogInfo(@"InMobi banner did fail with error: %@", error.localizedDescription);
[self.delegate interstitialCustomEvent:self didFailToLoadAdWithError:nil];
}

- (void)interstitialWillPresentScreen:(IMAdInterstitial *)ad
{
- (void)interstitialWillPresentScreen:(IMInterstitial *)ad {
MPLogInfo(@"InMobi interstitial will present");
[self.delegate interstitialCustomEventWillAppear:self];

Expand All @@ -103,30 +95,28 @@ - (void)interstitialWillPresentScreen:(IMAdInterstitial *)ad
[self.delegate interstitialCustomEventDidAppear:self];
}

- (void)interstitial:(IMAdInterstitial *)ad didFailToPresentScreenWithError:(IMAdError *)error
{
- (void)interstitial:(IMInterstitial *)ad didFailToPresentScreenWithError:(IMError *)error {
MPLogInfo(@"InMobi interstitial failed to present with error: %@", error.localizedDescription);
[self.delegate interstitialCustomEvent:self didFailToLoadAdWithError:nil];
}

- (void)interstitialWillDismissScreen:(IMAdInterstitial *)ad
{
- (void)interstitialWillDismissScreen:(IMInterstitial *)ad {
MPLogInfo(@"InMobi interstitial will dismiss");
[self.delegate interstitialCustomEventWillDisappear:self];
}

- (void)interstitialDidDismissScreen:(IMAdInterstitial *)ad
{
- (void)interstitialDidDismissScreen:(IMInterstitial *)ad {
MPLogInfo(@"InMobi interstitial did dismiss");
[self.delegate interstitialCustomEventDidDisappear:self];
}

- (void)interstitialWillLeaveApplication:(IMAdInterstitial *)ad
{
- (void)interstitialWillLeaveApplication:(IMInterstitial *)ad {
MPLogInfo(@"InMobi interstitial will leave application");
// InMobi doesn't seem to have an explicit callback for tap events. However, leaving the
// application is generally an indicator of a user tap, so we can use this callback
// to signal the tap event.
[self.delegate interstitialCustomEventWillLeaveApplication:self];
}

- (void) interstitialDidInteract:(IMInterstitial *)ad withParams:(NSDictionary *)dictionary {
MPLogInfo(@"InMobi interstitial was tapped");
[self.delegate interstitialCustomEventDidReceiveTapEvent:self];
}

Expand Down
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
## Version 1.14 (September 12, 2013)

- iOS 7 Gold Master support
- Verified compatibility with latest Millennial iOS SDK (5.1.1)
- Updated support for InMobi SDK version 4.0
- Bug fixes

#### Updates to InMobi Integrations
- **Important**: As of version 1.14.0.0, the InMobi custom events packaged with the MoPub SDK only support InMobi version 4.00 and up. Follow the instructions [here](http://www.inmobi.com/support/art/25856216/22465648/integrating-mopub-with-inmobi-ios-sdk-4-0/) to integrate InMobi version 4.00 and up. If you would like to continue to use a prior version of the InMobi SDK, do not update the custom event files and follow the instructions [here](http://developer.inmobi.com/wiki/index.php?title=MoPub_InMobi_iOS) to integrate.

## Version 1.13 (August 22, 2013)

- Added support for creating calendar events, storing pictures, and video playback via MRAID APIs
Expand Down
Loading

0 comments on commit 6cefa6b

Please sign in to comment.