SDK /SDK
Tapjoy の iOS SDK リファレンスの中を見て回り、プレースメントのリクエスト、コールバックの処理、広告コンテンツの表示、コア SDK 機能の統合を行う方法を確認できます。
読み終わるまでの所要時間 3 分最終更新 10日前
プレースメントのリクエスト
まず、ファイルの先頭にTJPlacement.h#import <tapjoy tjplacement.h>
TJPlacement *p = [TJPlacement placementWithName:@"Main Menu" delegate:self];
[p requestContent];
コンテンツの事前キャッシュ
最高のユーザー体験を提供するために、ユーザーにそのコンテンツが表示されるコンテンツを事前にリクエストします。例えば、プレースメントがメインメニューのボタンの場合、アプリケーションの起動時に、Tapjoy Connect 呼び出しが成功した直後にコンテンツをリクエストすることをお勧めします。コンテンツをリクエストするまで待つと、多くの場合、ユーザーはコンテンツがロードされるまで、ローディングスピナーを見ながら待たされることになります。広告の場合、ユーザーが広告に関与する可能性が低くなり、収益を得る可能性が低くなります。TJPlacement コールバック
コンテンツリクエストの状態に関するフィードバックを取得するには、以下の TJPlacementDelegate メソッドを実装します。- (void)requestDidSucceed:(TJPlacement*)placement{} // Called when the content request returns from the Offerwall servers.Does not necessarily mean that content is available. - (void)requestDidFail:(TJPlacement*)placement error:(NSError*)error{} - (void)contentIsReady:(TJPlacement*)placement{} //This is called when the content is actually available to display. - (void)contentDidAppear:(TJPlacement*)placement{} - (void)contentDidDisappear:(TJPlacement*)placement{}
プレースメントの表示
コンテンツを実際に表示するには、以下のように show を呼び出します。[p showContentWithViewController: nil];
showContentWithViewControllershowContentWithViewControllerif (p.isContentReady) { [p showContentWithViewController: nil]; } else { //handle situation where there is no content to show, or it has not yet downloaded. }
p.isContentReadyコンテンツの再リクエスト
プレースメントからユーザーにコンテンツを正常に表示したら、コンテンツを再度リクエストして (例えば[p requestContent];[p showContentWithViewController: self];Tapjoy コンテンツアクションリクエストの処理
Reward (ゲーム内報酬) や IAP Promotion (アプリ内課金プロモーション) などの Tapjoy コンテンツタイプでは、そのコンテンツ単位で渡されたパラメーターに基づいてコードがアクションを実行する必要があります。例えば、Reward コンテンツ単位はアイテム名 (string) と数量 (integer) がユーザーに渡されることを指定します。ゲーム内報酬を反映するためにユーザーの広告在庫を実際に調整するのはアプリケーションです。以下の TJActionRequestDelegate メソッドが呼び出され、コンテンツ単位から適切な情報が渡されます。- (void)placement:(TJPlacement*)placement didRequestPurchase:(TJActionRequest*)request productId:(NSString*)productId { //called when user clicks the product link in IAP promotion content //implement code here to trigger IAP purchase flow for item here } - (void)placement:(TJPlacement*)placement didRequestReward:(TJActionRequest*)request itemId:(NSString*)itemId quantity:(int)quantity { //called when the reward content is closed by the user //implement code here to give the player copies of item }
エントリーポイントの設定
任意で、各プレースメントの "エントリーポイント" を Tapjoy に伝えることができます。以下のさまざまなプリセット値から選択できます。TJEntryPointUnknown //Not set, but removes any value that was already set TJEntryPointOther TJEntryPointMainMenu TJEntryPointHud TJEntryPointExit TJEntryPointFail TJEntryPointComplete TJEntryPointInbox TJEntryPointInitialisation TJEntryPointStore
TJPlacement *placement = [TJPlacement placementWithName:@"myPlacement" delegate:nil]; [placement setEntryPoint:TJEntryPointMainMenu]; [placement requestContent];