Always Seek Permission for Geolocation in Cordova

Is there a way in PhoneGap to update the Geolocation plugin's permissions from "while in use" to "always" without manually editing the .plist file? I noticed that changing the NSLocationAlwaysUsageDescription key in the project's config.xml sets the correct permission, but how can I accomplish this through the JavaScript API of the plugin?

Reference: https://github.com/apache/cordova-plugin-geolocation/blob/master/src/ios/CDVLocation.m#L130

Answer №1

To locate the ios.json file on the platform, navigate to platform/ios/ios.json Identify the following:

 "*-Info.plist": {
                    "parents": {
                        "NSLocationWhenInUseUsageDescription": [
                            {
                                "xml": "<string />",
                                "count": 1
                            }
                        ]
                    }
                }

Then, substitute "NSLocationWhenInUseUsageDescription" with "NSLocationAlwaysUsageDescription" This will result in the updated code:

"*-Info.plist": {
            "parents": {
                "NSLocationAlwaysUsageDescription": [
                    {
                        "xml": "<string />",
                        "count": 1
                    }
                ]
            }
        }

Execute the command "cordova build ios"

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Using AngularJS: Implementing ng-include with a custom function

When using ng-include, I have encountered a peculiar issue. I am attempting to retrieve the template path by invoking a function defined in the controller that returns the path based on the parameter passed. Below is my code snippet: <tr ng-repeat="det ...

Angular 2: Dealing with NaN values from Snapshot Parameters and Services

I am facing difficulties in transferring parameters from one component to another using Angular2 router and activated route. Here is my API Service: getModels(makeNiceName: string): Observable<Models> { return this.http.get(this.baseURL + mak ...

What is the process for implementing a dynamically generated template in a Vue.js instance?

Using a static template with a Vue.js instance is straightforward. The firstPlaceholder content gets replaced by the staticTemplate, and the text property renders correctly. However, creating a dynamic template poses rendering issues. The secondPlaceholde ...

Display outcomes for chosen checkboxes

When I call the API: $url = 'https://plapi.ecomexpress.in/track_me/api/mawbd/?awb=awbnumber&order=' . $orderrecords[$k]["order_id"] . '&username=admin&password=admin123';, I retrieve the status results of all Order IDs and d ...

Unable to locate the root element for mounting the component in Cypress with React

I am currently testing my react app, which was created using create-react-app, with the help of cypress. Unfortunately, I encountered an error that looks like this: https://i.stack.imgur.com/xlwbo.png The error seems to be related to trying to fetch an ...

Displaying an error page instead of the error message when a backend or template engine error occurs

Whenever a template engine error occurs, it is displayed on the webpage. I am looking to implement a functionality where if our server is running in production mode, an error page will be shown instead of displaying our server's error directly. The m ...

Navigating through the content of slots within recurring slots in a subcomponent in Vue.js

I am encountering an issue with a child component, where each row in an object is rendered inside a div with a specific slot. I need to pass data from the parent for each of these elements. I've been attempting to iterate through every element of the ...

Exploring iBeacon information: decoding the strength field and additional data bytes

I'm fairly new to the Bluetooth system and I'm currently trying to wrap my head around the data used for Apple's latest technology: iBeacon. While there are some helpful answers out there explaining how it functions, I've delved into a ...

Oops! Looks like there was a glitch in the server for the application. The page you are looking for cannot be found. Error code: HTTP 404. Requested URL: /

Description: Oops! The page you are trying to access cannot be found. It may have been removed, renamed, or is currently unavailable. Please double-check the URL for any errors. Requested URL: /UsersPage/undefined I've got this AJAX script that is s ...

What is the best way to capture the result of an arrow function within an object in JavaScript and store it in a variable?

I am currently implementing a piece of JavaScript code taken from a publicly available repository located at: https://github.com/base62/base62.js My goal is to capture the output for further manipulation, specifically for a date conversion process. Howev ...

Personalized Tumblr-style button

Hey there, I've been working on creating a custom Tumblr-like button and tried adding an iframe above it to make it clickable. However, something seems to be off as it's not functioning properly. I'm still trying to wrap my head around how i ...

Get your hands on the base64 image by triggering the save as popup and downloading

I am facing a challenge with downloading a base64 image onto the user's machine. So far, I have attempted the following steps: var url = base64Image.replace(/^data:image\/[^;]+/, 'data:application/octet-stream'); window.open(url); an ...

What role does @next/react-dev-overlay serve in development processes?

Currently, I am diving into a NextJs project. Within the next.config.js file, there is this code snippet: const withTM = require('next-transpile-modules')([ 'some package', 'some package', 'emittery', ...

Inject a jQuery form submission using .html() into a div element

I am currently working on developing a basic forum where users can view listed topics and have the option to add new ones on-the-fly by clicking a link or image. How can I detect and handle the form submission event for the dynamically added form within an ...

Leveraging ES6 import declarations within Firebase functions

I've been experimenting with using ES6 in Firebase functions by trying to import modules like "import App from './src/App.js'. However, after adding type:"module" to my package.json, I encountered a strange error with Firebase ...

Exploring jQuery Ajax: A Guide to Verifying Duplicate Names

When I apply the blur function to a textbox to check for duplicate names using jQuery AJAX, it works perfectly. Here is the code snippet: function checkForDuplicate(data){ $.post("test.php", {name: data}, function (data){ if(data){ ...

Tips for retrieving the concealed input value from the div directly preceding

Is it possible for me to retrieve the hidden input value by clicking on the text "upload profile photo"? I don't have much experience in this area. <div> <input type="hidden" value='<?php echo $list['profil ...

How can we use AJAX to incorporate a "like" feature?

I have nearly completed my website, but there is one final obstacle. I would like to add an ajax liking feature. The idea is that when a user clicks on the button, an ajax call should be triggered to increase the value in the database and update it on the ...

What is the method for setting a condition within the setState function?

I used if for the title: in SetConfirmDialog, but it's not working. How can I fix this? <Button color={user.active ? "success" : "error"} variant="text" startIcon={<UserCheck />} title={user.active ? &quo ...

What strategies can I use to solve this JavaScript puzzle?

One of my acquaintances has a webpage online that contains an inline script tag, featuring a JavaScript function: (#1): var domain = window.location.protocol + "//" + window.location.host + '/'; $(document).ready(function() { var count = 5 ...