When creating a paywall with the Purchasely editor you can add multiple paywalls that get opened on top of each other. For example, if you have some different plan options and then when you select a plan you can select monthly or annual in a new paywall that is opened as another modal above the first paywall.
However, if you then need to close the the paywall at this point, to perform user login for example, then calling closePaywall only closes the top-most paywall (in my example above the one in which you select monthly or annual and not the primary paywall that presents each plan). Similarly, if you complete a purchase with multiple paywalls open, only the top-most will be dismissed after purchase leaving the user with the rest of the paywalls still open.
On iOS at least this issue seems to be caused by the fact that closePaywall dismisses the self.presentedPresentationViewController which is a reference to a single paywall (PLYProductViewController) and not the main UIViewController that Purchasely mounts when the calling UIViewController *ctrl = [Purchasely productControllerFor:] (PurchaselyRN.m:693). Actually, when this is called the ctrl is a reference to the PLYProductViewController and not the main UIViewController the Purchasely framework mounts - I think it should return the main view controller that is mounted in this case so that when closePaywall is called it does actually remove this main view controller, which will then remove any child PLYProductViewControllers in the process.
Workaround
For now as a workaround I have added the following patch which dismisses the self.presentedPresentationViewController.presentingViewController instead when closePaywall and when a successful purchase is triggered which dismisses the main view controller Purchasely has mounted.
Problem
When creating a paywall with the Purchasely editor you can add multiple paywalls that get opened on top of each other. For example, if you have some different plan options and then when you select a plan you can select monthly or annual in a new paywall that is opened as another modal above the first paywall.
However, if you then need to close the the paywall at this point, to perform user login for example, then calling
closePaywall
only closes the top-most paywall (in my example above the one in which you select monthly or annual and not the primary paywall that presents each plan). Similarly, if you complete a purchase with multiple paywalls open, only the top-most will be dismissed after purchase leaving the user with the rest of the paywalls still open.On iOS at least this issue seems to be caused by the fact that
closePaywall
dismisses theself.presentedPresentationViewController
which is a reference to a single paywall (PLYProductViewController
) and not the mainUIViewController
that Purchasely mounts when the callingUIViewController *ctrl = [Purchasely productControllerFor:]
(PurchaselyRN.m:693). Actually, when this is called thectrl
is a reference to thePLYProductViewController
and not the mainUIViewController
the Purchasely framework mounts - I think it should return the main view controller that is mounted in this case so that whenclosePaywall
is called it does actually remove this main view controller, which will then remove any child PLYProductViewControllers in the process.Workaround
For now as a workaround I have added the following patch which dismisses the
self.presentedPresentationViewController.presentingViewController
instead whenclosePaywall
and when a successful purchase is triggered which dismisses the main view controller Purchasely has mounted.react-native-purchasely+2.6.8.patch