[x] A description about what and why you are contributing, even if it's trivial.
This PR adds two API improvements:
Purchases Listener is currently an abstract MonoBehaviour, which ties the behaviour to Unity components. This is not bad, but it does limit you, which is entirely not needed, if you mostly use the API from code. There's no other requirement that this should in fact be an abstract class (aside from the ability to set it in Editor). So a new interface is introduced instead and backwards support is added, so that the UpdatedCustomerInfoListener implements the interface. Field is now set as private and serialized, so it can remain set in Editor, but via code Listener property should be used.
The whole Purchases object which is required for RevenueCat to operate initializes itself fairly late in Start function. This is a problem, if you need to do anything beforehand as we're booting our game up in Awake method. The script order is usually undefined and we've seen many differences in it between real devices and Editor, so sometimes Purchases would prepare itself for API type of configuration, sometimes we would be too early calling Configure and crash with NullPointerException on internal _wrapper. To get around this problem, we extracted initialization of wrapper to a separate function that only creates the instances once, but can be called many times. That way Configure will Prepare the wrapper, before it calls to it's Setup method.
[x] The issue number(s) or PR number(s) in the description if you are contributing in response to those.
No open issues right now for these improvements.
[x] If applicable, unit tests.
No additional Unit Tests required.
This PR adds two API improvements:
Purchases Listener is currently an abstract
MonoBehaviour
, which ties the behaviour to Unity components. This is not bad, but it does limit you, which is entirely not needed, if you mostly use the API from code. There's no other requirement that this should in fact be an abstract class (aside from the ability to set it in Editor). So a new interface is introduced instead and backwards support is added, so that theUpdatedCustomerInfoListener
implements the interface. Field is now set as private and serialized, so it can remain set in Editor, but via codeListener
property should be used.The whole
Purchases
object which is required for RevenueCat to operate initializes itself fairly late inStart
function. This is a problem, if you need to do anything beforehand as we're booting our game up inAwake
method. The script order is usually undefined and we've seen many differences in it between real devices and Editor, so sometimesPurchases
would prepare itself for API type of configuration, sometimes we would be too early callingConfigure
and crash withNullPointerException
on internal_wrapper
. To get around this problem, we extracted initialization of wrapper to a separate function that only creates the instances once, but can be called many times. That wayConfigure
willPrepare
the wrapper, before it calls to it'sSetup
method.[x] The issue number(s) or PR number(s) in the description if you are contributing in response to those. No open issues right now for these improvements.
[x] If applicable, unit tests. No additional Unit Tests required.