Tapjoy Developers

  • デベロッパー
  • 広告主
  • ログイン/登録
Developer / 仮想通貨 / Tapjoy管理

Tapjoy管理

Table of Contents

  • 1 タップポイントの取得
    • 1.1 仮想通貨の取得についての注意点
    • 1.2 iOS手順
    • 1.3 Android手順
    • 1.4 Unity手順
    • 1.5 AIR手順
  • 2 ユーザが仮想通貨の取得した時のチェック
    • 2.1 iOS手順
    • 2.2 Android手順
    • 2.3 Unity手順
    • 2.4 AIR手順
  • 3 タップポイントの使用
    • 3.1 iOS手順
    • 3.2 Android手順
    • 3.3 Unity手順
    • 3.4 AIR手順
  • 4 タップポイントの付与
    • 4.1 iOS手順
    • 4.2 Android手順
    • 4.3 Unity手順
    • 4.4 AIR手順
  • 5 仮想通貨のテスト
  • 6 複数の仮想通貨
  • 7 ベスト事例と参考情報
ここでは仮想通貨のTapjoyホスティングサーバーの実装手順を説明します。
ユーザのアプリ内仮想通貨の管理はTapjoyサーバで実現可能です。この機能はTapjoy SDKご利用の開発者に無償で提供しております。この場合はCallbackURLが必要ありません。実装方法は下記のように非常に簡単です。

タップポイントの取得

仮想通貨の取得についての注意点

仮想通貨のTapjoy管理の場合は、ユーザーが広告のアクションを完了すると仮想通貨がTapjoyポイントサーバに追加されます。
アプリではTapjoy SDKが提供する関数でTapjoyポイントサーバにお問い合わせし、初めてポイント残高を確認できます。
Tapjoyポイントサーバの仮想通貨を確認するタイミングが遅れてしまいますと、ユーザーに適切なタイミングでポイントを付与できなくなります。重要なのはポイントはできるだけ早くユーザに付与する事ですが、Tapjoyサービスは諸事情(インターネット事情など)によりユーザーが広告を実施したと同時にポイントを付与する事ができません。ポイント付与の実装方法としてもっても良い事例は、ビデオ広告を閉じた時、オファーウォルを閉じた時などですが、そのほかには下記のようなアプリ仮想通貨が表示される場合はTapjoyサーバー上の仮想通貨数を確認し、アプリに付与するような実装をお勧めします。

  • アプリ起動時
  • アプリアクティブ時(バックグラウンドから起動など)
  • アプリ内ストアに遷移時
  • Tapjoyオファーウォルやその他広告を閉じる時、ビデオ広告が再生完了した時
  • レベルクリア時
  • その他、アプリ内仮想通貨が表示される各画面

他にも、アプリ内でユーザーに広告実施後ポイント付与まで少しお時間がかかるとの説明を追加するのも効果的です。

トップに戻る

ユーザーのタップポイントを取得するには、次のメソッドをコールします。

iOS手順

// This method requests the tapjoy server for current virtual currency of the user.
//Get Currency
[Tapjoy getCurrencyBalanceWithCompletion:^(NSDictionary *parameters, NSError *error) {
	if (error) {
		//Show error message
		NSLog(@"getCurrencyBalance error: %@", [error localizedDescription]);
	} else {
		//Update currency value of your app
		NSLog(@"getCurrencyBalance returned %@: %d", parameters[@"currencyName"], [parameters[@"amount"] intValue]);
	}
}];

下記Notificationをご利用できます。

TJC_GET_CURRENCY_RESPONSE_NOTIFICATION
TJC_GET_CURRENCY_RESPONSE_NOTIFICATION_ERROR

トップに戻る

Android手順

Tapjoy.getCurrencyBalance(new TJGetCurrencyBalanceListener(){
	@Override
	public void onGetCurrencyBalanceResponse(String currencyName, int balance) {
		Log.i(TAG, "getCurrencyBalance returned " + currencyName + ":" + balance);
	}
	@Override
	public void onGetCurrencyBalanceResponseFailure(String error) {
		Log.i("Tapjoy", "getCurrencyBalance error: " + error);
	}
});

トップに戻る

Unity手順

// Get currency
Tapjoy.GetCurrencyBalance();

// on enable, add delegates
void OnEnable() {
	Tapjoy.OnGetCurrencyBalanceResponse += HandleGetCurrencyBalanceResponse;
	Tapjoy.OnGetCurrencyBalanceResponseFailure += HandleGetCurrencyBalanceResponseFailure;
}

// on disable, remove delegates
void OnDisable() {
	Tapjoy.OnGetCurrencyBalanceResponse -= HandleGetCurrencyBalanceResponse;
	Tapjoy.OnGetCurrencyBalanceResponseFailure -= HandleGetCurrencyBalanceResponseFailure;
}
public void HandleGetCurrencyBalanceResponse(string currencyName, int balance) {
	Debug.Log("C#: HandleGetCurrencyBalanceResponse: currencyName: " + currencyName + ", balance: " + balance);
}
	
public void HandleGetCurrencyBalanceResponseFailure(string error) {
	Debug.Log("C#: HandleGetCurrencyBalanceResponseFailure: " + error);
}

トップに戻る

AIR手順

// Get currency
TapjoyAIR.getCurrencyBalance();

// Setup handlers
TapjoyAIR.addEventListener(TJCurrencyEvent.GET_CURRENCY_BALANCE_SUCCESS, tapjoyCurrencyEventHandler);
TapjoyAIR.addEventListener(TJCurrencyEvent.GET_CURRENCY_BALANCE_FAILURE, tapjoyCurrencyEventHandler);

private function tapjoyCurrencyEvents(event:TJCurrencyEvent):void {
	trace("Tapjoy sample event listener for " + event.type + ", " + event.balance + ", " + event.currencyName);
}

トップに戻る


ユーザが仮想通貨の取得した時のチェック

ここではユーザーの仮想通貨が追加された時に自動的に追加された仮想通貨数を確認できる方法を説明します。
EarnedCurrencyは前回確認された仮想通貨数より追加された場合、追加された分のみコールバックで通知します。このコールバックはgetCurrencyやawardCurrencyなどの仮想追加関連メソッドがコールされた場合に自動的に追加仮想通貨を判断します。
例えば、ある時点でgetCurrencyをコールし、仮想通貨を100が確認されたとします。その後ユーザーが広告を実行し仮想通貨25を取得した場合、次のgetCurrencyがコールされた場合getCurrencyのコールバックでは125を確認できますが、EarnedCurrencyコールバックではその差分の25を確認できます。

iOS手順

// Set the notification observer for earned-currency-notification. It's recommended that this be placed within the applicationDidBecomeActive method.
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(showEarnedCurrencyAlert:) name:TJC_CURRENCY_EARNED_NOTIFICATION object:nil];

// In the following method, you can set a custom message or use the default UIAlert to inform the user that they just earned some currency.
- (void)showEarnedCurrencyAlert:(NSNotification*)notifyObj
{
	NSNumber *currencyEarned = notifyObj.object;
	int earnedNum = [currencyEarned 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];

	// This is a good place to remove this notification since it is undesirable to have a pop-up alert more than once per app run.
	[[NSNotificationCenter defaultCenter] removeObserver:self name:TJC_CURRENCY_EARNED_NOTIFICATION object:nil];
}

トップに戻る

Android手順

 // Get notifications whenever Tapjoy currency is earned.
Tapjoy.setEarnedCurrencyListener(new TJEarnedCurrencyListener() {
	@Override
	public void onEarnedCurrency(String currencyName, int amount) {
		Log.i("Tapjoy", "You've just earned " + amount + " " + currencyName);
	}
});

トップに戻る

Unity手順

// on enable, add delegates
void OnEnable() {
	Tapjoy.OnEarnedCurrency += HandleEarnedCurrency;
}

// on disable, remove delegates
void OnDisable() {
	Tapjoy.OnEarnedCurrency -= HandleEarnedCurrency;
}

public void HandleEarnedCurrency(string currencyName, int amount) {
	Debug.Log("C#: HandleEarnedCurrency: currencyName: " + currencyName + ", amount: " + amount);
}

トップに戻る

AIR手順

TapjoyAIR.addEventListener(TJEarnedCurrencyEvent.EARNED_CURRENCY, tapjoyEarnedCurrencyEventHandler);

private function tapjoyEarnedCurrencyEventHandler(event:TJEarnedCurrencyEvent):void
{
	trace("You can notify user's here that they've just earned " + event.amount + " " + event.currencyName);
}

トップに戻る


タップポイントの使用

ユーザーの仮想通貨から、いくらかの金額を使用するには、次のメソッドを呼び出します。

iOS手順

// This method call will deduct 10 virtual currencies from the user's total.
[Tapjoy spendCurrency:10 completion:^(NSDictionary *parameters, NSError *error) {
	if (error)
		//Show error message
		NSLog(@"spendCurrency error: %@", [error localizedDescription]);
	else
		//Update currency value of your app
		NSLog(@"spendCurrency returned %@: %d", parameters[@"currencyName"], [parameters[@"amount"] intValue]);
}];

下記Notificationをご利用できます。

TJC_SPEND_CURRENCY_RESPONSE_NOTIFICATION
TJC_SPEND_CURRENCY_RESPONSE_NOTIFICATION_ERROR

トップに戻る

Android手順

Tapjoy.spendCurrency(25, new TJSpendCurrencyListener() {
	@Override
	public void onSpendCurrencyResponse(String currencyName, int balance) {
		Log.i(TAG, "spendCurrency returned " + currencyName + ":" + balance);
	}

	@Override
	public void onSpendCurrencyResponseFailure(String error) {
		Log.i("Tapjoy", "spendCurrency error: " + error);
	}
});

トップに戻る

Unity手順

// Spend currency
Tapjoy.SpendCurrency(10);

// on enable, add delegates
void OnEnable() {
	Tapjoy.OnSpendCurrencyResponse += HandleSpendCurrencyResponse;
	Tapjoy.OnSpendCurrencyResponseFailure += HandleSpendCurrencyResponseFailure;
}

// on disable, remove delegates
void OnDisable() {
	Tapjoy.OnSpendCurrencyResponse -= HandleSpendCurrencyResponse;
	Tapjoy.OnSpendCurrencyResponseFailure -= HandleSpendCurrencyResponseFailure;
}

public void HandleSpendCurrencyResponse(string currencyName, int balance) {
	Debug.Log("C#: HandleSpendCurrencyResponse: currencyName: " + currencyName + ", balance: " + balance);
}
	
public void HandleSpendCurrencyResponseFailure(string error) {
	Debug.Log("C#: HandleSpendCurrencyResponseFailure: " + error);
}

トップに戻る

AIR手順

// Spend currency
TapjoyAIR.spendCurrency(10);

// Setup handlers
TapjoyAIR.addEventListener(TJCurrencyEvent.SPEND_CURRENCY_SUCCESS, tapjoyCurrencyEventHandler);
TapjoyAIR.addEventListener(TJCurrencyEvent.SPEND_CURRENCY_FAILURE, tapjoyCurrencyEventHandler);

private function tapjoyCurrencyEventHandler(event:TJCurrencyEvent):void {
	trace("Tapjoy sample event listener for " + event.type + ", " + event.balance + ", " + event.currencyName);
}

トップに戻る


タップポイントの付与

ユーザーの仮想通貨に、いくらかの金額を授与するには、次のメソッドを呼び出します。

iOS手順

// This method call will award 10 virtual currencies to the user's total.
[Tapjoy awardCurrency:10 completion:^(NSDictionary *parameters, NSError *error) {
	if (error)
		//Show error message
		NSLog(@"awardCurrency error: %@", [error localizedDescription]);
	else
		//Update currency value of your app
		NSLog(@"awardCurrency returned %@: %d", parameters[@"currencyName"],[parameters[@"amount"] intValue]);
}];

下記Notificationがご利用可能です。

TJC_AWARD_CURRENCY_RESPONSE_NOTIFICATION
TJC_AWARD_CURRENCY_RESPONSE_NOTIFICATION_ERROR

トップに戻る

Android手順

Tapjoy.awardCurrency(10, new TJAwardCurrencyListener() {
	@Override
	public void onAwardCurrencyResponseFailure(String error) {
		Log.i(TAG, "awardCurrency returned " + currencyName + ":" + balance);
	}

	@Override
	public void onAwardCurrencyResponse(String currencyName, int balance) {
		Log.i("Tapjoy", "awardCurrency error: " + error);
	}
});

トップに戻る

Unity手順

// Award currency
Tapjoy.AwardCurrency(10);

// on enable, add delegates
void OnEnable() {
	Tapjoy.OnAwardCurrencyResponse += HandleAwardCurrencyResponse;
	Tapjoy.OnAwardCurrencyResponseFailure += HandleAwardCurrencyResponseFailure;
}

// on disable, remove delegates
void OnDisable() {
	Tapjoy.OnAwardCurrencyResponse -= HandleAwardCurrencyResponse;
	Tapjoy.OnAwardCurrencyResponseFailure -= HandleAwardCurrencyResponseFailure;
}

public void HandleAwardCurrencyResponse(string currencyName, int balance) {
	Debug.Log("C#: HandleAwardCurrencySucceeded: currencyName: " + currencyName + ", balance: " + balance);
}
	
public void HandleAwardCurrencyResponseFailure(string error) {
	Debug.Log("C#: HandleAwardCurrencyResponseFailure: " + error);
}

トップに戻る

AIR手順

// Award currency
TapjoyAIR.awardCurrency(10);

// Setup handlers
TapjoyAIR.addEventListener(TJCurrencyEvent.AWARD_CURRENCY_SUCCESS, tapjoyCurrencyEventHandler);
TapjoyAIR.addEventListener(TJCurrencyEvent.AWARD_CURRENCY_FAILED, tapjoyCurrencyEventHandler);

private function tapjoyCurrencyEventHandler(event:TJCurrencyEvent):void {
	trace("Tapjoy sample event listener for " + event.type + ", " + event.balance + ", " + event.currencyName);
}

トップに戻る


仮想通貨のテスト

テスト端末のIDを登録すると、オファーウォールでテスト用広告を表示できるようになります。追加するには、お使いのアプリのダッシュボードで、[設定]-[アプリ設定]から[テストデバイス]を選択します。 IDの追加後、次のようにテスト広告がオファーウォールの上部に表示され、通貨を簡単にテストすることができます。

test_offerwall


複数の仮想通貨

Tapjoy管理の場合、複数の仮想通貨は取り扱うことができません。複数の仮想通貨を取り扱うには仮想通貨の自社管理のを実装します。

トップに戻る


ベスト事例と参考情報

  • 注意:awardCurrencyとspendCurrencyが正しく動作しているかを必ず確認してください。正しく動作しない場合はアプリ内の仮想通貨値が異常になる可能性があります。
    TJC_SPEND_CURRENCY_RESPONSE_NOTIFICATION_ERROR 
    TJC_AWARD_CURRENCY_RESPONSE_NOTIFICATION_ERROR
    

    などのコールバック関数を必ず実装するしてください。

  • Tapjoy仮想通貨をアプリ内で管理するように実装する事をお勧めします。Tapjoyサーバは広告取得によりポイントを格納する場所のみにし、ポイント残高がある場合はアプリに移し、サーバ上は常に0にするようにします。
  • spendCurrencyは仮想通貨がアプリ内で使用された場合に利用してください。
  • 仮想通貨のTapjoy管理は一つの仮想通貨に対応します。複数の仮想通貨を取り扱うには仮想通貨の自社管理をご検討ください。
  • 仮想通貨のTapjoy管理では残高がデバイス毎に管理されるので、複数でバイス間の仮想通貨の共有ができません。

トップに戻る

  • このフィールドは入力チェック用です。変更しないでください。
ナレッジセンター
製品概要
SDK実装ガイド
iOS SDK
アプリ開発者向け
広告主向け
SDK10x以下からの移行ガイド
5rockからSDK11へのアップデート
Android SDK
アプリ開発者向け
広告主向け
複数インストールリファラレシーバー
SDK10x以下からの移行ガイド
5rockからSDK11へのアップデート
Unity Plugin
アプリ開発者向け
広告主向け
サンプルアプリ
SDK10x以下からの移行ガイド
Unity Migration Guide: 5rocks to Tapjoy 11
Adobe AIR Plugin
アプリ開発者向け
広告主向け
Tapjoy 10からSDK11へのアップデート
Cocos 2d-x
Tapjoy メディエーション パートナー
仮想通貨
Tapjoy管理
仮想通貨の自社管理
広告レポートAPI
アプリ開発者向けレポートAPI
よくあるご質問
Glossary
Publisher Integration Checklist
広告レポートAPI
データ分析レポートAPI
自動プッシュ通知設定ガイド
プッシュ証明書の作成方法
FCM 用のSender IDとAPI Keyの確認方法
複数Push通知
デバイス広告ID
Push通知のカスタムフィールド
Setting up Test Devices
エンジニア ブログ (英語)
従来製品
GDPR
お問い合わせ
  • English
  • 日本語 (Japan)
  • 한국어 (Korea)
  • 中文 (China)
  • Login/Sign Up
  • Privacy and Legal
Follow Us
  • English
  • 日本語 (Japan)
  • 한국어 (Korea)
  • 中文 (China)

©2019 Tapjoy, Inc. All Rights Reserved. Tapjoy and the Tapjoy logo are trademarks or registered trademarks of Tapjoy, Inc. All third party logos and trademarks mentioned are the property of their respective owners.

  • デベロッパー
  • 広告主
  • ログイン/登録