Guides & References
A full guide and reference page for in-app purchases in the HMS Unity Plugin, providing the necessary kits and services for a seamless integration.
Before we begin, ensure you have the following:
Unity 2018 or later.
HMS Unity Plugin.
A registered Huawei AppGallery Connect account.
IAP products at App Gallery Connect in IAP section.
Open the plugin editor window under Huawei > Kit Settings
For activating and using the IAP module of hms-unity-plugin, firstly developer has to activate the "Enable Plugin" checkbox (shown as 1 in the following picture) and "In-App Purchase" checkbox (shown as 2 in the following picture)
Creating Products in AppGallery Connect
Go to your app by following My apps > Operate >Product Management in AppGallery Connect.
Click on Add Products and fill in the information needed and save.
To create products in the Unity Editor, please take note of your ProductID. This unique identifier will be essential in identifying and managing your products within the Unity ecosystem.
Creating Products in Unity Editor
Click the IAP tab: Huawei > Kit Settings > IAP tab.
Create all products (all products at App Gallery Connect) in the IAP section.
You can create products in 2 ways.
Writing product detail in the IAP section by writing productId into Identifier and then clicking Add button. (shown as 1 in the following picture)
If you are using Google IAP, export IAP items to Excel then import into the Unity editor. (shown as 2 in the following picture)
Initializing IAP Kit at Runtime
You have 2 options.
1- If you check the "Initialize On Start" checkbox, it'll automatically retrieve registered products on Start.
2 - If you want to initialize the IAP by yourself, call the function mentioned below. You can also set callbacks as well.
Purchase Products
You can purchase products by calling HMSIAPManager.Instance.PurchaseProduct(productID).
Then you can catch purchase success at OnBuyProductSuccess callback with productId. In this callback, you can make what you want...
Restore Products
Consumable: Retrieve consumable product records with ;
Non-Consumable: Retrieve active non-consumable products with
Subscriptions: Retrieve active subscriptions with
Restoring Products Example
Managing Subscriptions
Access the subscription management screen by calling;
This screen displays all subscriptions.
To access a specific subscription screen directly, call
Last updated