diff --git a/InMobi/InMobiNativeAdAdapter.h b/InMobi/InMobiNativeAdAdapter.h index 51324dd5..811377bf 100644 --- a/InMobi/InMobiNativeAdAdapter.h +++ b/InMobi/InMobiNativeAdAdapter.h @@ -21,4 +21,5 @@ @property (nonatomic, strong) IMNative* nativeAd; /// MoPub native ad adapter delegate instance. @property(nonatomic, weak) id delegate; +@property (nonatomic) CGFloat mainMediaViewWidth; @end diff --git a/InMobi/InMobiNativeAdAdapter.m b/InMobi/InMobiNativeAdAdapter.m index fd31b6b3..f1782b4e 100644 --- a/InMobi/InMobiNativeAdAdapter.m +++ b/InMobi/InMobiNativeAdAdapter.m @@ -124,6 +124,8 @@ - (void)displayContentForURL:(NSURL *)URL rootViewController:(UIViewController * IMCompletionBlock completionBlock = ^{ if ([weakSelf.delegate respondsToSelector:@selector(nativeAdDidClick:)]) { [weakSelf.delegate nativeAdDidClick:weakSelf]; + MPLogEvent([MPLogEvent adTappedForAdapter:[self adapterName]]); + [self.nativeAd reportAdClickAndOpenLandingPage]; } [weakSelf.delegate nativeAdWillPresentModalForAdapter:self]; }; @@ -136,21 +138,11 @@ - (void)willAttachToView:(UIView *)view { MPLogEvent([MPLogEvent adShowAttemptForAdapter:name]); MPLogEvent([MPLogEvent adShowSuccessForAdapter:name]); MPLogEvent([MPLogEvent adDidAppearForAdapter:name]); - // Sending impression to MoPub SDK. - [self.delegate nativeAdWillLogImpression:self]; self.adView = view; } -- (void)trackClick { - // Sending click to MoPub SDK. - MPLogEvent([MPLogEvent adTappedForAdapter:[self adapterName]]); - [self.nativeAd reportAdClickAndOpenLandingPage]; -} - - (UIView *)mainMediaView { - UIView *view = [self.delegate viewControllerForPresentingModalView].view; - CGFloat width = view.frame.size.width; - return [self.nativeAd primaryViewOfWidth:width]; + return [self.nativeAd primaryViewOfWidth: self.mainMediaViewWidth]; } @end diff --git a/InMobi/InMobiNativeAdRenderer.m b/InMobi/InMobiNativeAdRenderer.m index 0a966053..0c45c168 100644 --- a/InMobi/InMobiNativeAdRenderer.m +++ b/InMobi/InMobiNativeAdRenderer.m @@ -66,6 +66,10 @@ - (UIView *)retrieveViewWithAdapter:(id)adapter error:(NSErro // Creates Unified Native AdView with adapter. - (void)renderUnifiedAdViewWithAdapter:(id)adapter { + if([adapter isKindOfClass: [InMobiNativeAdAdapter class]]) { + InMobiNativeAdAdapter *imAdapter = (InMobiNativeAdAdapter *)adapter; + imAdapter.mainMediaViewWidth = [[self.adView nativeMainImageView] frame].size.width; + } UIView *mainView = adapter.mainMediaView; [self.adView addSubview:mainView]; diff --git a/InMobi/InMobiNativeCustomEvent.m b/InMobi/InMobiNativeCustomEvent.m index c7e8b2b6..80117a12 100644 --- a/InMobi/InMobiNativeCustomEvent.m +++ b/InMobi/InMobiNativeCustomEvent.m @@ -123,6 +123,7 @@ - (void)native:(IMNative *)native didInteractWithParams:(NSDictionary *)params{ - (void)nativeAdImpressed:(IMNative *)native{ MPLogInfo(@"InMobi impression tracked successfully"); + [self.adAdapter.delegate nativeAdWillLogImpression:self.adAdapter]; } - (void)nativeDidFinishPlayingMedia:(IMNative*)native{