Question

I am using multiple in-app purchases within my app, and I need to check, sometimes for two at once, for example, if a user has made a purchase for featureA or featureB or featureC

or perhaps they have made A & B but not C... for example;

if ([MKStoreManager featureAPurchased] && [MKStoreManager featureCPurchased] ) {

        bannerView_.hidden = YES;

What I am trying to do is say "if you have purchased feature A OR feature C then bannerView will be hidden. I know how to do it for just one (ie featureA) but if I am trying to check for if BOTH those features have been purchased, that is where I am struggling.

I guess I am doing it wrong, as it does not appear to work correctly? I am probably muddling up the statement using &&?

Was it helpful?

Solution

&& is the operator used for saying 'and'. If you want to say 'or', use ||.

So, you want

if ([MKStoreManager featureAPurchased] || [MKStoreManager featureCPurchased] ) {

bannerView_.hidden = YES;

OTHER TIPS

How are you checking that the user has purchased something? The usual way to check this is either have this information persisted in the app (User Defaults or database) or asking App store with -[SKPaymentQueue restoreCompletedTransactions]. Restoring transactions gives you information about all available products purchased for the user in your app, so this should give you enough to accomplish what you want

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top