Hi,
I generated a testapp with framework7 --ui and included the cordova-plugin-geolocation
using the command line “framework7 cordova plugin add cordova-plugin-geolocation”.
In the deviceRedy event I ask to show my GPS postion. Here my app.js file.
Opening the app in my android phone I get first the GPS permission request and then the alert: “code:2 message: application does not have sufficient geolocation permissions.” but no error in the console.
Opening the app a second time I get the alert with the coordinate of my position but the following error on the console.
Did I miss something in the installation?
Thanks in advance for any support
app.js:
indent preformatted text by 4 spaces
import $ from ‘dom7’;
import Framework7, { getDevice } from ‘framework7/bundle’;
import ‘leaflet/dist/leaflet.css’;
import ‘leaflet-defaulticon-compatibility/dist/leaflet-defaulticon-compatibility.webpack.css’; // Re-uses images from ~leaflet package
import * as L from ‘leaflet’;
import ‘leaflet-defaulticon-compatibility’;
// Import F7 Styles
import ‘framework7/framework7-bundle.css’;
// Import Icons and App Custom Styles
import ‘…/css/icons.css’;
import ‘…/css/app.css’;
// Import Cordova APIs
import cordovaApp from ‘./cordova-app.js’;
// Import Routes
import routes from ‘./routes.js’;
// Import Geo
import geo from ‘./geo.js’;
// Import main app component
import App from ‘…/app.f7.html’;
var device = getDevice();
var app = new Framework7({
name: ‘Cordova0’, // App name
theme: ‘auto’, // Automatic theme detection
el: ‘#app’, // App root element
component: App, // App main component
id: ‘io.framework7.myapp’, // App bundle ID
// App routes
routes: routes,
// Input settings
input: {
scrollIntoViewOnFocus: device.cordova && !device.electron,
scrollIntoViewCentered: device.cordova && !device.electron,
},
// Cordova Statusbar settings
statusbar: {
iosOverlaysWebView: true,
androidOverlaysWebView: false,
},
on: {
init: function () {
var f7 = this;
if (f7.device.cordova) {
// Init cordova APIs (see cordova-app.js)
cordovaApp.init(f7);
}
},
},
});
document.addEventListener(“deviceready”, onDeviceReady, false);
function onDeviceReady() {
console.log("navigator.geolocation works well");
//navigator.geolocation.getCurrentPosition(onSuccess, onError);
var watchID = navigator.geolocation.watchPosition(onSuccess, onError, { timeout: 30000 });
// onSuccess Callback
// This method accepts a Position object, which contains the
// current GPS coordinates
//
var onSuccess = function (position) {
alert('Latitude: ’ + position.coords.latitude + ‘\n’ +
'Longitude: ’ + position.coords.longitude + ‘\n’ +
'Altitude: ’ + position.coords.altitude + ‘\n’ +
'Accuracy: ’ + position.coords.accuracy + ‘\n’ +
'Altitude Accuracy: ’ + position.coords.altitudeAccuracy + ‘\n’ +
'Heading: ’ + position.coords.heading + ‘\n’ +
'Speed: ’ + position.coords.speed + ‘\n’ +
'Timestamp: ’ + position.timestamp + ‘\n’);
};
// onError Callback receives a PositionError object
//
function onError(error) {
alert('code: ’ + error.code + ‘\n’ +
'message: ’ + error.message + ‘\n’);
}
navigator.geolocation.getCurrentPosition(onSuccess, onError);
}
Blockquote