javaandroidhuawei-mobile-serviceshuawei-developershuawei-iap

Is there a way to get a callback when subscription changed in Huawei In App Purchase?


I am implementing IAP to my application.

There is a flow to change/cancel already purchased subscription. To do that "Subscription management" page should be opened. It is possible by getting result from

iapClient.startIapActivity(inAppRequest)

and calling

startIapActivityResult.startActivity(activity)

Unfortunately, in this case no result is returned and no callback is invoked, thus changes in subscriptions are not known unless a request is performed.

Is there a possibility to observe changes in user subscriptions while app is running?

Or is it possible to get a result in a same way (in onActivityResult) when a product is purchased using

iapClient.createPurchaseIntent(purchaseIntentReq)

Solution

  • You can use

    obtainOwnedPurchases()
    

    to query the current subscription. The returned subscription includes the current status of the subscription.

    You can get more detail from : https://developer.huawei.com/consumer/en/doc/HMSCore-References-V5/iapclient-0000001050137587-V5#ZH-CN_TOPIC_0000001050137587__section15126153542812