How to send event to Lua from iOS without having the current lua_State* L

Hi,

I came across an issue of passing an event to Lua from native iOS callbacks.
such as purchase completed or purchase error from Storekit.

i would like to have a function like below:

-(void) Purchased {

lua_State* L =  get the current L which I could use from native level.
// lua_State* L = luaL_newstate();

PluginLibrary *library = PluginLibrary::ToLibrary( L );

CoronaLuaNewEvent( L, PluginLibrary::kEvent );
lua_pushstring( L, "purchased" );
lua_setfield( L, -2, "event" );

// Dispatch event to library listener
CoronaLuaDispatchEvent( L, library->GetListener(), 0 );

}

I’ve tried luaL_newstate() or stored the previously lua_State where I’ve got called from Lua, but they all return bad access here. what would be the best way of doing it?

Can I call lua without having the lua_state, or how do I get the correct state when passing event to lua

Thx

Are those related?

There are several ways you can do this. Take a look how the iTunes plugin does it for instance: https://github.com/coronalabs/plugins-source-itunes/blob/master/ios/Plugin/iTunesLibrary.mm