Purchasely / Purchasely-ReactNative

Other
13 stars 2 forks source link

Try to present PLYProductViewController causes crash #50

Closed Geoffrey63 closed 1 year ago

Geoffrey63 commented 1 year ago

On version 2.6.8, I encounter the following crash when I press the purchase button in some conditions :

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Application tried to present modally a view controller <Purchasely.PLYProductViewController: 0x7fb5d80db400> that is already being presented by <UIViewController: 0x7fb5edf38140>.'

Crash occurs when i call the onProcessAction in the paywalInterceptorCallback :

Purchasely.setPaywallActionInterceptorCallback(result => {
  switch (result.action) {
    case PLYPaywallAction.LOGIN:
    case PLYPaywallAction.PURCHASE:
    case PLYPaywallAction.RESTORE: {

      if (!isUserAuthenticated) {
        ...
      } else {
        setupUserAccount()
          .then(userAccount => {
            Purchasely.onProcessAction(true); // <--- This causes the crash 💥 
          })
          .catch(error => {
            ...
          });
      }
      break;
    }
    case PLYPaywallAction.CLOSE:
      ...
      break;
    ...
  }
});

The same code works fine on 2.6.6 version.

mlanoy1 commented 1 year ago

Hello @Geoffrey63, Does your paywall have a flow? I mean, does a paywall opens another paywall before purchasing something? This issue happens in those cases. we've fixed it and will be available in our next release.

Geoffrey63 commented 1 year ago

Hello, our paywall doesn't open another paywall but it opens a modal webview for the user login. Once user is logged in, calling the onProcessAction causes the crash.

mlanoy1 commented 1 year ago

Did you close your webview before calling onProcessAction?

Geoffrey63 commented 1 year ago

Yes, the webview is closed when the onProcessAction is called.

mlanoy1 commented 1 year ago

Does the paywall has been closed before displaying your webview? You should try to call closePaywall() before displaying your webview.

Geoffrey63 commented 1 year ago

I tried to close the Paywall but i've still have a crash.

The use case is the following :

mlanoy1 commented 1 year ago

It has been fixed.Available in next release

Geoffrey63 commented 1 year ago

Great, thank you @mlanoy1 🙏🏻