Hello, could someone kindly explain why we should check entitlements.all isActive after a purchase before unlocking the feature (see code below) ? My points are:
- If purchasePackage() didn’t fail, it means that the purchase was processed successfully and this should be enough to unlock the features associated to the purchase.
- Checking isActive of Entitlements doesn’t make sense in the case where Entitlement has several consumable products (ie. boost_1, boost_2, boost_3) which can be purchased multiple times (so for example , user might have 3 active boost_1, 1 active boost_2, 5 active boost_3, etc). In that case, using customerInfo.entitlements.all["my_entitlement_identifier"].isActive might lead even to wrong outcome. Am I missing something?
try {
CustomerInfo customerInfo = await Purchases.purchasePackage(package);
if (customerInfo.entitlements.all["my_entitlement_identifier"].isActive) {
// Unlock that great "pro" content
}
} on PlatformException catch (e) {
var errorCode = PurchasesErrorHelper.getErrorCode(e);
if (errorCode != PurchasesErrorCode.purchaseCancelledError) {
showError(e);
}
}