I’m not seeing this behavior on Scripted or Codeless IAP. Once I click the background to dismiss the Google purchase dialog, I immediately receive OnPurchaseFailed with failure reason UserCancelled, as expected. I’m using the Sample IAP Project here with IAP 2.2.5 (Asset) and In App Purchasing library 2.2.1 (Package Manager) Sample IAP Project
Can you elaborate “go to pause”? Once the Google purchase dialog appears, your game is already in the background. I also tried pressing the Home button and switching to another app with the purchase dialog up. Once I came back to my app, the dialog was gone and I had received OnPurchaseFailed.
The issue only occurs for me if I go back to the app via app icon on homescreen or app list. If I go back to the app by switching tabs on android then I see a black screen with the android billing overlay on top still active and once I dismiss that one I get the expected OnPurchaseFailed event and can also see the game again.
However, if I come back to the app by clicking on the app icon then the android billing overlay is gone and no OnPurchaseFailed event is triggered. For our internal purchase tracking the purchase is still in a pending state …
For now we switched back to IAP 2.1.1 where everything works fine so far
Thanks for your patience @alexm_scp . We investigated this billing flow issue and unfortunately have no solution at this time.
We could be overlooking an opportunity to fix this behavior. I’m sharing our findings to-date, here in hopes this helps fix the issue ultimately. We plan to open a ticket with Google Support, and are also discussing internally whether there is a way we could configure AndroidManifest.xml differently although I feel that major change is a risky way to accommodate the needs of purchasing.
We reproduced the following behavior:
Using Google Play Billing Library v3.0.1
Launch app and initialize, connecting to Google Play billing
Initiate a purchase
See a Google Play Billing purchasing dialog
Navigate away from the app
Use the Android Launcher’s app-icon to resume the app (not the Task Switcher)
See no dialog, instead the original app. Receive no callback on the Google PurchasesUpdatedListener.
We reproduced it outside of Unity:
On a non-Made With Unity project, using a small Kotlin class (download Project and see file Android-Project/app/src/main/java/com/example/testinggooglebillingv3/MainActivity.kt)
Experimented with AndroidManifest.xml attribute changes: to the com.unity3d.player.UnityPlayerActivity’s android:alwaysRetainTaskState and android:allowTaskReparenting … we still need to research further whether there is a solution to be won through those attributes.
We explored a workaround hack, and rejected:
Detect a purchasing dialog being opened, and then handle the failure-state combination of:
app being resumed via Activity.onResume, presumably from the Android Launcher’s app-icon
REJECTED: a trivial rotation of the device generates Activity.onResume callbacks, cannot differentiate between normal player device rotation and this scenario
IAP versions 3.0.x are not available in Unity 2018.4.x. Do you plan to have compatibility for these Unity versions?
Or maybe we’ll have a new IAP version 2.2.8 fixing these kinds of errors?
Sorry no, we won’t be backporting to Unity 2018.4. We won’t have a 2.2.8 version, we are at version 3 now and above. The 3.0.2 release was a documentation release only, any bug fixes will be in the next release. No ETA but hopefully soon (generally a week or two)