adaptyteam / AdaptySDK-Flutter

SDK for growing mobile in-app purchases
https://docs.adapty.io/docs/quickstart
MIT License
95 stars 17 forks source link

Crash when making purchases #56

Closed pyretttt closed 1 year ago

pyretttt commented 2 years ago

Environment: flutter: 3.0.5 iOS: 15.5

Adapty/Adapty.swift:369: Fatal error: [Adapty] In order to properly measure performance of the paywalls, you need to use products from paywalls. https://docs.adapty.io/docs/ios-displaying-products#showcase

Crashing on call: final result = await Adapty.makePurchase(product);

How manual purchase is related to paywalls? Is there a workaround?

pyretttt commented 2 years ago
Screen Shot 2022-08-30 at 20 59 35
x401om commented 2 years ago

Hi, @pyretttt! If you have created any paywall using our dashboard, then you have to use products from paywalls. Also you need to call logShowPaywall before making purchase. We had to add this check to make sure there were no errors in the analytics calculations. Speaking of workaround, you can try to remove the paywalls and use only products, although I don't think this approach is effective.

pyretttt commented 2 years ago

Yep thanks, but next it crashing on Adapty.swift:369 if hasPaywalls && product.variationId == nil { assertionFailure("[Adapty] In order to properly measure performance of the paywalls, you need to use products from paywalls. https://docs.adapty.io/docs/ios-displaying-products#showcase") }

x401om commented 2 years ago

You should pass the ProductModel object from the corresponding PaywallModel object (products property). In case you are using paywalls, you shouldn't use the raw products array.

pyretttt commented 2 years ago

Yep, I do it like that. I noticed that one day it crashed, but on next day it didn't. It seems danger and poorly designed. Because I hadn't even changed anything between this days, it just started to work properly. Won't it repeat on production? If it can - would you describe me, what is the reason product doesn't have variationId?

x401om commented 2 years ago

Asserts are designed to be executed in debug builds only. We have added this checks to be sure, developers makes everything in a right way at the development stage.

ch-muhammad-adil commented 2 years ago

It is working fine in release build, but yes crashed for me in debug build. Calling logShowPayWall has fixed it.