Skip to content

Commit

Permalink
File src/content/docs/en/sdk/react-native/v5/features/subscriptions.m…
Browse files Browse the repository at this point in the history
…dx was translated to zh-CN locale
  • Loading branch information
smartling-github-connector[bot] authored Nov 7, 2024
1 parent 1797769 commit 43422d7
Showing 1 changed file with 63 additions and 93 deletions.
156 changes: 63 additions & 93 deletions src/content/docs/zh/sdk/react-native/v5/features/subscriptions.mdx
Original file line number Diff line number Diff line change
@@ -1,46 +1,41 @@
---
title: 发送订阅信息
description: 使用这些方法向 Adjust 发送订阅信息。
slug: zh/sdk/react-native/features/subscriptions
versions:
- label: v5
value: v5
default: true
- label: v4
value: v4
redirects:
v4: /zh/sdk/react-native/v4/features/subscriptions
title: "发送订阅信息"
description: "使用这些方法向 Adjust 发送订阅信息。"
slug: "en/sdk/react-native/features/subscriptions"
versions:
-
label: "v5"
value: "v5"
default: true
-
label: "v4"
value: "v4"
redirects:
v4: "/en/sdk/react-native/v4/features/subscriptions"
---
<callout type="important">

<Callout type="important">

下列步骤仅会在 Adjust SDK 中设置订阅监测。要启动该功能,Adjust 需要设置应用相关的具体信息。请发送邮件至 [[email protected]](mailto:[email protected])或与您的技术客户经理联系进行设置。

</Callout>
下列步骤仅会在 Adjust SDK 中设置订阅监测。要启用该功能,请按照[为应用设置订阅监测](https://help.adjust.com/en/article/set-up-subscriptions-for-your-app)中的步骤操作。
</Callout>

您可以用 Adjust SDK 记录 App Store 和 Play 应用商店的订阅,并验证这些订阅是否有效。用户购买订阅后,创建一个包含细节的 `AdjustAppStoreSubscription``AdjustPlayStoreSubscription` 实例。

## 1\. Instantiate a subscription object {#1-instantiate-a-subscription-object}
1\. 实例化订阅对象\{\#instantiate\-a\-subscription\-object\}
------------------------------------------------------------

要开始设置,先创建一个包含订阅购买细节的订阅对象。

<Tabs>
<Tab title="App Store" sync="appstore" icon="PlatformIos">
<CodeBlock title="方法签名">
<tabs> <tab title="App Store" sync="appstore" icon="PlatformIos"> <codeblock title="方法签名">

```ts
constructor(price: string, currency: string, transactionId: string: string)
```

</CodeBlock>
</CodeBlock>

创建一个 `AdjustAppStoreSubscription` 对象,属性如下:

| 参数 | 数据类型 | 描述 |
| --------------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `price` | `string` | 订阅价格 |
| `currency` | `string` | 订阅的币种。格式为 [`priceLocale`](https://developer.apple.com/documentation/storekit/skproduct/1506145-pricelocale?language=objc)对象的[`currencyCode`](https://developer.apple.com/documentation/foundation/nslocale/1642836-currencycode?language=objc) |
| `transactionId` | `string` | 交易的 ID |
\|参数 \|数据类型 \|描述 \| \| \-\-\-\-\-\-\-\-\-\-\-\-\-\-\- \| \-\-\-\-\-\-\-\-\- \| \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- \| \-\-\- \| \| `price` \| `string` \|订阅价格 \| \| `currency` \| `string` \|订阅的币种。格式为 [`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` \| `string` \| 交易的 ID \| \|

```jsx
var subscription = new AdjustAppStoreSubscription(
Expand All @@ -51,26 +46,24 @@ var subscription = new AdjustAppStoreSubscription(
Adjust.trackAppStoreSubscription(subscription);
```

</Tab>
<Tab title="Play 商店" sync="playstore" icon="PlatformGooglePlay">
<CodeBlock title="方法签名">
</Tab> <tab title="Play 商店" sync="playstore" icon="PlatformGooglePlay"> <codeblock title="方法签名">

```ts
constructor(price: string, currency: string, sku: string, orderId: string, signature: string, purchaseToken: string)
```

</CodeBlock>
</CodeBlock>

创建一个 `AdjustPlayStoreSubscription` 对象,属性如下:

| 参数 | 数据类型 | 描述 |
| --------------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `price` | `string` | 订阅价格 |
| `currency` | `string` | 订阅使用的币种 |
| `sku` | `string` | 产品 ID |
| `orderId` | `string` | 您的交易 ID |
| `signature` | `string` | 购买数据的签名 |
| `purchaseToken` | `string` | 交易唯一识别码。请参考[Google 的文档](<https://developer.android.com/reference/com/android/billingclient/api/Purchase#getPurchaseToken()>),了解更多信息。 |
| 参数 | 数据类型 | 描述 |
|-----------------|----------|------------------------------------------------------------------------------------------------------------------------------------|
| `price` | `string` | 订阅价格 |
| `currency` | `string` | 订阅使用的币种 |
| `sku` | `string` | 产品 ID |
| `orderId` | `string` | 您的交易 ID |
| `signature` | `string` | 购买数据的签名 |
| `purchaseToken` | `string` | 交易唯一识别码。请参考[Google 的文档](https://developer.android.com/reference/com/android/billingclient/api/Purchase#getPurchaseToken()),了解更多信息。 |

```jsx
var subscription = new AdjustPlayStoreSubscription(
Expand All @@ -83,22 +76,18 @@ var subscription = new AdjustPlayStoreSubscription(
);
```

</Tab>
</Tabs>
</Tab> </Tabs>

### Record the purchase date {#record-the-purchase-date}
### 记录购买日期\{\#record\-the\-purchase\-date\}

您可以记录用户购买订阅的日期。SDK 会返回该数据用于报告。

<Tabs>
<Tab title="App Store" sync="appstore" icon="PlatformIos">
<CodeBlock title="方法签名">
<tabs> <tab title="App Store" sync="appstore" icon="PlatformIos"> <codeblock title="方法签名">

```ts
public setTransactionDate(transactionDate: string): void
```

</CodeBlock>
</CodeBlock>

在您的订阅对象上调用 `setTransactionDate` 方法来记录订阅的时间戳。

Expand All @@ -113,15 +102,13 @@ subscription.setTransactionDate(transactionDate);
Adjust.trackAppStoreSubscription(subscription);
```

</Tab>
<Tab title="Play 商店" sync="playstore" icon="PlatformGooglePlay">
<CodeBlock title="方法签名">
</Tab> <tab title="Play 商店" sync="playstore" icon="PlatformGooglePlay"> <codeblock title="方法签名">

```ts
public setPurchaseTime(purchaseTime: string): void
```

</CodeBlock>
</CodeBlock>

在您的订阅对象上调用 `setPurchaseTime` 方法来记录订阅的时间戳。

Expand All @@ -137,20 +124,19 @@ var subscription = new AdjustPlayStoreSubscription(
subscription.setPurchaseTime(purchaseTime);
```

</Tab>
</Tabs>
</Tab> </Tabs>

### Record the purchase region \(iOS only\) {#record-the-purchase-region-ios-only}
### Record the purchase region \(iOS only\) \{\#record\-the\-purchase\-region\-ios\-only\}

<CodeBlock title="方法签名">
<codeblock title="方法签名">

```ts
public setSalesRegion(salesRegion: string): void
```

</CodeBlock>
</CodeBlock>

您可以记录用户购买订阅的地区。为此,请在订阅对象上调用 `setSalesRegion` 方法并将国家代码作为 `string` 传递。此信息格式需为 [`Storefront`](https://developer.apple.com/documentation/storekit/storefront) 对象的 [`countryCode`](https://developer.apple.com/documentation/storekit/storefront/3792000-countrycode)
您可以记录用户购买订阅的地区。为此,请在订阅对象上调用 `setSalesRegion` 方法并将国家代码作为 `string` 传递。此信息格式需为 [`Storefront`](https://developer.apple.com/documentation/storekit/storefront/3792000-countrycode) 对象的 [`countryCode`](https://developer.apple.com/documentation/storekit/storefront)

```jsx
var subscription = new AdjustAppStoreSubscription(
Expand All @@ -163,19 +149,16 @@ subscription.setSalesRegion(salesRegion);
Adjust.trackPlayStoreSubscription(subscription);
```

### Add callback parameters {#add-callback-parameters}
### 添加回传参数\{\#add\-callback\-parameters\}

您可以向订阅对象附加回传参数。SDK 会将这些参数附加至您的回传 URL。要添加回传参数,请在订阅对象上调用 `addCallbackParameter` 方法。多次调用该方法可添加多个回传参数。

<Tabs>
<Tab title="App Store" sync="appstore" icon="PlatformIos">
<CodeBlock title="方法签名">
<tabs> <tab title="App Store" sync="appstore" icon="PlatformIos"> <codeblock title="方法签名">

```ts
public addCallbackParameter(key: string, value: string): void
```

</CodeBlock>
</CodeBlock>

```jsx
var subscription = new AdjustAppStoreSubscription(
Expand All @@ -192,15 +175,13 @@ subscription.addCallbackParameter("key2", "value2");
Adjust.trackAppStoreSubscription(subscription);
```

</Tab>
<Tab title="Play 商店" sync="playstore" icon="PlatformGooglePlay">
<CodeBlock title="方法签名">
</Tab> <tab title="Play 商店" sync="playstore" icon="PlatformGooglePlay"> <codeblock title="方法签名">

```ts
public addCallbackParameter(key: string, value: string): void
```

</CodeBlock>
</CodeBlock>

```jsx
var subscription = new AdjustPlayStoreSubscription(
Expand All @@ -216,22 +197,18 @@ subscription.addCallbackParameter("key1", "value1");
subscription.addCallbackParameter("key2", "value2");
```

</Tab>
</Tabs>
</Tab> </Tabs>

### Add partner parameters {#add-partner-parameters}
### 添加合作伙伴参数\{\#add\-partner\-parameters\}

您可以向订阅对象附加合作伙伴参数。用户购买订阅时,SDK 会将这些参数发送至 Adjust 服务器。Adjust 服务器会将此信息转发至您的合作伙伴。要添加合作伙伴参数,请在您的订阅对象上调用`addPartnerParameter`方法。多次调用该方法可添加多个合作伙伴参数。

<Tabs>
<Tab title="App Store" sync="appstore" icon="PlatformIos">
<CodeBlock title="方法签名">
<tabs> <tab title="App Store" sync="appstore" icon="PlatformIos"> <codeblock title="方法签名">

```ts
public addPartnerParameter(key: string, value: string): void
```

</CodeBlock>
</CodeBlock>

```jsx
var subscription = new AdjustAppStoreSubscription(
Expand All @@ -248,15 +225,13 @@ subscription.addPartnerParameter("key2", "value2");
Adjust.trackAppStoreSubscription(subscription);
```

</Tab>
<Tab title="Play 商店" sync="playstore" icon="PlatformGooglePlay">
<CodeBlock title="方法签名">
</Tab> <tab title="Play 商店" sync="playstore" icon="PlatformGooglePlay"> <codeblock title="方法签名">

```ts
public addPartnerParameter(key: string, value: string): void
```

</CodeBlock>
</CodeBlock>

```jsx
var subscription = new AdjustPlayStoreSubscription(
Expand All @@ -272,22 +247,19 @@ subscription.addPartnerParameter("key1", "value1");
subscription.addPartnerParameter("key2", "value2");
```

</Tab>
</Tabs>
</Tab> </Tabs>

## 2\. Record subscription information {#2-record-subscription-information}
2\. Record subscription information \{\#record\-subscription\-information\}
---------------------------------------------------------------------------------

设置好订阅对象后,您就可以通过 Adjust SDK 对其进行记录了。

<Tabs>
<Tab title="App Store" sync="appstore" icon="PlatformIos">
<CodeBlock title="方法签名">
<tabs> <tab title="App Store" sync="appstore" icon="PlatformIos"> <codeblock title="方法签名">

```ts
trackAppStoreSubscription: (subscription: AdjustAppStoreSubscription) => void
```

</CodeBlock>
</CodeBlock>

将订阅对象传送至 `trackAppStoreSubscription` 方法,以记录用户订阅购买。

Expand All @@ -303,15 +275,13 @@ subscription.setSalesRegion(salesRegion);
Adjust.trackAppStoreSubscription(subscription);
```

</Tab>
<Tab title="Play 商店" sync="playstore" icon="PlatformGooglePlay">
<CodeBlock title="方法签名">
</Tab> <tab title="Play 商店" sync="playstore" icon="PlatformGooglePlay"> <codeblock title="方法签名">

```ts
trackPlayStoreSubscription: (subscription: AdjustPlayStoreSubscription) => void
```

</CodeBlock>
</CodeBlock>

将订阅对象传送至 `trackPlayStoreSubscription` 方法,以记录用户订阅购买。

Expand All @@ -329,5 +299,5 @@ subscription.setPurchaseTime(purchaseTime);
Adjust.trackPlayStoreSubscription(subscription);
```

</Tab>
</Tabs>
</Tab> </Tabs>

0 comments on commit 43422d7

Please sign in to comment.