Intelligent Assistant
Chat with our virtual assistant to get answers promptly.
Documents from this version have been archived, and will not continue to be maintained. Please use the latest version.
Latest release: 4.0.4.301
1. Added the startIapActivity API in IapClient. You can use this API to open the in-app payment pages, including the subscription editing page and subscription management page.
This API is used in HMS Core IAP SDK 4.0.4.300 and later versions to replace the subscription management page redirection method provided in earlier versions.
The following is an example:
- // Redirect to the subscription management page.
- StartIapActivityReq req = new StartIapActivityReq();
- req.setType(StartIapActivityReq.TYPE_SUBSCRIBE_MANAGER_ACTIVITY);
- final Activity activity = getActivity();
- IapClient mClient = Iap.getIapClient(activity);
- Task<StartIapActivityResult> task = mClient.startIapActivity(req);
- task.addOnSuccessListener(new OnSuccessListener<StartIapActivityResult>() {
- @Override
- public void onSuccess(StartIapActivityResult result) {
- Log.i("startIapActivity", "onSuccess");
- if (result != null) {
- result.startActivity(activity);
- }
- }
- }).addOnFailureListener(new OnFailureListener() {
- @Override
- public void onFailure(Exception e) {
- Log.e("startIapActivity", "onFailure");
- }
- });
- // Redirect to the subscription editing page.
- StartIapActivityReq req = new StartIapActivityReq();
- req.setSubscribeProductId("XXX");
- req.setType(StartIapActivityReq.TYPE_SUBSCRIBE_EDIT_ACTIVITY);
- final Activity activity = getActivity();
- IapClient mClient = Iap.getIapClient(activity);
- Task<StartIapActivityResult> task = mClient.startIapActivity(req);
- task.addOnSuccessListener(new OnSuccessListener<StartIapActivityResult>() {
- @Override
- public void onSuccess(StartIapActivityResult result) {
- Log.i("startIapActivity", "onSuccess");
- if (result != null) {
- result.startActivity(activity);
- }
- }
- }).addOnFailureListener(new OnFailureListener() {
- @Override
- public void onFailure(Exception e) {
- Log.e("startIapActivity", "onFailure");
- }
- });
2. Added the status field in ProductInfo and also the getter and setter methods for the field. You can use this field to obtain the actual status of a subscription.
3. Added the getAccountFlag method to the InAppPurchaseData class. You can use this method to identify the account type of a user.
4. Added the getIapClient(Activity activity, String subAppId) method to the Iap class for quick apps.
Latest release: 4.0.2.300
1. Added the isSandboxActivated API to IapClient for you to check whether the sign-in HUAWEI ID and the app APK version meets the requirements of the sandbox testing. The following is an example:
- // To get the Activity instance that calls this API.
- Activity activity = getActivity();
- IapClient mClient = Iap.getIapClient(activity);
- Task<IsSandboxActivatedResult> task = mClient.isSandboxActivated(new IsSandboxActivatedReq());
- task.addOnSuccessListener(new OnSuccessListener<IsSandboxActivatedResult>() {
- @Override
- public void onSuccess(IsSandboxActivatedResult result) {
- Log.i(TAG, "isSandboxActivated success");
- dealSandboxResult(activity, result, handler);
- }
- }).addOnFailureListener(new OnFailureListener() {
- @Override
- public void onFailure(Exception e) {
- Log.e(TAG, "isSandboxActivated fail");
- if (e instanceof IapApiException) {
- IapApiException apiException = (IapApiException)e;
- int returnCode = apiException.getStatusCode();
- } else {
- // Other external errors
- }
- }
- });
2. Added ORDER_HIGH_RISK_OPERATIONS (60056) to OrderStatusCode, which indicates that the transaction is rejected because the user triggers risk control.
Latest release: 4.0.1.300
1. Supports integrating the IAP SDK into an app project in the Eclipse IDE.
Latest release: 4.0.0.300
1. Added a class InAppPurchaseData, using which you can parse InAppPurchaseData in JSON format.
Example:
- String token;
- try {
- // You can get iapData using the createPurchaseIntent or obtainOwnedPurchases API.
- InAppPurchaseData data = new InAppPurchaseData(iapData);
- token = data.getPurchaseToken();
- } catch (JSONException e) {
- handleError();
- }
- use(token);
2. Added originalLocalPrice and originalMicroPrice in ProductInfo returned after you call the obtainProductInfo API to obtain product details configured in AppGallery Connect. Your app can acquire the values of originalLocalPrice and originalMicroPrice to present both the original price and actual price of a product.
3. Added a tool class IapClientHelper. Using the parseRespCodeFromIntent method of this class, you can obtain result codes; using the parseRespMessageFromIntent method of this class, you can obtain response messages.
4. Added an API IapClient.PriceType, using which you can obtain the constant value IN_APP_CONSUMABLE, IN_APP_NONCONSUMABLE, or IN_APP_SUBSCRIPTION.
5. Added an API InAppPurchaseData.PurchaseState, using which you can obtain the constant value PURCHASED, CANCELED, or REFUNDED.
1. Changed the public fields in the com.huawei.hms.iap.entity package to the private fields and provided the corresponding getter and setter methods.
Latest release: 3.0.3.300
HMS SDK 3.0 Development Guide
HMS SDK 2.0 Development Guide
1. The SDK of this version runs on a mobile phone with HUAWEI HMS Core (APK) 4.0.4.300 or later installed. On a mobile phone that does not have HUAWEI HMS Core (APK) of 4.0.4.300 or later installed, the user will be prompted to install it when your app calls HUAWEI HMS Core (APK).
2. Basic features of HUAWEI IAP Kit are available on most Huawei devices, whereas some advanced features are available only on Huawei devices running EMUI of the required versions. For details, please refer to: EMUI Version-Dependent Features.