logging the transaction count in paymentQueue:updatedTransactions and addTransactionObserver i found that
in the empty app i get 0 transactions in addTransactionObserver and then ios immediately fires a paymentQueue:updatedTransactions with the pending payment
in the main app i get 1 transaction already added in addTransactionObserver, so no event is fired
if I force the update, it is notified by unity after (more than?) a frame, so I cannot distinguish anymore the case “init complete, no purchases pending” from “init complete with x purchases pending”, so I have to change my app flow
Unity IAP adds a single transaction observer during initialisation and leaves it in place for the lifetime of the process.
If storekit is not notifying that transaction observer, as it appears from the log you sent, then that is an issue to take up with Apple. Unity IAP cannot add an additional transaction observer on the chance that storekit will send it transactions that it should already be receiving.
Is it possible that another plugin in your project would be adding a transaction observer? You mentioned previously that a transaction already exists when Unity IAP adds its transaction observer. SKPaymentQueue.transactions should be undefined until the first observer is added.
that what I was investigating right now. I do have native plugins in my project but some of them are compiled (.h + .a files) ant the ones for which I have the source do not add observers (except for reign native, which we used for wp8 before unityIAP and was the first thing I commented out and replaced with nslogs)
I managed to set a symbolic breakpoint in xcode for “-[SKPaymentQueue addTransactionObserver:]” and it hits before our splash screen, with this stack trace
It looks like the transaction observer is being added from a listener added to NSNotificationCenter. Can you set a breakpoint to try to catch what is adding the notification listener?
Alternatively you could binary search through your installed plugins until you find the one that’s adding it.
13 hits for -[NSNotificationCenter addObserverForName:object:queue:usingBlock:]
146 hits for -[NSNotificationCenter addObserver:selector:name:object:]
it seems almost every plugin I have does something with NSNotificationCenter
then I tried removing StoreKit and let the linker complain…
(found a rogue Prime31 static constructor doing an extern call into it’s libStoreKit.a but I don’t reference it anymore and nothing changed when i commented out that line of code - I put a log in there to be sure, it doesn’t get called)
can’t do that because they are too much entangled with our code - we were unable to completely remove Prime31 and Reign from the project because it was a mess to refactor (for P31, we still use its “static OnActivityResult” on Android, and Reign is here for WP8 Facebook integration)
I was hoping for a way to scan the various .a for references to SKPaymentQueue calls…
I think it’s Facebook. I removed Facebook from our app and successfully got notified of a pending purchase on app restart.
If you’re on SDK 3.22 or higher, it’s set to automatically log IAP (https://developers.facebook.com/docs/app-events/ios/#purchase), though it’s not clear if you need to explicitly call ActivateApp() or if it’s done automatically for you on iOS. I guess to do the logging, they’re adding a listener, and it’s either because they don’t do it on Android, or the fact that iOS needs a password to restore transactions which lets them get in there first.
I’m trying a build right now where IAP logging is turned off in the developers.facebook.com settings to see if that makes a difference, or if I need to jump into the code to stop the ActivateApp() call
Can confirm that turning off the automatic in-app purchasing on Facebook settings (developers.facebook.com > App > Settings > Basic > iOS > iOS Only: Log In-App Purchase Events Automatically (Recommended)) unblocks unity purchasing notifications. ActivateApp() is called automatically on iOS.
( @M_R - we’re not using AdMob - FB is pretty much the only plugin, aside from iOS Native)
As to when this change propagates to Unity, I’m not sure. After it worked, I reset logging of purchase events through the site, and it continued to work, so I’m not sure if it’s order issue (including Unity IAP before Facebook), or a cache issue (FB hadn’t propagated the re-change back), etc. At this point, after a week of sitting through half hour builds, I don’t really care
I have issue with “This In-App purchase has already been bought. It will be restore for free”.
If I buy some consumable product, then verify, but not consume (with ConfirmPendingPurchase), and after that, again try to buy the same product, I have this message, and no any callback is called.
This is problem, because I disable all buttons and dont have any callback to enable it.