saturngod / IAPHelper

No more maintenance for this repo. Please use the https://github.com/bizz84/SwiftyStoreKit
MIT License
1.55k stars 280 forks source link

IAPHelper Not handling transactions at application launch? #34

Open phasedarray opened 8 years ago

phasedarray commented 8 years ago

@saturngod From the Apple's document In-App Purchase Best Practices https://developer.apple.com/library/ios/technotes/tn2387/_index.html

Transaction observer SHOULD be added to SKPaymentQueue at application launch, the reason is that some transaction may be still in purchasing status when user closes the app. But IAPHelper doesn't initialise it self at launch. Moreover buyProductCompleteBlock in IAPHelper isn't initialised until buyProduct:onCompletion: or restoreProductsWithCompletion: is invoked. So the updatedTransactions will be lost before any purchase or restore if user relaunches the app.

Am i correct?

saturngod commented 8 years ago

yes, it's correct. That why , I use addTransactionObserver at object allocate and removeTransactionObserver at dealloc of IAPHelper class.

phasedarray commented 8 years ago

but at that time, _buyProductCompleteBlock is still nil, customer code can't get any notification or callback.