Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions InMobi/InMobiNativeAdAdapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@
@property (nonatomic, strong) IMNative* nativeAd;
/// MoPub native ad adapter delegate instance.
@property(nonatomic, weak) id<MPNativeAdAdapterDelegate> delegate;
@property (nonatomic) CGFloat mainMediaViewWidth;
@end
14 changes: 3 additions & 11 deletions InMobi/InMobiNativeAdAdapter.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];
};
Expand All @@ -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
4 changes: 4 additions & 0 deletions InMobi/InMobiNativeAdRenderer.m
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ - (UIView *)retrieveViewWithAdapter:(id<MPNativeAdAdapter>)adapter error:(NSErro

// Creates Unified Native AdView with adapter.
- (void)renderUnifiedAdViewWithAdapter:(id<MPNativeAdAdapter>)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];

Expand Down
1 change: 1 addition & 0 deletions InMobi/InMobiNativeCustomEvent.m
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down