diff --git a/src/content/docs/zh/sdk/cordova/v4/features/subscriptions.mdx b/src/content/docs/zh/sdk/cordova/v4/features/subscriptions.mdx index 3f0f64dd4..162c9dd15 100644 --- a/src/content/docs/zh/sdk/cordova/v4/features/subscriptions.mdx +++ b/src/content/docs/zh/sdk/cordova/v4/features/subscriptions.mdx @@ -1,46 +1,45 @@ --- -title: Send subscription information -description: Use these methods send subscription information to Adjust. -slug: zh/sdk/cordova/v4/features/subscriptions -versions: - - label: v5 - value: v5 - default: true - - label: v4 - value: v4 -redirects: - v5: /zh/sdk/cordova/features/subscriptions +title: "发送订阅信息" +description: "使用这些方法向 Adjust 发送订阅信息。" +slug: "en/sdk/cordova/v4/features/subscriptions" +versions: + - + label: "v5" + value: "v5" + default: true + - + label: "v4" + value: "v4" +redirects: + v5: "/en/sdk/cordova/features/subscriptions" --- + - +下列步骤仅会在 Adjust SDK 中设置订阅监测。要启用该功能,请按照[为应用设置订阅监测](https://help.adjust.com/en/article/set-up-subscriptions-for-your-app)中的步骤操作。 + -下列步骤仅会在 Adjust SDK 中设置订阅监测。要启用该功能,请按照[为应用设置订阅监测](https://help.adjust.com/zh/article/set-up-subscriptions-for-your-app)中的步骤操作。 +您可以用 Adjust SDK 记录 App Store 和 Play 应用商店的订阅,并验证这些订阅是否有效。用户购买订阅后,创建一个包含细节的 `AdjustAppStoreSubscription` 或 `AdjustPlayStoreSubscription` 实例。 - +1\. 实例化订阅对象\{\#instantiate\-a\-subscription\-object\} +------------------------------------------------------------ -You can record App Store and Play Store subscriptions and verify their validity with the Adjust SDK. After the user purchases a subscription, create an `AdjustAppStoreSubscription` or `AdjustPlayStoreSubscription` instance containing the details. - -## 1\. Instantiate a subscription object \{\#instantiate\-a\-subscription\-object\} - -To get started, you need to create a subscription object containing details of the subscription purchase. - - - +要开始设置,先创建一个包含订阅购买细节的订阅对象。 + ```js constructor(price: string, currency: string, transactionId: string, receipt: string) ``` - + -Create an `AdjustAppStoreSubscription` object with the following properties: +创建一个 `AdjustAppStoreSubscription` 对象,属性如下: -| Parameter | Data type | Description | -| --------------- | --------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `price` | Number | The price of the subscription | -| `currency` | String | The currency of the subscription. Formatted as the [`currencyCode`](https://developer.apple.com/documentation/foundation/nslocale/1642836-currencycode?language=objc) of the [`priceLocale`](https://developer.apple.com/documentation/storekit/skproduct/1506145-pricelocale?language=objc) object | -| `transactionId` | String | Your ID for the transaction | -| `receipt` | String | The receipt information | +| 参数 | 数据类型 | 描述 | +|-----------------|------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `price` | 数字 | 订阅价格 | +| `currency` | 字符串 | 订阅使用的币种。此信息格式为 [`priceLocale`](https://developer.apple.com/documentation/foundation/nslocale/1642836-currencycode?language=objc) 对象的 [`currencyCode`](https://developer.apple.com/documentation/storekit/skproduct/1506145-pricelocale?language=objc)。 | +| `transactionId` | 字符串 | 您的交易 ID | +| `receipt` | 字符串 | 收据信息 | ```js var subscription = new AdjustAppStoreSubscription( @@ -51,25 +50,24 @@ var subscription = new AdjustAppStoreSubscription( ); ``` - - + ```js constructor(price: string, currency: string, sku: string, orderId: string, signature: string, purchaseToken: string) ``` - + -Create an `AdjustPlayStoreSubscription` object with the following properties: +创建一个 `AdjustPlayStoreSubscription` 对象,属性如下: -| Parameter | Data type | Description | -| --------------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `price` | Number | The price of the subscription | -| `currency` | String | The currency of the subscription | -| `sku` | String | The ID of the product | -| `orderId` | String | Your ID for the transaction | -| `signature` | String | The signature of the purchase data | -| `purchaseToken` | String | The unique token of the transaction. See [Google's documentation]() for more information | +| 参数 | 数据类型 | 描述 | +|-----------------|------|------------------------------------------------------------------------------------------------------------------------------------| +| `price` | 数字 | 订阅价格 | +| `currency` | 字符串 | 订阅使用的币种 | +| `sku` | 字符串 | 产品 ID | +| `orderId` | 字符串 | 您的交易 ID | +| `signature` | 字符串 | 购买数据的签名 | +| `purchaseToken` | 字符串 | 交易唯一识别码。请参考[Google 的文档](https://developer.android.com/reference/com/android/billingclient/api/Purchase#getPurchaseToken()),了解更多信息。 | ```js var subscription = new AdjustPlayStoreSubscription( @@ -82,23 +80,20 @@ var subscription = new AdjustPlayStoreSubscription( ); ``` - - - -### Record the purchase date {#record-the-purchase-date} + -You can record the date on which the user purchased a subscription. The SDK returns this data for you to report on. +### 记录购买日期\{\#record\-the\-purchase\-date\} - - +您可以记录用户购买订阅的日期。SDK 会返回该数据用于报告。 + ```js setTransactionDate(transactionDate: string): void ``` - + -Call the `setTransactionDate` method on your subscription object to record the timestamp of the subscription. +在您的订阅对象上调用 `setTransactionDate` 方法来记录订阅的时间戳。 ```js var subscription = new AdjustAppStoreSubscription( @@ -111,16 +106,15 @@ var subscription = new AdjustAppStoreSubscription( subscription.setTransactionDate(transactionDate); ``` - - + ```js setPurchaseTime(purchaseTime: string): void ``` - + -Call the `setPurchaseTime` method on your subscription object to record the timestamp of the subscription. +在您的订阅对象上调用 `setPurchaseTime` 方法来记录订阅的时间戳。 ```js var subscription = new AdjustPlayStoreSubscription( @@ -134,20 +128,19 @@ var subscription = new AdjustPlayStoreSubscription( subscription.setPurchaseTime(purchaseTime); ``` - - + -### Record the purchase region \(iOS only\) {#record-the-purchase-region-ios-only} +### 记录购买地区 \(仅限 iOS\)\{\#record\-the\-purchase\-region\-ios\-only\} - + ```js setSalesRegion(salesRegion: string): void ``` - + -You can record the region in which the user purchased a subscription. To do this, call the `setSalesRegion` method on your subscription object and pass the country code as a `string`. This needs to be formatted as the [`countryCode`](https://developer.apple.com/documentation/storekit/storefront/3792000-countrycode) of the [`Storefront`](https://developer.apple.com/documentation/storekit/storefront) object. +您可以记录用户购买订阅的地区。为此,请在订阅对象上调用 `setSalesRegion` 方法并将国家代码作为 `string` 传递。此信息格式需为 [`Storefront`](https://developer.apple.com/documentation/storekit/storefront/3792000-countrycode) 对象的 [`countryCode`](https://developer.apple.com/documentation/storekit/storefront)。 ```js var subscription = new AdjustAppStoreSubscription( @@ -160,18 +153,16 @@ var subscription = new AdjustAppStoreSubscription( subscription.setSalesRegion(salesRegion); ``` -### Add callback parameters {#add-callback-parameters} +### 添加回传参数\{\#add\-callback\-parameters\} -You can add callback parameters to your subscription object. The SDK appends these parameters to your callback URL. To add callback parameters, call the `addCallbackParameter` method on your subscription object. You can add multiple callback parameters by calling this method multiple times. - - - +您可以向订阅对象附加回传参数。SDK 会将这些参数附加至您的回传 URL。要添加回传参数,请在订阅对象上调用 `addCallbackParameter` 方法。多次调用该方法可添加多个回传参数。 + ```js addCallbackParameter(key: string, value: string): void ``` - + ```js var subscription = new AdjustAppStoreSubscription( @@ -185,14 +176,13 @@ subscription.addCallbackParameter("key1", "value1"); subscription.addCallbackParameter("key2", "value2"); ``` - - + ```js addCallbackParameter(key: string, value: string): void ``` - + ```js var subscription = new AdjustPlayStoreSubscription( @@ -208,21 +198,18 @@ subscription.addCallbackParameter("key1", "value1"); subscription.addCallbackParameter("key2", "value2"); ``` - - - -### Add partner parameters {#add-partner-parameters} + -You can add partner parameters to your subscription object. The SDK sends these to Adjust's servers when the user purchases a subscription. Adjust's servers forward the information on to your network partner. To add partner parameters, call the `addPartnerParameter` method on your subscription object. You can add multiple partner parameters by calling this method multiple times. +### 添加合作伙伴参数\{\#add\-partner\-parameters\} - - +您可以向订阅对象附加合作伙伴参数。用户购买订阅时,SDK 会将这些参数发送至 Adjust 服务器。Adjust 服务器会将此信息转发至您的合作伙伴。要添加合作伙伴参数,请在您的订阅对象上调用`addPartnerParameter`方法。多次调用该方法可添加多个合作伙伴参数。 + ```js addPartnerParameter(key: string, value: string): void ``` - + ```js var subscription = new AdjustAppStoreSubscription( @@ -236,14 +223,13 @@ subscription.addPartnerParameter("key1", "value1"); subscription.addPartnerParameter("key2", "value2"); ``` - - + ```js addPartnerParameter(key: string, value: string): void ``` - + ```js var subscription = new AdjustPlayStoreSubscription( @@ -259,23 +245,21 @@ subscription.addPartnerParameter("key1", "value1"); subscription.addPartnerParameter("key2", "value2"); ``` - - + -## 2\. Record subscription information \{\#record\-subscription\-information\} +2\. 记录订阅信息\{\#record\-subscription\-information\} +------------------------------------------------------- -Once you have set up your subscription object, you can record it using the Adjust SDK. - - - +设置好订阅对象后,您就可以通过 Adjust SDK 对其进行记录了。 + ```js trackAppStoreSubscription(subscription: AdjustAppStoreSubscription): void ``` - + -Pass your subscription object to the `trackAppStoreSubscription` method to record the user's subscription purchase. +将订阅对象传送至 `trackAppStoreSubscription` 方法,以记录用户订阅购买。 ```js var subscription = new AdjustAppStoreSubscription( @@ -294,16 +278,15 @@ subscription.addPartnerParameter("key2", "value2"); Adjust.trackAppStoreSubscription(subscription); ``` - - + ```js trackPlayStoreSubscription(subscription: AdjustPlayStoreSubscription): void ``` - + -Pass your subscription object to the `trackPlayStoreSubscription` method to record the user's subscription purchase. +将订阅对象传送至 `trackPlayStoreSubscription` 方法,以记录用户订阅购买。 ```js var subscription = new AdjustPlayStoreSubscription( @@ -323,5 +306,5 @@ subscription.addPartnerParameter("key2", "value2"); Adjust.trackPlayStoreSubscription(subscription); ``` - - + +