en:products:comfortel-d-series:developer:luaapi:examples:minibrowser_auto_launch

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
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <luaAutoStarters>
  3. <luaScript name="MinibrowserTrigger">
  4. <code><![CDATA[
  5. function onTriggered(url, body, headers, vars)
  6. debug.log(url, "d")
  7. local query = vars.query_map
  8. local mbUri = query.url
  9. if mbUri == nil or #mbUri == 0 then
  10. return 400, "missing url=... -> nothing to open minibrowser with"
  11. end
  12. system.intent{action="android.intent.action.VIEW", component="de.auerswald.minibrowser/.LoadingActivity", data=mbUri}
  13. return 200, "started minibrowser to load " .. mbUri
  14. end
  15.  
  16. function listenForMinibrowserTrigger()
  17. mCommandListener = http.listen("listenForMinibrowserTrigger", onTriggered, true)
  18. debug.log("listening for commands on https://" .. getIp() .. "/api/v1/exec/listenForMinibrowserTrigger?url=...")
  19. end
  20.  
  21. function getIp()
  22. local ips = phoneInfo.getIPs()
  23. if #ips > 0 then
  24. return ips[1]
  25. end
  26. return "[phoneIp]"
  27. end
  28.  
  29. listenForMinibrowserTrigger()
  30. --]]></code>
  31. </luaScript>
  32. </luaAutoStarters>
  • en/products/comfortel-d-series/developer/luaapi/examples/minibrowser_auto_launch.txt
  • Last modified: 09.05.2022 12:43
  • by neubauers