Roberto Rodriguez
Roberto Rodriguez

Reputation: 3347

React Native navigator.geolocation.getCurrentPosition how to customize the Alert Text Message

In React Native we have this function to access the Device's Location:

navigator.geolocation.getCurrentPosition(
      (position) => {
        this.setState({
          latitude: position.coords.latitude,
          longitude: position.coords.longitude,
          error: null,
        });
      },
      (error) => this.setState({ error: error.message }),
      { enableHighAccuracy: true, timeout: 20000, maximumAge: 1000 },
    );

As we see in this sample code, it receives a onSuccess and onFail functions, and also an object as third parameter where you can customize enableHighAccuracy, timeout and maximumAge.

Then when you call this, the first time it shows a Modal, requesting the user's permission to access his location. So my question is:

How can I customize the text displayed in that Modal alert?

enter image description here

Now Apple introduced some guiadance that requires to mention what the permission is being requested for, but I dont see a way to customize tha text message programatically.

I am stuck, and my app is being rejected many times because of this. Please advise.

Upvotes: 1

Views: 2161

Answers (1)

hawkup
hawkup

Reputation: 547

  1. Open your react native ios project with Xcode
  2. Select info tab
  3. Find Privacy - Location When In Use Usage Description key (Example Privacy - Camera Usage Description)
  4. Edit value to describe why you request to access this enter image description here
  5. When app show popup request will show description that you fill enter image description here

More info check this answer

Upvotes: 3

Related Questions