extension-admob
extension-admob copied to clipboard
Added optional `userId` and `customData` support for rewarded AD
This currently supports android devices only. Any help from moderators is welcomed.
Looks good.
This currently supports android devices only
iOS documentation: https://developers.google.com/admob/ios/rewarded#validate-ssv
Adding support for userId is breaking as load_rewarded expects userId to be passed as argument.
Adding support for
userIdis breaking asload_rewardedexpects userId to be passed as argument.
You're right. It would be better to either have userId and customData as optional extra arguments or provide them in an options table:
local options = {
user_id = "user_id",
custom_data = "my custom data",
}
admob.show_rewarded("unit_id", options)
The below change should be enough to treat the values as optional:
static int Lua_LoadRewarded(lua_State* L)
{
DM_LUA_STACK_CHECK(L, 0);
if (lua_type(L, 1) != LUA_TSTRING) {
return DM_LUA_ERROR("Expected string, got %s. Wrong type for Rewarded UnitId variable '%s'.", luaL_typename(L, 1), lua_tostring(L, 1));
}
const char* unitId_lua = luaL_checkstring(L, 1);
char* userId_lua = 0;
if (lua_gettop(L) > 1)
{
userId_lua = luaL_checkstring(L, 2);
}
char* customData_lua = 0;
if (lua_gettop(L) > 2)
{
customData_lua = luaL_checkstring(L, 3);
}
LoadRewarded(unitId_lua, userId_lua, customData_lua);
return 0;
}
Thanks! Could you please also update the script_api:
https://github.com/defold/extension-admob/blob/master/extension-admob/api/admob.script_api