# 在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 。\


<figure><img src="https://750271784-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fcs8LWlkAbJnzCUmymYwc%2Fuploads%2Fo3Hw6cYW2FNlk6zciGBw%2F7.png?alt=media&#x26;token=66e17687-c4b6-440f-b6db-4892e4728094" alt=""><figcaption></figcaption></figure>

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