j3k0 / cordova-plugin-purchase

In-App Purchase for Cordova on iOS, Android and Windows
https://purchase.cordova.fovea.cc
1.29k stars 529 forks source link

Initiating the purchase flow intercepts onActivityResult calls from Capacitor plugins #1549

Open masimplo opened 1 month ago

masimplo commented 1 month ago

I am using this plugin (version 13.10.1) in a capacitor project (version 5.7.3) along other capacitor plugins. For this issue report I will focus on the official Share plugin that utilizes the startActivityForResult and onActivityResult mechanism (but the same is happening to many others).

Observed behavior

Issue is that after initiating the purchase flow the plugin intercepts any onActivityResult calls from other plugins for their first call.

So when I initiate the purchase flow and dismiss the payment sheet, either by buying a product or closing it (the onActivityResult is not called), and then calling a capacitor plugin (the Share plugin in this case) that utilizes startActivityForResult and onActivityResult, the capacitor plugin never gets to return its payload back to the app as this plugin has set the activityResultCallback property to capacitor bridge.java and thus captures the result.

Here is a video demonstrating the issue and the flow: https://www.youtube.com/watch?v=SRxTy1jfD84

Notice that Share plugin onActivityResult works as expected at first, but then after invoking the purchase flow of this plugin, the share plugin onActivityResult is not invoked anymore.

Expected behavior

System Info

Output of cordova info.