기술 자료

지원

SDK

TJPlacement 클래스를 사용하여 광고 플레이스먼트를 요청하는 방법을 알아보려면 기본 SDK 기술 자료를 참고하여 플레이스먼트 이름이 탭조이 대시보드에서 설정된 이름과 일치하도록 합니다.
읽는 시간 1분최근 업데이트: 2일 전

플레이스먼트 요청

플레이스먼트를 요청하려면
TJPlacement
클래스를 사용합니다. 코드의 플레이스먼트 이름 문자열이 대시보드의 플레이스먼트 이름과 정확히 일치해야 합니다.
TJPlacementListener placementListener = this;TJPlacement p = Tapjoy.getPlacement("[PLACEMENT_NAME]", placementListener);
listener 메서드가 적용되고 플레이스먼트가 인스턴스화되면 해당 플레이스먼트에 대한 콘텐츠를 요청할 수 있습니다.
if(Tapjoy.isConnected()) p.requestContent();else Log.d("MyApp", "Tapjoy SDK must finish connecting before requesting content.")
콘텐츠를 요청하기 전에 탭조이 연결 호출이 성공해야 합니다.
onConnectSuccess
콜백을 수신한 이후 요청해야 합니다.

콘텐츠 사전 캐싱

최적의 사용자 경험을 제공하려면 사용자에게 해당 콘텐츠가 표시되기 전에 콘텐츠를 요청합니다. 예를 들어 플레이스먼트가 메인 메뉴의 버튼이면 탭조이 연결 호출 성공 직후 애플리케이션이 시작될 때 해당 콘텐츠를 요청할 수 있습니다. 마지막 순간까지 대기하여 콘텐츠를 요청하면 사용자가 콘텐츠가 로드될 때까지 기다리고 로딩 스피너를 보게 될 수 있습니다. 이렇게 하면 광고에서 사용자가 광고와 상호 작용할 가능성이 감소하므로 사용자가 수익을 창출할 가능성 역시 줄어듭니다.

리스너

다양한 플레이스먼트 응답을 처리하기 위한 델리게이트 메서드를 준비해야 합니다. 최소한 클래스는 TJPlacementListener 인터페이스를 확장해야 합니다(YourMainActivity 공개 클래스가 확장되고 Activity가 TJPlacementListener를 구현함).
TJPlacementListener
인터페이스로 정의되는 주요 메서드는 다음과 같습니다.
public void onRequestSuccess(TJPlacement placement); // This just means the SDK has made contact with the Offerwall servers. It does not necessarily mean that any content is available.public void onRequestFailure(TJPlacement placement, TJError error);public void onContentReady(TJPlacement placement); //This is called when the content is actually available to display.public void onContentShow(TJPlacement placement);public void onContentDismiss(TJPlacement placement);
동영상이 포함될 수 있는 플레이스먼트의 콘텐츠를 표시하기 전에 오디오를 음소거로 설정하는 것이 좋습니다. 그렇지 않으면 동영상 오디오와 앱 오디오가 충돌할 수 있습니다. 종종 onContentReady 델리게이트가 작동할 때까지 기다린 후 사용자에게 콘텐츠를 표시하는 것이 좋습니다. 이렇게 하면 콘텐츠가 실제로 디바이스에 있는지 확인할 수 있으며 사용자에게 지연 없이 표시할 수 있습니다. 다른 동등한 방법은 위의 예시와 같이 p.isContentReady()가 true인지 확인하는 것입니다.

플레이스먼트 표시

TJPLacement를 요청할 때 TJPLacementListener 오브젝트와 함께 전달합니다. TJPlacementListener에는 ‘onRequestSuccess’ 콜백이 포함됩니다. SDK가 서버에 콘텐츠를 성공적으로 요청한 후 onRequestSuccess 콜백이 작동합니다. 이 콜백이 작동하면 isContentAvailable 함수를 호출하여 TJPlacement에 콘텐츠가 있는지 확인할 수 있습니다.
public void onRequestSuccess(TJPlacement tjPlacement){ if(tjPlacement.isContentAvailable()) { //There is an ad unit available } else { //Fall-through }}
public void onContentReady(TJPlacement tjPlacement) { if(tjPlacement.isContentReady()) { // We can uncomment the following line to show the ad as soon as it finishes loading, // or call showContent at a later point when we're ready to display the ad. tjPlacement.showContent(); }}

콘텐츠 다시 요청

플레이스먼트에서 사용자에게 콘텐츠를 성공적으로 표시할 경우 다른 콘텐츠 단위로 플레이스먼트를 ‘재로드’하려면 콘텐츠를 다시 요청해야 합니다(예:
p.requestContent();
다시 호출).
p.showContent();
를 다시 호출할 수 없습니다. 콘텐츠를 요청하기 전에 콘텐츠를 표시하려고 하면 콘텐츠가 표시되지 않습니다.
콘텐츠가 준비되면 콘텐츠를 표시할 수 있습니다.
if(p.isContentReady()) { p.showContent();}else { //handle situation where there is no content to show, or it has not yet downloaded.}

탭조이 콘텐츠 액션 요청 처리

보상과 IAP Promo 등의 일부 탭조이 콘텐츠 유형에서는 해당 콘텐츠 단위가 전달한 파라미터에 따라 코드를 통해 조치를 취해야 합니다. 예를 들어 보상 콘텐츠 단위는 사용자에게 지정할 항목 이름(문자열)과 수량(정수)을 지정합니다. 애플리케이션에서는 보상을 반영하도록 사용자의 인벤토리를 실제로 조정해야 합니다. 다음과 같이 특수한 유형의 콘텐츠 단위에 대한 델리게이트 메서드가 있습니다.
public void onPurchaseRequest(TJPlacement placement, TJActionRequest request, String productId); //onPurchaseRequest called when user clicks the product link in IAP promotion content. Put the code that actually triggers the IAP here.////public void onRewardRequest(TJPlacement placement, TJActionRequest request, String itemId, int quantity); //called when the content closed in reward content

엔트리 포인트 설정

필요에 따라 각 플레이스먼트의 ‘엔트리 포인트’를 탭조이에 제공할 수 있습니다. 선택 가능한 다양한 프리셋 값은 다음과 같습니다.
TJEntryPoint.ENTRY_POINT_UNKNOWNTJEntryPoint.ENTRY_POINT_OTHERTJEntryPoint.ENTRY_POINT_MAIN_MENUTJEntryPoint.ENTRY_POINT_HUDTJEntryPoint.ENTRY_POINT_EXITTJEntryPoint.ENTRY_POINT_FAILTJEntryPoint.ENTRY_POINT_COMPLETETJEntryPoint.ENTRY_POINT_INBOXTJEntryPoint.ENTRY_POINT_INITTJEntryPoint.ENTRY_POINT_STORE
플레이스먼트 오브젝트를 생성한 후, 콘텐츠를 요청하기 전에 엔트리 포인트를 설정합니다.
TJPlacement placement = Tapjoy.getPlacement("myPlacement", null);placement.setEntryPoint(TJEntryPoint.ENTRY_POINT_MAIN_MENU);placement.requestContent();