# 在Unity升级至IAP SDK v21

## 更新Unity用v21 Library文件

{% hint style="info" %}
如果只更換Library文件，IAP SDK v21新提供的多次購買、訂閱等功能將無法。
{% endhint %}

### 删除v19 Library文件。 <a href="#id-zai-unity-sheng-ji-zhi-iapsdkv21-shan-chu-v19library-wen-jian" id="id-zai-unity-sheng-ji-zhi-iapsdkv21-shan-chu-v19library-wen-jian"></a>

| **Assets > Plugins > Android** | <p>· iap\_sdk-v19.00.xx.aar<br>· iap\_adapter-v1.x.x.aar</p> |
| ------------------------------ | ------------------------------------------------------------ |
| **Assets > StreamingAssets**   | · global-appstores.json                                      |

### 從AndroidManifest.xml中刪除元素 <a href="#id-zai-unity-sheng-ji-zhi-iapsdkv21-cong-androidmanifest.xml-zhong-shan-chu-yuan-su" id="id-zai-unity-sheng-ji-zhi-iapsdkv21-cong-androidmanifest.xml-zhong-shan-chu-yuan-su"></a>

Assets > Plugins > Android > AndroidManifest.xml

刪除ProxyActivity和 iap\_version元數據。

```xml

<manifest>
<application>
        <activity android:name="com.gaa.sdk.iap.ProxyActivity"
android:configChanges="locale|fontScale|keyboard|keyboardHidden|layoutDirection|mcc|mnc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|touchscreen|uiMode"
android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen"/>

         <meta-data android:name="iap:api_version" android:value="6"/>
...
</application>
</manifest>

```

### [添加v21 Library文件。](https://github.com/ONE-store/unity_plugins/tree/archive) <a href="#id-zai-unity-sheng-ji-zhi-iapsdkv21-tian-jia-v21library-wen-jian" id="id-zai-unity-sheng-ji-zhi-iapsdkv21-tian-jia-v21library-wen-jian"></a>

將Library文件添加到下面的文件夹。

| **Assets > Plugins > Android** | <p>· sdk-base-v1.0.0.aar<br>· sdk-auth-v1.0.1.aar<br>· sdk-iap-v21.00.00.aar<br>· sdk-configuration-kr-v1.0.0.aar<br>· iap-unity-adapter-v2.0.0.aar</p> |
| ------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------- |

## 為使用IAP SDK v21新功能進行升级

### 刪除v19 ".unitypackage"中添加的文件

| **Assets > Plugins > Android**  | <p>· iap\_sdk-v19.00.xx.aar<br>· iap\_adapter-v1.x.x.aar</p>                                                                                  |
| ------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
| **Assets > Scripts > Purchase** | <p>· GaaIapCallManager.cs<br>· GaaIapCallbackManager.cs<br>· GaaIapResultListener.cs<br>· GaaIapPurchaseResponse.cs<br>· AndroidNative.cs</p> |
| **Assets > StreamingAssets**    | · global-appstores.json                                                                                                                       |

### 从AndroidManifest.xml中刪除元素

Assets > Plugins > Android > AndroidManifest.xml\
刪除ProxyActivity和iap\_version元數據。

```
<manifest>
    <application>
         <activity android:name="com.gaa.sdk.iap.ProxyActivity"
                  android:configChanges="locale|fontScale|keyboard|keyboardHidden|layoutDirection|mcc|mnc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|touchscreen|uiMode"
                  android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen"/>
 
         <meta-data android:name="iap:api_version" android:value="6"/>
        ...
    </application>
</manifest>
```

### 刪除GameObject

刪除GaaIapCallbackManager 遊戲對象。 應用了 v2的Unity Plugin，無須手動添加 GameObject 。<br>

<figure><img src="/files/qymqEMa3Nx5leMKNjPZO" alt=""><figcaption></figcaption></figure>

\
如果執行了上述所有操作，在應用IAP SDK v21之前已經做好了事前準備。\
現在可以参照 [在Unity使用One store In-App支付](/dev/cht/tools/billing/v21/unitymig.md)指南使用即可。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://onestore-dev.gitbook.io/dev/cht/tools/billing/v21/unitymig.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
