Skip to content

Latest commit

 

History

History
 
 

gdx-pay-android-huawei

IAP implementation with HMS (Huawei or an android device with HMS app)

It manages purchases, restores and consumption for consumable, non-consumable and subscription products.

Usage

Dependencies

android:

 compile "com.badlogicgames.gdxpay:gdx-pay-android-huawei:$gdxPayVersion"

ProGuard configuration

 -ignorewarning
 -keepattributes *Annotation*
 -keepattributes Exceptions
 -keepattributes InnerClasses
 -keepattributes Signature
 -keepattributes SourceFile,LineNumberTable
 -keep class com.hianalytics.android.**{*;}
 -keep class com.huawei.updatesdk.**{*;}
 -keep class com.huawei.hms.**{*;}

AndResGuard configuration

 "R.string.hms*",
 "R.string.connect_server_fail_prompt_toast",
 "R.string.getting_message_fail_prompt_toast",
 "R.string.no_available_network_prompt_toast",
 "R.string.third_app_*",
 "R.string.upsdk_*",
 "R.string.agc*",
 "R.layout.hms*",
 "R.layout.upsdk_*",
 "R.drawable.upsdk*",
 "R.color.upsdk*",
 "R.dimen.upsdk*",
 "R.style.upsdk*"

REQUIREMENTS

PREPARATION

How To use the HuaweiPurchaseManager

  • As PurchaseManager you have to instantiate the HuaweiPurchaseManager also passing a IAPListener;
  • Into your Activity, in onPurchaseResult(PurchaseIntentResult result) write the following code: result.getStatus().startResolutionForResult(this, ANY_RESOLUTION_CODE);
  • Into your Activity, override the onActivityResult(int requestCode, int resultCode, Intent data) to get the intent result (ref: https://developer.huawei.com/consumer/en/codelab/HMSInAppPurchase/index.html#6)
  • Optional: to consume a consumable product, after received the purchase result into your onActivityResult, there is a method into HuaweiPurchaseManager to manage it: consumeProduct(String inAppPurchaseData) result -> onConsumedResult(ConsumeOwnedPurchaseResult result)

Testing