I want to develop an Chrome Extension which would be compatible with Manifest Version 3, but I run into problem with getting current user's geolocation coordinates, which works with Manifest Version 2, but for Manifest Version 3 it throws that navigator.geolocation is undefined.
Here are my manifest.json and background.js files:
manifest.json:
"name": "Chrome Extension MV3",
"description": "Learning all about Chrome Extensions Manifest Version 3!",
"version": "0.1.0",
"manifest_version": 2,
"background": {
"service_worker": "background.js"
},
"permissions": ["geolocation"]
}
background.js:
navigator.geolocation.getCurrentPosition((position) => {
const { latitude, longitude } = position.coords;
console.log(latitude, longitude);
});