• Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Register
  • Login
UBports Robot Logo UBports Forum
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Register
  • Login

QtWebEngine location access

Scheduled Pinned Locked Moved App Development
5 Posts 2 Posters 676 Views 1 Watching
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • G Offline
      Giiba
      last edited by 10 Jun 2019, 16:44

      Is there some trick to enabling location access for a webapp using the QtWebEngine?

      I'm just experimenting, using Sailbook as a template, with using google maps urls. The page loads and looks good but it simply doesn't have location access; there is no prompt from the webengine or OS, and the webpage just says it cannot determine location.

      I've adjusted the apparmor settings and added QtLocation and QtPositioning imports to the qml files. However all I can find is tutorials for using the mapping features of Qt and none that speak to finding current location.

      Anyone know of a tutorial or the right documentation?

      1 Reply Last reply Reply Quote 1
      • D Offline
        dobey
        last edited by 10 Jun 2019, 17:28

        Is the code not using Morph.Web API to embed the engine? Although I think QtWebEngine itself should already be using the proper API for asking location access from Qt. Otherwise it may just be that you're missing the extra dialog implementation if you're embedding QtWebEngine itself instead of Morph.Web.

        I don't think you should need to use QtLocation or QtPositioning at all yourself, for a web page to get it. As long as the apparmor json is correct, it should work (and remember, if you change the apparmor, you need to change the version so the profile gets rebuilt when installing the app).

        G 1 Reply Last reply 10 Jun 2019, 17:45 Reply Quote 1
        • G Offline
          Giiba @dobey
          last edited by 10 Jun 2019, 17:45

          @dobey
          I didn't know about the version thing thx. However that's not the trouble it seems. Perhaps I should find a clean template to work from.

          1 Reply Last reply Reply Quote 0
          • G Offline
            Giiba
            last edited by Giiba 6 Oct 2019, 17:50 10 Jun 2019, 17:49

            Looking closer there is no embedded webengine just imports in main.qml. But it does do:

            import Morph.Web 0.1
            import QtWebEngine 1.7
            

            so I have to admit I don't really know what is going on, I'm going to look for a clean template.

            1 Reply Last reply Reply Quote 0
            • G Offline
              Giiba
              last edited by Giiba 14 Jun 2019, 03:18

              @dobey you were correct, the location call was just being ignored. Adding the necessary lines enabled access for the webapp. Thanks for the direction.

              I copied this from the Morph browser code:

              onFeaturePermissionRequested: {
                  switch(feature) {
                      case WebEngineView.Geolocation:
                      grantFeaturePermission(securityOrigin, feature, true);
                      break;
                  }
              }
              

              there is of course cases for other feature requests in the code I copied, and this just grants permission passing responsibility for approving the call to the OS. This does work around the issue where Morph asks permission each and everytime location is called, without the trouble of approving different sites as there is only one.

              1 Reply Last reply Reply Quote 0
              1 out of 5
              • First post
                1/5
                Last post