인모비 네이티브 광고는 앱의 콘텐츠에 원활하게 섞여 들어가 사용자 경험에 영향을 주지 않으면서 사용자 참여를 최대화합니다. 앱의 디자인과 가장 잘 맞는 레이아웃을 선택하여 사용자 지정할 수 있습니다. 인모비 네이티브 광고는 뉴스, 유틸리티 및 커뮤니케이션 앱에 이상적입니다.
인모비 네이티브 광고는 비디오 및/또는 정적 이미지를 모두 포함할 수 있습니다. 배치 위치에 따라 다음을 선택할 수 있습니다.
다음의 간단한 단계에 따라 네이티브 광고를 통해 수익을 창출하십시오.
인피드 비디오 광고 배치
정적 피드 광고 배치
-(UIView*)primaryViewOfWidth:(CGFloat)width
스플래시 비디오 광고 배치
네이티브 광고 레이아웃으로 SPLASH를 선택합니다.
IMNative 클래스에는 다음 개체가 포함됩니다.
NSString* adTitle
- 광고 제목을 반환합니다.NSString* adDescription
- 광고 설명을 반환합니다.UIImage* adIcon
- 광고의 아이콘 이미지를 반환합니다.NSString* adCtaText
- 광고의 CTA(Click To Action) 텍스트를 반환합니다.NSString* adRating
- 광고 평가를 반환합니다(옵션).NSURL* adLandingPageUrl
- 광고 연결 URL을 반환합니다.BOOL isAppDownload
- 광고가 앱 다운로드용인지 여부를 반환합니다.NSString* customAdContent
- 여기에는 광고의 기본 뷰 주위에 사용자화된 UI를 생성하는 데 사용될 수 있는 추가 정보(설명, 이미지 URL 등)가 있습니다.IMNative 클래스는 다음 함수를 지원합니다.
-(UIView*)primaryViewOfWidth:(CGFloat)width
- 지정된 너비로 UIView를 반환합니다. 네이티브 광고의 메인 광고 콘텐츠입니다. 네이티브 배치를 생성하는 동안 인모비 대시보드에서 선택한 것과 동일한 가로 세로 비율의 뷰가 반환됩니다. 이 기본 뷰가 화면에 표시될 때 모든 광고노출 렌더링 이벤트도 자동으로 실행됩니다.
배치를 생성하는 동안 피드 레이아웃을 선택한 경우 primaryView를 가져오는 동안 너비를 25로 지정하십시오. 그러면 AdChoices 아이콘이 표시되고 광고 렌더링 이벤트가 실행됩니다.
-(void)load
- 광고를 메모리에 로드하는 함수입니다.-(BOOL)isReady
- True는 광고를 표시할 준비가 되었음을 의미합니다.-(void)reportAdClickAndOpenLandingPage
- 이 함수는 클릭 이벤트를 실행하고 연결 페이지를 엽니다. 이 함수를 사용하는 동안 연결 페이지를 직접 열지 않아도 됩니다.-(void)recyclePrimaryView
- 광고가 화면의 가시 영역을 벗어날 때마다 이 함수를 호출합니다. 또한 동일한 개체에 네이티브 광고를 다시 로드하기 전에 이 함수를 호출하십시오.인모비 SDK 헤더 파일을 가져옵니다.
#import <inmobisdk inmobisdk.h="">
</inmobisdk>
피드에 광고를 표시할 위치를 선언합니다. 아래 예에서는 4번째 위치에 광고를 표시합니다.
#define IM_AD_INSERTION_POSITION 4
다음 위치에 네이티브 광고 인스턴스를 선언합니다. ViewController.m
@interface TableViewController () <imnativedelegate>
@property(nonatomic,strong) IMNative *InMobiNativeAd;
@end
</imnativedelegate>
최종 ViewDidLoad
코드는 다음과 같아야 합니다.
- (void)viewDidLoad {
[super viewDidLoad];
self.InMobiNativeAd = [[IMNative alloc] initWithPlacementId:<insert here="" id="" inmobi="" placement="">];
self.InMobiNativeAd.delegate = self;
[self.InMobiNativeAd load];
//Your app content
}
</insert>
성공 콜백을 위해 IMNativeDelegate
메서드를 구현합니다. 성공 콜백은 광고가 화면에 표시될 준비가 되었음을 나타냅니다. 여기서는 TableView의 데이터 소스에 InMobiNativeAd 개체를 추가해야 합니다.
-(void)nativeDidFinishLoading:(IMNative*)native{
[self.tableData insertObject:native atIndex:IM_AD_INSERTION_POSITION];
[self.tableView reloadData];
NSLog(@"Native Ad did finish loading");
}
콜백 nativeAdDidFinishLoading
을 가져올 때 네이티브 광고가 성공적으로 수신되었습니다. 다음 예제에서는 tableView delegate cellForRowAtIndexPath
에서 adView를 가져오는 방법을 보여 줍니다.
참고: 네이티브 광고의 기본 뷰가 화면의 가시 영역 안에 있을 때만 광고노출 이벤트가 실행됩니다.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
InFeedTableCell *cell = (InFeedTableCell *)[tableView
dequeueReusableCellWithIdentifier:@"InFeedTableCell"];
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"InFeedTableCell"
owner:self options:nil];
cell = [nib objectAtIndex:0];
id slide = [self.tableData objectAtIndex:indexPath.row];
if ([self isAdAtIndexPath:indexPath]) {
IMNative * currentNativeAd = slide;
cell.iconImageView.image = currentNativeAd.adIcon;
cell.titleLabel.text = currentNativeAd.adTitle;
cell.subTitleLabel.text = @"Sponsored";
cell.descriptionLabel.text = currentNativeAd.adDescription;
cell.ctaLabel.text = currentNativeAd.adCtaText;
//Calculate your feed's primaryImageViewWidth and use it to fetch and
Ad Primary view of same width.
UIView* AdPrimaryViewOfCorrectWidth = [currentNativeAd
primaryViewOfWidth:primaryImageViewWidth];
//Set the frame of Ad Primary View same as that of your feed's Primary
View
AdPrimaryViewOfCorrectWidth.frame = primaryImageViewFrame;
[cell addSubview:AdPrimaryViewOfCorrectWidth];
UITapGestureRecognizer *singleTapAndOpenLandingPage =
[[UITapGestureRecognizer alloc] initWithTarget:currentNativeAd
action:@selector(reportAdClickAndOpenLandingPage)];
cell.ctaLabel.userInteractionEnabled = YES;
[cell.ctaLabel addGestureRecognizer:singleTapAndOpenLandingPage];
}
else{
//Your App’s TableCell implementation
}
return cell;
}
광고가 화면 영역 밖으로 나갈 때마다 네이티브 광고의 기본 뷰를 재활용해야 합니다. 이것은 메모리 사용량을 최적화하고 AdView가 앱의 네이티브 뷰와 충돌하지 않도록 하기 위한 것입니다. 광고가 가시 영역을 벗어날 때마다 InMobiNativeAd
개체의 recyclePrimaryView
메서드를 호출합니다. TableView에서는, didEndDisplayingCell
메서드에서 호출될 수 있습니다.
- (void)tableView:(UITableView *)tableView didEndDisplayingCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
if([self isAdAtIndexPath:indexPath]){
[self.InMobiNativeAd recyclePrimaryView];
}
}
참고: recyclePrimaryView
를 호출한 후 화면에서 이 뷰를 다시 추가하려면 이전 뷰가 재활용되었을 때 [self.InMobiNativeAd primaryViewOfWidth:<custom width="">]</custom>
에서 가져와야 합니다. 8단계에서 설명한 대로 cellForRowAtIndexPath delegate 에서 추가한 경우에는 여기에서 아무 것도 수행할 필요가 없습니다.
참고: tableData
에서 IMNative
개체를 제거하고 현재 광고 개체를 삭제하는 것이 중요합니다. 그런 다음 새 개체를 생성하고 개체에서 load를 호출해야 합니다. 또한 기존 개체를 삭제하기 전에 기본 뷰를 재활용해야 합니다.
-(void)refreshInMobiStrandAd {
[self.tableData removeObject:self.InMobiNativeAd];
[self.tableView reloadData];
[self.InMobiNativeAd recyclePrimaryView];
self.InMobiNativeAd = [[IMNative alloc] initWithPlacementId:<insert here="" id="" inmobi="" placement="">];
self.InMobiNativeAd.delegate = self;
[self.InMobiNativeAd load];
}
</insert>
[self.InMobiNativeAd primaryViewOfWidth:<custom width="">]</custom>
메서드를 다시 호출하여 현재 광고 기본 뷰를 새 뷰로 교체해야 합니다.ViewController
클래스의 dealloc
메서드에서 InMobiNativeAd
개체와 해당 delegate 를 nil로 설정해야 합니다. 할당 취소하기 전에 뷰를 재활용하여 adView에 대한 모든 참조를 제거하십시오.
-(void)dealloc {
[self.InMobiNativeAd recyclePrimaryView];
self.InMobiNativeAd.delegate = nil;
self.InMobiNativeAd = nil;
}
self.InMobiNativeAd.isReady
함수를 사용하여 광고를 표시할 준비가 되었는지 확인해야 합니다. 때로는 주 스레드가 점유된 상태일 수 있으므로 nativeDidFinishLoading
을 제때 수신하지 못할 수 있습니다. 그러므로 차단 기간이 경과된 직후에 광고가 준비되었는지 사전에 확인하는 것이 좋습니다.중요: 광고의 두 번째 화면이 표시되면 광고를 닫지 마십시오. nativeWillPresentScreen
에서 이를 확인하고 이 delegate 가 실행되면 광고를 닫지 않을 수 있습니다. 샘플 구현은 다음과 같습니다.
@property(nonatomic,strong) bool *isSecondScreenDisplayed;// Use this to check if second screen has to be shown or not
-(void)nativeWillPresentScreen:(IMNative*)native{
NSLog(@"Native Ad will present screen");
isSecondScreenDisplayed = YES;
}
광고를 닫기 전에 기본 뷰를 재활용해야 합니다. 다음과 같이 구현될 수 있습니다.
@property (nonatomic, strong) UIView* SplashAdView; // Use this view to check for visibility of splash screen
-(void)dismissAd{
if(isSecondScreenDisplayed){
NSLog(@"DO NOT DISMISS THE AD WHILE THE SCREEN IS BEING DISPLAYED");
}
else{
self.SplashAdView.hidden = true;
[self.InMobiNativeAd recyclePrimaryView];
self.InMobiNativeAd = nil;
}
}
프리롤 비디오 경험은 동일한 IMNative 클래스를 사용하여 구현할 수 있습니다. 다음 delegate 에서 광고 뷰를 닫아야 합니다.
-(void)nativeDidFinishPlayingMedia:(IMNative *)native{
[self dismissAd];
}
프리롤 광고는 다음과 같이 닫을 수 있습니다.
@property (nonatomic, strong) UIView* PrerollAdView; //Use this to store the primaryView returned by the IMNative instance.
-(void)dismissAd{
self.PrerollAdView.hidden = true;
[self.InMobiNativeAd recyclePrimaryView];
self.InMobiNativeAd = nil;
}
추가 콜백을 가져오려면 다음 단계를 수행합니다. ViewController.m
파일에 다음과 같은 delegate 메서드를 구현하십시오.
/*Indicates that the naive has received the ad markup. */
- (void)nativeAdIsAvailable:(IMNative *)native {
NSLog(@"nativeAdIsAvailable");
}
-(void)nativeDidFinishLoading:(IMNative*)native{
NSLog(@"Native Ad load Successful"); // Ad is ready to be displayed
}
-(void)native:(IMNative*)native didFailToLoadWithError:(IMRequestStatus*)error{
NSLog(@"Native Ad load Failed"); // No Fill or error
}
-(void)nativeWillPresentScreen:(IMNative*)native{
NSLog(@"Native Ad will present screen"); //Full Screen experience is about to be presented
}
-(void)nativeDidPresentScreen:(IMNative*)native{
NSLog(@"Native Ad did present screen"); //Full Screen experience has been presented
}
-(void)nativeWillDismissScreen:(IMNative*)native{
NSLog(@"Native Ad will dismiss screen"); //Full Screen experience is going to be dismissed
}
-(void)nativeDidDismissScreen:(IMNative*)native{
NSLog(@"Native Ad did dismiss screen"); //Full Screen experience has been dismissed
}
-(void)userWillLeaveApplicationFromNative:(IMNative*)native{
NSLog(@"User leave"); //User is about to leave the app on clicking the ad
}
-(void)native:(IMNative *)native didInteractWithParams:(NSDictionary *)params{
NSLog(@"User clicked"); // Called when the user clicks on the ad.
}
-(void)nativeAdImpressed:(IMNative *)native{
NSLog(@"User viewed the ad"); // Called when impression event is fired.
}
-(void)nativeDidFinishPlayingMedia:(IMNative*)native{
NSLog(@"The Video has finished playing"); // Called when the video has finished playing. Used for preroll use-case
}
-(void)native:(IMNative *)native rewardActionCompletedWithRewards:(NSDictionary *)rewards{
NSLog(@"Rewarded"); // Called when the user is rewarded to watch the ad.
}
-(void)userDidSkipPlayingMediaFromNative:(IMNative*) native {
NSLog(@"User has skipped playing media"); // Called when the user has opted to skip the media being shown.
}
-(void)native:(IMNative*)native adAudioStateChanged:(BOOL)audioStateMuted {
if (audioStateMuted) {
NSLog(@"Inline video-ad audio state changed to mute");
} else {
NSLog(@"Inline video-ad audio state changed to unmute");
}
//This is called when inline video audio state changes.
}
인모비의 SDK는 당신의 네이티브 지면을 배치할 때, HTML 방식과 Native Unit 방식을 모두 실행할 수 있습니다. 다음과 같은 사이즈의 광고를 귀사가 지정해둔 네이티브 지면에 배치할 수 있습니다.
이 기능을 설정하려면 원하는 백필 크기로 담당 파트너 관리자에게 문의해야 합니다. 또한 코드에서 다음과 같이 처리해야 합니다
.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
InFeedTableCell *cell = (InFeedTableCell *)[tableView
dequeueReusableCellWithIdentifier:@"InFeedTableCell"];
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"InFeedTableCell"
owner:self options:nil];
cell = [nib objectAtIndex:0];
id slide = [self.tableData objectAtIndex:indexPath.row];
if ([self isAdAtIndexPath:indexPath]) {
if ([currentNativeAd.customAdContent rangeOfString:@"isHTMLResponse"].location != NSNotFound)
{
IMNative * currentNativeAd = slide;
//Depending on the selected backfill size, provide accurate width below
UIView* AdPrimaryViewOfCorrectWidth = [currentNativeAd primaryViewOfWidth:250];
AdPrimaryViewOfCorrectWidth.frame = primaryImageViewFrame;
[cell addSubview:AdPrimaryViewOfCorrectWidth];
}
else
{
IMNative * currentNativeAd = slide;
cell.iconImageView.image = currentNativeAd.adIcon;
cell.titleLabel.text = currentNativeAd.adTitle;
cell.subTitleLabel.text = @"Sponsored";
cell.descriptionLabel.text = currentNativeAd.adDescription;
cell.ctaLabel.text = currentNativeAd.adCtaText;
//Calculate your feed's primaryImageViewWidth and use it to fetch and Ad Primary view of same width.
UIView* AdPrimaryViewOfCorrectWidth = [currentNativeAd primaryViewOfWidth:primaryImageViewWidth];
//Set the frame of Ad Primary View same as that of your feed's Primary View
AdPrimaryViewOfCorrectWidth.frame = primaryImageViewFrame;
[cell addSubview:AdPrimaryViewOfCorrectWidth];
UITapGestureRecognizer *singleTapAndOpenLandingPage =
[[UITapGestureRecognizer alloc] initWithTarget:currentNativeAd
action:@selector(reportAdClickAndOpenLandingPage)];
cell.ctaLabel.userInteractionEnabled = YES;
[cell.ctaLabel addGestureRecognizer:singleTapAndOpenLandingPage];
}
}
else {
//Your App’s TableCell implementation
}
return cell;
}
참고:
isHTMLResponse
라는 문자열이 포함됩니다.진행되고 있는 모든 광고 품질 검사를 피해나와, 관련성이없고 불쾌한 소재 또는 사용자에게 혼란을주는 광고를 보여줌으로써 앱의 사용자 경험을 손상시키는 불량 광고주가 가끔 있습니다. 이러한 상황을 극복하기 위해 광고 인스턴스의 creativeID를 검색하고 InMobi 담당자에게 암호화 된 creativeID를보고 할 수 있습니다.
mNativeAd.creativeId // mNativeAd
는 예제 인스턴스입니다.
Tools(도구) - Diagnostics(진단)로 이동하여 테스트 모드를 Global ON(전역 켜기) 또는 Selective ON(선택 켜기)으로 전환합니다.
광고 단위를 처음으로 통합하는 경우 | Test Mode(테스트 모드)를 Global ON(전역 켜기)으로 설정합니다. |
한 세트의 장치에 대한 테스트 트래픽을 선택적으로 켜려는 경우 이 특정 광고 단위에 SDK의 이전 버전이 이미 통합되어 있으므로 테스트를 일부 장치에만 제한해야 합니다. |
Test Mode(테스트 모드)를 Selective ON(선택 켜기)으로 설정합니다.
장치 섹션에서:
이미 장치가 구성되어 있으면 장치를 선택하고 테스트 모드를 사용할 수 있습니다. |
참고: 게시하기 전에 반드시 테스트 모드를 해제해야 합니다. 그렇지 않으면 앱에서 수익을 창출하지 못합니다.
이제는 모두 테스트 광고를 가져올 준비가 되었습니다.
장치 ID 가져오기
장치 ID는 기본적으로 IDFA 또는 IFA(광고용 식별자)입니다. 장치 ID를 가져오는 가장 쉬운 방법은 SDK의 로그 수준을 "디버그"로 설정하는 것입니다. 디버그 로그를 사용하려면 아래에 표시된대로 AppDelegate.m
파일 내의 didFinishLaunchingWithOptions
메서드에 추가하십시오.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
//Initialize InMobi SDK with your account ID
[IMSdk initWithAccountID:@"Insert InMobi account ID here"];
//Set log level to Debug
[IMSdk setLogLevel:kIMSDKLogLevelDebug];
// Do your stuff.
return YES;
}
디버그 모드에서 장치 ID는 XCode 개발자 콘솔에 다음과 같이 기록됩니다. “Publisher device ID is <device-id>â€?</device-id>
Device ID(장치 ID) 상자에 이 장치 ID를 입력할 수 있습니다.
[InMobi] InMobi SDK initialized with account id: <your account="" here="" id="" />
[InMobi] Fetching native ad for placement id: <your here="" id="" placement="" />
[InMobi] Publisher device id is <device here="" id="" />
[InMobi] Native ad successfully fetched for placement id: <your here="" id="" placement="" />
** ERROR ** [InMobi] ___ Please initialize the SDK before creating a <ad format="" />
ad.
** ERROR ** [InMobi] ___ Account id cannot be null or empty. Please provide a valid Account id.
[InMobi] Invalid account id passed to init. Please provide a valid account id.
일반 SDK 초기화 메시지
로그 수준 | 시나리오 | 표시된 메시지 |
오류 | SDK가 초기화되지 않음 | Please initialize the SDK before creating xxx ad. (xxx 광고를 생성하기 전에 SDK를 초기화하십시오.) |
오류 | 광고 서버 URL의 ATS 상태가 잘못됨 | ATS Configuration not supported. Kindly remove InMobi from the exception list. (ATS 구성이 지원되지 않습니다. 인모비를 예외 목록에서 제거하십시오.) |
오류 | initializeSDKWithAccountID에 제공된 계정 ID가 비어 있거나 null임 | Account id cannot be null or empty. Please provide a valid Account id. (계정 ID는 null이거나 비워 둘 수 없습니다. 올바른 계정 ID를 입력하십시오.) |
디버그 | 게시자가 올바른 계정 ID를 전달함 | InMobi SDK initialized with account id:<account-id /> |
디버그 | 계정 ID 길이가 유효하지 않은 경우 | Invalid account id passed to init. Please provide a valid account id. (init에 잘못된 계정 ID가 전달되었습니다. 올바른 계정 ID를 입력하십시오.) |
디버그 | SDK의 최신 버전이 제공됨 | A newer version (ver. 6.0.1) of the InMobi SDK is available! You are currently on an older version (Ver. 6.0.0). Please download the latest InMobi SDK from http://www.inmobi.com/products/sdk/#downloads (InMobi SDK의 최신 버전(버전 6.0.1)을 사용할 수 있습니다! 현재 이전 버전(버전 6.0.0)입니다. 최신 인모비 SDK는 http://www.inmobi.com/products/sdk/#downloads에서 다운로드하십시오.) |
일반적인 광고 수명 주기 메시지
로그 수준 | 시나리오 | 표시된 메시지 |
오류 | 제공된 PlacementID가 잘못됨(<= 0) | Please provide a valid placement id to create a xx ad. (xx 광고를 생성하려면 올바른 배치 ID를 입력하십시오.) |
오류 | 잘못된 배너 배치 ID가 호출됨 | Please give a valid placement id before calling load (load를 호출하기 전에 올바른 배치 ID를 제공하십시오.) |
오류 | 광고의 현재 상태가 Loading 또는 AdAvailable임 | An ad load is already in progress. Please wait for the load to complete before requesting for another ad. Rejected placement id: xx (광고 로드가 이미 진행 중입니다. 로드가 완료될 때까지 기다렸다가 다른 광고를 요청하십시오. 거부된 배치 ID: xx) |
오류 | 광고의 현재 상태가 Active임 | An ad is currently being viewed by the user. Please wait for the user to close the ad before requesting for another ad. Rejected placement id: xx (사용자가 현재 광고를 보고 있습니다. 사용자가 광고를 닫을 때까지 기다렸다가 다른 광고를 요청하십시오. 거부된 배치 ID: xx) |
오류 | 구성에 명시된 최소 새로 고침 간격 전에 광고가 새로 고쳐짐 | Ad cannot be refreshed before xxx secs (xxx초 전에 광고를 새로 고칠 수 없습니다.) |
오류 | 광고의 현재 상태가 ready임 | Ad Load is not complete. Please wait for the Ad to be in a ready state before calling show (광고 로드가 완료되지 않았습니다. show를 호출하기 전에 광고가 준비 상태가 될 때까지 기다려 주십시오.) |
오류 | 전면광고에서 Show가 호출되었지만 앱이 현재 뷰 컨트롤러를 전달하지 못함 | Full screen ad cannot be displayed without a view controller. Please pass a view controller to present the full screen ad. (전체 화면 광고는 뷰 컨트롤러 없이 표시할 수 없습니다. 전체 화면 광고를 표시하려면 뷰 컨트롤러를 전달하십시오.) |
오류 | 광고의 현재 상태가 부착/렌더링되지 않았거나 활성화되지 않음 | reportAdClick call made in wrong state (reportAdClick 호출이 잘못된 상태로 만들어졌습니다.) |
디버그 | 게시자 장치 ID | Publisher device id is <device-id /> |
디버그 | 수익 창출이 구성에서 비활성화됨 | SDK will not perform this load operation as monetization has been disabled. Please contact InMobi for further info. (SDK에서 수익 창출을 비활성화하면 이 로드 작업이 수행되지 않습니다. 자세한 내용은 인모비에 문의하십시오. |