I’m trying to use the webview but I have this error:
attempt to index global ‘webview’ (a null value)
I want to know do I need to do something for the webview to be recognized by the defold mechanism? I just added the dependency and from what I understand it doesn’t recognize this function.
Yes, I did. last time I had to put something before it was a web socket library.
My code to eliminate doubts:
function init(self)
msg.post(".", "acquire_input_focus")
msg.post("@render:", "use_fixed_fit_projection", { near = -1, far = 1 })
end
local player_feedback_url = "http://www.defold.com"
local function webview_callback(self, webview_id, request_id, type, data)
if type == webview.CALLBACK_RESULT_URL_ERROR then
-- An error occurred!
-- Let's close the webview and set a label with some helpful text!
webview.destroy(webview_id)
label.set_text("#label", "Player feedback not available at this moment.")
elseif type == webview.CALLBACK_RESULT_URL_LOADING then
-- Make sure the player isn't navigating away from the feedback URL.
if data.url ~= player_feedback_url then
return false
end
end
end
local feedback_webview = webview.create(webview_callback)
webview.open(feedback_webview, player_feedback_url)
webview.set_visible(feedback_webview, 1)
webview.set_position(feedback_webview, 0, 0, -1, 500)
the webview worked on android after i put it inside init it worked with open_raw and with open. had a part of the code returned false remove and opened the open. Thanks to everyone who responded.
Yeah, basically all your script logic need to be called from the lifecycle functions such as init, update etc. Especially code which uses code from extensions or the Defold API functions.