[Solved] SDKBOX IAP v2.2.1.6 iOS

Hi,

I only using SDKBOX IAP with Cocos2d-JS v3.8.1.

Crash happen in PluginIAPJSHelper.cpp

void callback(float dt) {
    if (!s_cx) {
        return;
    }

    JSContext* cx = s_cx;
    const char* func_name = _eventName.data();

    JS::RootedObject obj(cx, _jsHandler);
    JSAutoCompartment ac(cx, obj); <-- crash on this line

I setup IAP with a global function in a scene1. Crash happen when changing scene from scene2 to scene1.
However, the crash is not always.

function setupIAP()
{
sdkbox.IAP.init();

sdkbox.IAP.setListener(
{
	onSuccess : function (product) 
	{
	},
	onFailure : function (product, msg)
	{
	},
	onCanceled : function (product)
	{
	},
	onRestored : function (product)
	{
	},
	onProductRequestSuccess : function (products) 
	{
	},
	onProductRequestFailure : function (msg)
	{
	}
});
sdkbox.IAP.refresh();

}

Any idea on the crash?

Thank you.

I found out that it is my own function caused crash that called in the IAP listener callback.

Hi @Zinitter ,

Can you share your problem, I’m dealing with same error but haven’t found out mine

@trungnt85

My problem is not related to SDKBOX, is caused by incomplete own function.

sdkbox.IAP.setListener(
{
	onSuccess : function (product) 
	{
             CallIncompleteOwnFunction();<-- this crash
	},
	onFailure : function (product, msg)
	{
	},
	onCanceled : function (product)
	{
	},
	onRestored : function (product)
	{
	},
	onProductRequestSuccess : function (products) 
	{
	},
	onProductRequestFailure : function (msg)
	{
	}
});

@Zinitter

Thank you, I checked my problem, the crash happens with iOS 10 but works fine on iOS 9. Need to dive into it