Is it normal when you submit an In-App Purchase, that it causes applicationWillResignActive while it asks you if you want to BUY?
For example:
[[SKPaymentQueue defaultQueue] addPayment:payment];
This causes app to resign active and then once you hit BUY or CANCEL and then applicationWillEnterForeground is called.
Is there a way to know that it was an in app purchase that caused the application to resign so that when it enters foreground again, I can flag some things to be skipped?
Thanks
Ok, this is what I am going to do since I cannot think of any other way of doing it...
When an application starts up fresh it calls application:didFinishLaunchingWithOptions, and when it starts from the background it calls applicationWillEnterForeground. In both these two cases, it then always calls applicationDidBecomeActive, which is where I have the code that I want to skip when an IAP occurs.
When an application shuts down or moves to the background it always calls applicationWillResignActive and then applicationDidEnterBackground.
What I noticed is that an IAP calls applicationWillResignActive and then applicationDidBecomeActive and nothing else.
So in application:didFinishLaunchingWithOptions I will set a variable startupDidFinish=1
And in applicationWillEnterForeground I will set a variable startupForeground=1
In applicationDidBecomeActive I will do this:
//SKIP if application resigned active then becomes active again.
if (startupDidFinish == 1 || startupForeground==1) {
//Do normal startup stuff
}
startupDidFinish = 0;
startupForeground = 0;
So this will allow you to skip code for things like IAP (and I think also an SMS acts the same way).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With