raidho36 wrote:Is there a reason it's not a dynamically loaded library and a FFI wrapper? I don't feel like using a whole custom build just to get this one orthogonal feature.
Doing IAP requires the use of native Apple APIs and frameworks, and I don't know whether it would be possible to access those through FFI (granted, I don't have any experience with FFI). I went with the source code modification, as it was the simplest approach for me. Also, if you're planning to distribute a game on the app store, you'll need to do a custom build anyway to fuse the game and change all of the game-specific options like the app icon, etc.
zorg wrote:I don't think hanging is a good idea, since no feedback (or rather, my app is hanging feedback) is a pretty bad design choice in my opinion.
It's how love.window.showMessageBox() works. The lua code hangs on the line where showMessageBox() was called until the user selects one of the options, at which point the lua function returns the result and code execution resumes there. For purchasing, I could easily see it working the same way, except with an extra step that after the user confirms the purchase and enters their credentials, it shows another dialog box saying "completing purchase..." with a "cancel" button the user could press to abort the process. Then, the lua function would return the result of the purchasing attempt (e.g. "success", "canceled", "failed"). The way my code works now, it calls the Apple API to open up the purchasing dialog, and then the lua code immediately continues running in the background while the dialog box is still open, which is a bit wonky.
zorg wrote:Still, it would mean that it would need a network handling loop embedded, which may cause some concern...
So, behind the scenes, Apple is already doing the networking async callback stuff anyway, using
SKPaymentTransactionObserver. In theory, it should be possible to insert a "love.purchase" event into the SDL event queue once the app gets the transaction callback. Right now, the way I'm implementing it is by updating NSUserDefaults to store which purchases have been made when the Objective C callback is called, and querying NSUserDefaults when the user calls love.system.hasPurchase(). I opted to not go with the SDL event queue option because it adds a lot of complexity to the code if the Objective C callback has to have access to the SDL event queue (and deal with the concurrency issues there).