Tapjoyというリワード広告について調べてみる
Tapjoy – Rewarding MobileTapjoy
リワード広告 - Wikipedia
日本語のドキュメントも大分あるけど、なんっか足りないんだよなー
導入は簡単。http://tech.tapjoy.com/sdk
前に紹介した[cocoapods](http://mochico-ios.hateblo.jp/entry/2014/04/13/235609) を使用して、Podfileに
pod "TapjoySDK", "10.0.0"で、コンソールで
$ pod installこうじゃ。説明ページにあるのそのままコピペするとクオートがおかしい。 BuildPhasesに追加するライブラリは、デモアプリの導入で説明でされている。 http://tech.tapjoy.com/product-overview/publishers/overview-for-publishers AppDelegateにAppIDとAppSecletKeyを設定する。 これらは[DashBoard](https://dashboard.tapjoy.com/) から登録して取得する。 ここで一番わかりづらいのが、先に実装を行わないとIntegratedがYESにならない。 アプリの情報もマーケットから取得するので、公開前のアプリどうすんのかよくわからない。 さらに、初期段階ではMovieなどの項目が利用できないのだけど、どうすんのかよくわからない。 ので、EasyAppの解説に終始することにする。
TapjoyEasyAppの動画終了イベントを探す
動画を最後まで見るとユーザーに仮想通貨が還元される。 この最後まで見た/見ていないはSDKで処理されている。 仮想通貨が付与される部分は、Androidの場合は実装ファイルが一つしかないので見つけるの簡単。TapjoyConnect.requestTapjoyConnect(getApplicationContext(), tapjoyAppID, tapjoySecretKey, connectFlags, new TapjoyConnectNotifier() { @Override public void connectSuccess() { onConnectSuccess(); } @Override public void connectFail() { onConnectFail(); } });
public void onConnectSuccess() { // NOTE: The get/spend/awardTapPoints methods will only work if your virtual currency // is managed by Tapjoy. // // For NON-MANAGED virtual currency, TapjoyConnect.getTapjoyConnectInsance().setUserID(...) // must be called after requestTapjoyConnect. // Get notifications whenever Tapjoy currency is earned. TapjoyConnect.getTapjoyConnectInstance().setEarnedPointsNotifier(new TapjoyEarnedPointsNotifier() { @Override public void earnedTapPoints(int amount) { earnedPoints = true; updateTextInUI("You've just earned " + amount + " Tap Points!"); showPopupMessage("You've just earned " + amount + " Tap Points!"); } });のあたりで仮想通貨の付与が完了したのをハンドルすることができそう。 仮想通貨を付与するタイミングならVideoの再生完了でもよいので、 DocumentにあるTapjoyVideoNotifier.videoComplete() でもできそう。 iOSはちょっと探すのめんどかった。 付属のDocument見る限りvideoComplete的なコールバックはない。 仮想通貨付与の時にダイアログが出ているが、これはどこで出ているのか。 これはTJAppDelegateにあり、
- (void)showEarnedCurrencyAlert:(NSNotification*)notifyObj { NSNumber *tapPointsEarned = notifyObj.object; int earnedNum = [tapPointsEarned intValue]; NSLog(@"Currency earned: %d", earnedNum); // Pops up a UIAlert notifying the user that they have successfully earned some currency. // This is the default alert, so you may place a custom alert here if you choose to do so. [Tapjoy showDefaultEarnedCurrencyAlert]; }この辺引っ掛ければ付与された仮想通貨の情報が取得できそう。