distriqt / airnativeextensions

DEPRECATED: Original repository of the distriqt native extensions and is no longer maintained. Please see our site for the latest ANEs
https://airnativeextensions.com
2 stars 0 forks source link

InAppBilling - frozen issue on Android #66

Closed pierrickyamago closed 10 years ago

pierrickyamago commented 10 years ago

I have an issue with the InAppBilling ANE on Android.

Tested on the 1.37 version (I check the release notes, and there is no mention of a fix concerning this ANE) Steps : 1-Buy an item 2-Buy the same item 3-The app freezes

Here is my adb log :

E/com.distriqt.extension.inappbilling.util.IabHelper( 3746): In-app billing error: Unable to buy item, Error response: 7:Item Already Owned

D/com.distriqt.extension.inappbilling.util.IabHelper( 3746): Ending async operation: launchPurchaseFlow

D/com.distriqt.inappbilling::PurchaseListener( 3746): onIabPurchaseFinished

D/com.distriqt.inappbilling::PurchaseListener( 3746): onIabPurchaseFinished(): [7]:Unable to buy item (response: 7:Item Already Owned)

D/com.distriqt.inappbilling::ResponseHelper( 3746): Invalid purchase

D/com.distriqt.inappbilling::PurchaseListener( 3746): onIabPurchaseFinished(): purchase: <transaction><error>Invalid Purchase|-1</error></transaction>

I/com.distriqt.inappbilling::PurchaseActivity( 3746): onResume()

D/[HPTag] ( 3746): onConnectionFailed: result 4

D/[HPTag] ( 3746): onConnectionFailed: since user didn't initiate sign-in, failing now.

D/[MMGGGPlugin]( 3746): Automatic sign in did not complete.

I/WindowManager(  606): Screen frozen for +360ms due to Window{424b5f70 u0 air.net.yamago.Hilomi/com.distriqt.extension.inappbilling.activities.PurchaseActivity}

Do you confirm this issue?

Best Regards

Pierrick

VoodooGames commented 10 years ago

Hi,

According to the last error : E/com.distriqt.extension.inappbilling.util.IabHelper( 3746): In-app billing error: Unable to buy item, Error response: 7:Item Already Owned

It seems to me that you don't perform a "consume" after buying the product. On Android, you cannot buy an item you've already purchased without consuming it first (see the related Android docs here : https://developer.android.com/google/play/billing/api.html#purchase)

However the app shouldn't freeze, i don't know if it's a bug or something else.

Hope it helped

pierrickyamago commented 10 years ago

It's not a consumable item in my case.

In different scenarios, without calling restorePurchases() at the first session, developers can't know if a user have already bought an item. For instance this one : 1-user installs the app 2-user buy an item 3-user uninstalls the app 4-user buy the same item

A "restorePurchase check" sounds good but it adds an unnecessary loading time in almost all cases. I would prefer to display a dialog warning and then restore purchases for the user.

marchbold commented 10 years ago

Yeah I agree. I'll look into adding an event for "already purchased" so you can handle situations like this as you require.

marchbold commented 10 years ago

Just a question, if you press "back" when this happen does your app regain focus?

pierrickyamago commented 10 years ago

Hello Michael,

Thanks for your answer! Yes when I press "back", the app regain focus and don't freeze anymore. A event "already purchased" will be perfect :)

Best Regards

marchbold commented 10 years ago

Hi,

Just a note: You should actually already receive an event in this situation I've realised. A PURCHASE_FAILED event with a message: "response:item:already:owned"

marchbold commented 10 years ago

Latest update should fix this issue.

Cheers, Michael

pierrickyamago commented 10 years ago

Thank you Michael! the update seems to work works fine (I have to check all others events). I think it could be useful in your documentation to warning the developer about :

Best Regards Pierrick