Need to get this Cordova plugin working for Electron (or Browser) platforms: cordova-plugin-geolocation.
The iOS, & Android implementation work great, but windows is deprecated because it uses IE11. So we are porting our windows implementation to Electron platform. The other platforms (iOS, android & windows) all utilize native (platform) code to get this done that we do not have access too in Electron or Browser platforms.
All we need is Latitude & Longitude! We don't need maps, or any other data just those two numbers. Therefore we do not need Google Maps API KEY. (We do not need the google api key for the other platforms and we are not allowed to generate one for our existing product that already worked with out it). NOTE: google api key does solve our issue, but we are not allowed to use it for billing reasons.
In our web application we use the JavaScript navigator.geolocation.getCurrentPosition(callback);
prompting the user to allow location services and every thing works out great.
When we wrap (build) the existing web application in cordova/Electron this no longer works and we do not have native windows platform support. We have also found Electron documentation that suggests you have to have a Google Maps API KEY.
Cordova/Electron documentation: Cordova Electron application to retrieve Latitude & Longitude.
I have started to look at the following paths, but we are struggling to get them to work correctly inside electron and not positive Windows Store will allow it.
- https://github.com/NodeRT/NodeRT (JavaScript specific to Windows platfrom)
- https://github.com/tjanczuk/edge (JavaScript that allows you to execute C# code)
- https://github.com/transistorsoft/cordova-background-geolocation-lt/blob/master/src/browser/BackgroundGeolocationMock.js#L165 (Only mocks out a default/Fake location)
Does anyone have an example of an Electron or Cordova app invoking a windows native dll or code?
Versions we are using:
- cordova: 10.0.0
- cordova-electron: 3.0.0
- electron: 14.0.0
- electron-builder: 22.11.7
What version of cordova-electron are you using? With WebView2 (fork of Chromium I believe) on Windows, geo location should be built in like in the browser. I could be mistaken. Have you tried (capital G)
You can also inspect the webview and check out what version it is building the app with, and check what methods are available.