Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat | DONATE
iOS purchase through Hot Wax — Gideros Forum

iOS purchase through Hot Wax

zimarriozimarrio Member
edited March 2015 in General questions
Hi,
I'm trying to implement in app purchases in iOS using Hot Wax by Bowerhaus but I'm struggling with callbacks from objective c to lua.
Here is a sample code of what I'm trying to do.
waxClass({"Buyer", NSObject, protocols = {"SKProductsRequestDelegate"}})
 
function init()
	return self
end
 
function buy()
	print("start buy")
 
	local setProduct = NSSet:setWithObject("myProductId")
 
	local productsRequest = SKProductsRequest:initWithProductIdentifiers(setProduct)
	productsRequest:setDelegate(self)
	productsRequest:start()
 
	print("end buy")
end
 
 
function productsRequest_didReceiveResponse(request, response)
	print("callback")
end
 
buyer = Buyer:new()
buyer:buy()
It prints "start buy", "end buy" but never enters productsRequest_didReceiveResponse. It throws an exception with EXC_BAD_ACCESS in wax_fromInstance.

Any clue about what I'm doing wrong?
Thanks in advance.

Comments

  • @zimarrio,
    Are you sure that SKProducts is added and available? Check if the productsRequest is nil or an actual table value (i.e. valid result).

    I think you need to include the required libraries and recompile to include them. To me it seems that the functionality you are wanting is not available and hence the errors.
    twitter: @ozapps | http://www.oz-apps.com | http://howto.oz-apps.com | http://reviewme.oz-apps.com
    Author of Learn Lua for iOS Game Development from Apress ( http://www.apress.com/9781430246626 )
    Cool Vizify Profile at https://www.vizify.com/oz-apps
  • @OZApps thanks for your help.
    If I put these methods on the xcode side and call it like this:
    getRootViewController():buy("myProductId")
    The callback is called and the purchase popup appears. So it means that the product is available.
    The problem is that I can't figure out how to get back to Lua after the callback. If I can do it, I don't mind having all the code on the objective c side. I just need a way to get back to Lua to update the purchase status.
  • Is there an easier way to call a Lua function in Gideros from objective c?
    In Android the JVBrigde works like a charm. I have complete control both ways.
Sign In or Register to comment.