MinibrowserTrigger
Listen for incoming requests to
https://[phone-ip]/api/v1/exec/listenForMinibrowserTrigger?url=XYZ
-> causes to open MiniBrowser with provided XYZ-url.
start_webpage_template.xml |
---|
| <?xml version="1.0" encoding="UTF-8"?>
<luaAutoStarters>
<luaScript name="MinibrowserTrigger">
<code>
<![CDATA[
function onTriggered(url, body, headers, vars)
debug.log(url, "d")
local query = vars.query_map
local mbUri = query.url
if mbUri == nil or #mbUri == 0 then
return 400, "missing url=... -> nothing to open minibrowser with"
end
system.intent{action="android.intent.action.VIEW", component="de.auerswald.minibrowser/.LoadingActivity", data=mbUri}
return 200, "started minibrowser to load " .. mbUri
end
function listenForMinibrowserTrigger()
mCommandListener = http.listen("listenForMinibrowserTrigger", onTriggered, true)
debug.log("listening for commands on https://" .. getIp() .. "/api/v1/exec/listenForMinibrowserTrigger?url=...")
end
function getIp()
local ips = phoneInfo.getIPs()
if #ips > 0 then
return ips[1]
end
return "[phoneIp]"
end
listenForMinibrowserTrigger()]]>
</code>
</luaScript>
</luaAutoStarters>
|