Avoid Interstitial to show if the App is Purchased through App Store App
You are not notified of an inApp in the App Store before paymentQueue:shouldAddStorePayment:forProduct:
. Also, no inApp popup occurs unless your app presents one in paymentQueue:updatedTransactions:
.
This is the best thing I can suggest for you:
I'm assuming that you don't put up an interstitial ad immediately upon your app starting - that wouldn't be a very good user experience. So you just have to keep an ad from displaying between the time you know the user bought something and the time you process that transaction.
- So then, you can have a global variable
BOOL doAllowIntAd
which defaults toYES
. To find out if the user bought an inApp in the App Store, very early in
application:(UIApplication *)application didFinishLaunchingWithOptions:
, you call[[SKPaymentQueue defaultQueue] addTransactionObserver:yourTransactionObserver];
so that your observer is set up to receive the inApp from the App Store. This is the very first thing I do indidFinishLaunchingWithOptions:
.When
paymentQueue:shouldAddStorePayment:forProduct:
onyourTransactionObserver
gets called, before returningYES
, setdoAllowIntAd = NO
to keep the ad from displaying.When StoreKit calls
paymentQueue:updatedTransactions:
onyourTransactionObserver
with the inApp from the App Store, you process it the same way you would process a purchase made within your app. For example, fortransaction.transactionState==SKPaymentTransactionStatePurchased
, simply adddoAllowIntAd = YES
after the transaction has been processed, content enabled, and[yourSKPaymentQueue finishTransaction:]
has been called, to allow the interstitial ad to be displayed again. Of course, you should re-enabledoAllowIntAd
not just forSKPaymentTransactionStatePurchased
, but for some othertransactionState
as well. But you may decide to leave the ad disabled in the case the transaction is deferred, for example.
Thus if there is any delay between 3 & 4, your ad won't display during that time. You can experiment to see whether there is any delay in practice.