購入認証を有効にしている場合、Adjust SDKを使用して購入認証をリクエストできます。
Adjust SDKで購入認証を行うには、次の2つの方法があります。
-
購入を示す
ADJEvent
オブジェクトを作成し、以下のプロパティを追加します。transactionId
(NSString
):認証したいトランザクションのID。productId
(NSString
):購入に成功したアイテムのプロダクトID。
-
トランザクションIDとプロダクトIDを使用して
ADJAppStorePurchase
オブジェクトを作成します。
Adjust SDKで購入情報を送信すると、Adjustは以下を実行します。
- 情報をApp Storeに送信し、ステータスのレスポンスを待ちます。
- ステータスレスポンスをAdjust SDKに転送します。
コールバックを使用することで、購入認証ステータスにアクセスできます。結果は、以下のプロパティを含むADJPurchaseVerificationResult
オブジェクトとして返されます。
verificationStatus
(NSString
): 購入のステータス。code
(int
):購入のステータスコード。message
(NSString
):App Storeから返される全てのメッセージ。
イベントの記録と購入認証
- (void)verifyAndTrackAppStorePurchase:(nonnull ADJEvent *)event withCompletionHandler:(nonnull ADJVerificationResultBlock)completion;
購入認証の目的で収益イベントを送信し、購入認証ステータスを受け取るには、以下の手順に従ってください。
-
イベントトークンを使用して
ADJEvent
オブジェクトをインスタンス化し、以下のパラメーターを設定します。transactionId
(NSString
):認証したいトランザクションのID。productId
(NSString
):購入に成功したアイテムのプロダクトID。
-
次の引数を使用して
Adjust.verifyAndTrackPlayStorePurchase
メソッドを呼び出します:event
(ADJEvent
):インスタンス化されたイベントオブジェクト。callback
(ADJVerificationResultBlock
):ADJPurchaseVerificationResult
オブジェクトを引数として受け取るデリゲートコールバック関数。
この例では、購入認証レスポンスがログdaemonに出力されます。
let event = ADJEvent(eventToken: "g3mfiw")!event.setProductId("product-id")event.setTransactionId("transaction-id")
Adjust.verifyAndTrackAppStorePurchase(event) { verificationResult in print("Verification status: \(verificationResult.verificationStatus)") print("Code: \(verificationResult.code)") print("Message: \(verificationResult.message)")}
ADJEvent *event = [[ADJEvent alloc] initWithEventToken:yourEventToken];[event setProductId:@"product-id"];[event setTransactionId:@"transaction-id"];
[Adjust verifyAndTrackAppStorePurchase:event withCompletionHandler:^(ADJPurchaseVerificationResult * _Nonnull verificationResult) { NSLog(@"Verification status: %@", verificationResult.verificationStatus); NSLog(@"Code: %d", verificationResult.code); NSLog(@"Message: %@", verificationResult.message);}];
購入認証のみの場合
- (void)verifyAppStorePurchase:(nonnull ADJAppStorePurchase *)purchase withCompletionHandler:(nonnull ADJVerificationResultBlock)completion;
独立して購入データを送信し、購入認証ステータスを受信するには、次の手順に従ってください。
-
以下の引数で
ADJAppStorePurchase
をインスタンス化します:transactionId
(NSString
):認証したいトランザクションのID。productId
(NSString
):購入に成功したアイテムのプロダクトID。
-
次の引数を使用して
Adjust.verifyAppStorePurchase
メソッドを呼び出します:purchase
(ADJAppStorePurchase
):インスタンス化された購入オブジェクトcallback
(ADJVerificationResultBlock
):ADJPurchaseVerificationResult
オブジェクトを引数として受け取るデリゲートコールバック関数。
この例では、購入認証レスポンスがログdaemonに出力されます。
let appStorePurchase = ADJAppStorePurchase(transactionId: yourTransactionId, productId: yourProductId;
Adjust.verifyAppStorePurchase(appStorePurchase) { verificationResult in print("Verification status: \(verificationResult.verificationStatus)") print("Code: \(verificationResult.code)") print("Message: \(verificationResult.message)")}
ADJAppStorePurchase *appStorePurchase = [[ADJAppStorePurchase alloc] initWithTransactionId:yourTranscationId productId:yourProductId];
[Adjust verifyAppStorePurchase:appStorePurchase withCompletionHandler:^(ADJPurchaseVerificationResult * _Nonnull verificationResult) { NSLog(@"Verification status: %@", verificationResult.verificationStatus); NSLog(@"Code: %d", verificationResult.code); NSLog(@"Message: %@", verificationResult.message);}];