mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
45 lines
30 KiB
HTML
45 lines
30 KiB
HTML
<!doctype html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
<meta name="generator" content="Docusaurus v2.0.0-alpha.66">
|
|
<link rel="alternate" type="application/rss+xml" href="/blog/rss.xml" title="React Native Blog RSS Feed">
|
|
<link rel="alternate" type="application/atom+xml" href="/blog/atom.xml" title="React Native Blog Atom Feed">
|
|
<link rel="preconnect" href="https://www.google-analytics.com">
|
|
<script>window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)},ga.l=+new Date,ga("create","UA-41298772-2","auto"),ga("send","pageview")</script>
|
|
<script async src="https://www.google-analytics.com/analytics.js"></script>
|
|
<link rel="preconnect" href="https://www.google-analytics.com">
|
|
<link rel="preconnect" href="https://www.googletagmanager.com">
|
|
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-41298772-2"></script>
|
|
<script>function gtag(){dataLayer.push(arguments)}window.dataLayer=window.dataLayer||[],gtag("js",new Date),gtag("config","UA-41298772-2",{})</script>
|
|
<link rel="search" type="application/opensearchdescription+xml" title="React Native" href="/opensearch.xml">
|
|
<script src="https://cdn.jsdelivr.net/npm/focus-visible@5.2.0/dist/focus-visible.min.js" defer="defer"></script>
|
|
<script src="https://snack.expo.io/embed.js" defer="defer"></script><title data-react-helmet="true">🚧 Geolocation · React Native</title><meta data-react-helmet="true" property="twitter:image" content="https://reactnative.dev/img/logo-og.png"><meta data-react-helmet="true" name="twitter:image:alt" content="Image for React Native"><meta data-react-helmet="true" name="docsearch:language" content="en"><meta data-react-helmet="true" name="docsearch:version" content="0.63"><meta data-react-helmet="true" name="docsearch:docusaurus_tag" content="docs-default-0.63"><meta data-react-helmet="true" property="og:image" content="https://reactnative.dev/img/logo-og.png"><meta data-react-helmet="true" name="twitter:card" content="summary"><meta data-react-helmet="true" name="twitter:image" content="https://reactnative.dev/img/logo-og.png"><meta data-react-helmet="true" property="og:title" content="🚧 Geolocation · React Native"><meta data-react-helmet="true" name="description" content="Deprecated. Use @react-native-community/geolocation instead."><meta data-react-helmet="true" property="og:description" content="Deprecated. Use @react-native-community/geolocation instead."><meta data-react-helmet="true" property="og:url" content="https://reactnative.dev/docs/geolocation"><link data-react-helmet="true" rel="shortcut icon" href="/img/favicon.ico"><link data-react-helmet="true" rel="preconnect" href="https://BH4D9OD16A-dsn.algolia.net" crossorigin="anonymous"><link data-react-helmet="true" rel="canonical" href="https://reactnative.dev/docs/geolocation"><link rel="stylesheet" href="/styles.fccefeba.css">
|
|
<link rel="stylesheet" href="/main.ca40cabd.css">
|
|
<link rel="preload" href="/styles.07d522c6.js" as="script">
|
|
<link rel="preload" href="/runtime~main.c0800141.js" as="script">
|
|
<link rel="preload" href="/main.5a3c9855.js" as="script">
|
|
<link rel="preload" href="/1.ba9ce8bd.js" as="script">
|
|
<link rel="preload" href="/2.58cb5d3d.js" as="script">
|
|
<link rel="preload" href="/1f391b9e.a824c215.js" as="script">
|
|
<link rel="preload" href="/943.8b024446.js" as="script">
|
|
<link rel="preload" href="/ee5b3385.b4fff665.js" as="script">
|
|
<link rel="preload" href="/17896441.0c201679.js" as="script">
|
|
<link rel="preload" href="/18abb92e.9cf79b2f.js" as="script">
|
|
</head>
|
|
<body>
|
|
<script>!function(){function t(t){document.documentElement.setAttribute("data-theme",t)}var e=function(){var t=null;try{t=localStorage.getItem("theme")}catch(t){}return t}();t(null!==e?e:"light")}()</script><div id="__docusaurus">
|
|
<nav class="navbar navbar--fixed-top navbar--dark"><div class="navbar__inner"><div class="navbar__items"><div aria-label="Navigation bar toggle" class="navbar__toggle" role="button" tabindex="0"><svg xmlns="http://www.w3.org/2000/svg" width="30" height="30" viewBox="0 0 30 30" role="img" focusable="false"><title>Menu</title><path stroke="currentColor" stroke-linecap="round" stroke-miterlimit="10" stroke-width="2" d="M4 7h22M4 15h22M4 23h22"></path></svg></div><a class="navbar__brand" href="/"><img class="navbar__logo" src="/img/header_logo.svg" alt="React Native"><strong class="navbar__title">React Native</strong></a><div class="navbar__item dropdown dropdown--hoverable dropdown--left"><a class="navbar__item navbar__link" href="/docs/getting-started">0.63</a><ul class="dropdown__menu"><li><a class="dropdown__link" href="/docs/next/getting-started">Next</a></li><li><a aria-current="page" class="dropdown__link dropdown__link--active" href="/docs/geolocation">0.63</a></li><li><a class="dropdown__link" href="/docs/0.62/geolocation">0.62</a></li><li><a class="dropdown__link" href="/docs/0.61/geolocation">0.61</a></li><li><a class="dropdown__link" href="/docs/0.60/geolocation">0.60</a></li><li><a class="dropdown__link" href="/versions">All versions</a></li></ul></div></div><div class="navbar__items navbar__items--right"><a class="navbar__item navbar__link" href="/docs/getting-started">Docs</a><a class="navbar__item navbar__link" href="/docs/components-and-apis">Components</a><a class="navbar__item navbar__link" href="/docs/accessibilityinfo">API</a><a class="navbar__item navbar__link" href="/help">Community</a><a class="navbar__item navbar__link" href="/blog">Blog</a><a href="https://github.com/facebook/react-native" target="_blank" rel="noopener noreferrer" class="navbar__item navbar__link navbar-github-link" aria-label="GitHub repository"></a><div class="react-toggle react-toggle--disabled displayOnlyInLargeViewport_3lWe"><div class="react-toggle-track"><div class="react-toggle-track-check"><span class="toggle_gnXW">🌜</span></div><div class="react-toggle-track-x"><span class="toggle_gnXW">🌞</span></div></div><div class="react-toggle-thumb"></div><input type="checkbox" disabled="" aria-label="Dark mode toggle" class="react-toggle-screenreader-only"></div><button type="button" class="DocSearch DocSearch-Button" aria-label="Search"><svg width="20" height="20" class="DocSearch-Search-Icon" viewBox="0 0 20 20"><path d="M14.386 14.386l4.0877 4.0877-4.0877-4.0877c-2.9418 2.9419-7.7115 2.9419-10.6533 0-2.9419-2.9418-2.9419-7.7115 0-10.6533 2.9418-2.9419 7.7115-2.9419 10.6533 0 2.9419 2.9418 2.9419 7.7115 0 10.6533z" stroke="currentColor" fill="none" fill-rule="evenodd" stroke-linecap="round" stroke-linejoin="round"></path></svg><span class="DocSearch-Button-Placeholder">Search</span><span class="DocSearch-Button-Key">⌘</span><span class="DocSearch-Button-Key">K</span></button></div></div><div role="presentation" class="navbar-sidebar__backdrop"></div><div class="navbar-sidebar"><div class="navbar-sidebar__brand"><a class="navbar__brand" href="/"><img class="navbar__logo" src="/img/header_logo.svg" alt="React Native"><strong class="navbar__title">React Native</strong></a></div><div class="navbar-sidebar__items"><div class="menu"><ul class="menu__list"><li class="menu__list-item"><a class="menu__link" href="/docs/getting-started">Docs</a></li><li class="menu__list-item"><a class="menu__link" href="/docs/components-and-apis">Components</a></li><li class="menu__list-item"><a class="menu__link" href="/docs/accessibilityinfo">API</a></li><li class="menu__list-item"><a class="menu__link" href="/help">Community</a></li><li class="menu__list-item"><a class="menu__link" href="/blog">Blog</a></li><li class="menu__list-item"><a role="button" class="menu__link menu__link--sublist">Versions</a><ul class="menu__list"><li class="menu__list-item"><a class="menu__link" href="/docs/next/getting-started">Next</a></li><li class="menu__list-item"><a aria-current="page" class="menu__link menu__link--active" href="/docs/geolocation">0.63</a></li><li class="menu__list-item"><a class="menu__link" href="/docs/0.62/geolocation">0.62</a></li><li class="menu__list-item"><a class="menu__link" href="/docs/0.61/geolocation">0.61</a></li><li class="menu__list-item"><a class="menu__link" href="/docs/0.60/geolocation">0.60</a></li><li class="menu__list-item"><a class="menu__link" href="/versions">All versions</a></li></ul></li><li class="menu__list-item"><a href="https://github.com/facebook/react-native" target="_blank" rel="noopener noreferrer" class="menu__link navbar-github-link" aria-label="GitHub repository"></a></li></ul></div></div></div></nav><div class="main-wrapper"><div class="docPage_2UBv"><main class="docMainContainer_1rYT"><div class="container padding-vert--lg docItemWrapper_1Hme"><div class="row"><div class="col docItemCol_2AGf"><div class="docItemContainer_1tAC"><article><header><h1 class="docTitle_cWlf">🚧 Geolocation</h1></header><div class="markdown"><blockquote><p><strong>Deprecated.</strong> Use <a href="https://github.com/react-native-community/react-native-geolocation" target="_blank" rel="noopener noreferrer">@react-native-community/geolocation</a> instead.</p></blockquote><p>The Geolocation API extends the <a href="https://developer.mozilla.org/en-US/docs/Web/API/Geolocation" target="_blank" rel="noopener noreferrer">Geolocation web spec</a>.</p><p>As a browser polyfill, this API is available through the <code>navigator.geolocation</code> global - you do not need to <code>import</code> it.</p><p>On Android, this uses the <a href="https://developer.android.com/reference/android/location/package-summary" target="_blank" rel="noopener noreferrer">android.location API</a>. This API is not recommended by Google because it is less accurate and slower than the recommended <a href="https://developer.android.com/training/location/" target="_blank" rel="noopener noreferrer">Google Location Services API</a>. In order to use it with React Native, use the <a href="https://github.com/Agontuk/react-native-geolocation-service" target="_blank" rel="noopener noreferrer">react-native-geolocation-service</a> module.</p><h3><a aria-hidden="true" tabindex="-1" class="anchor enhancedAnchor_3pqN" id="configuration-and-permissions"></a>Configuration and Permissions<a aria-hidden="true" tabindex="-1" class="hash-link" href="#configuration-and-permissions" title="Direct link to heading">#</a></h3><div class="banner-crna-ejected"><h3>Projects with Native Code Only</h3><p>This section only applies to projects made with <code>react-native init</code>or to those made with <code>expo init</code> or Create React Native App which have since ejected. For more information about ejecting, please see the <a href="https://github.com/react-community/create-react-native-app/blob/master/EJECTING.md" target="_blank" rel="noopener noreferrer">guide</a> on the Create React Native App repository.</p></div><h4><a aria-hidden="true" tabindex="-1" class="anchor enhancedAnchor_3pqN" id="ios"></a>iOS<a aria-hidden="true" tabindex="-1" class="hash-link" href="#ios" title="Direct link to heading">#</a></h4><p>You need to include the <code>NSLocationWhenInUseUsageDescription</code> key in Info.plist to enable geolocation when using the app. Geolocation is enabled by default when you create a project with <code>react-native init</code>.</p><p>In order to enable geolocation in the background, you need to include the 'NSLocationAlwaysUsageDescription' key in Info.plist and add location as a background mode in the 'Capabilities' tab in Xcode.</p><p>If you are using CocoaPods for React Native, make sure to include the <code>RCTGeolocation</code> sub-podspec.</p><h4><a aria-hidden="true" tabindex="-1" class="anchor enhancedAnchor_3pqN" id="android"></a>Android<a aria-hidden="true" tabindex="-1" class="hash-link" href="#android" title="Direct link to heading">#</a></h4><p>To request access to location, you need to add the following line to your app's <code>AndroidManifest.xml</code>:</p><p><code><uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /></code></p><p>Android API >= 18 Positions will also contain a <code>mocked</code> boolean to indicate if position was created from a mock provider.</p><p>Android API >= 23 Requires an additional step to check for, and request the ACCESS_FINE_LOCATION permission using the <a target="_blank" href="/docs/permissionsandroid">PermissionsAndroid API</a>. Failure to do so may result in a hard crash.</p><h3><a aria-hidden="true" tabindex="-1" class="anchor enhancedAnchor_3pqN" id="methods"></a>Methods<a aria-hidden="true" tabindex="-1" class="hash-link" href="#methods" title="Direct link to heading">#</a></h3><ul><li><a href="#setrnconfiguration"><code>setRNConfiguration</code></a></li><li><a href="#requestauthorization"><code>requestAuthorization</code></a></li><li><a href="#getcurrentposition"><code>getCurrentPosition</code></a></li><li><a href="#watchposition"><code>watchPosition</code></a></li><li><a href="#clearwatch"><code>clearWatch</code></a></li><li><a href="#stopobserving"><code>stopObserving</code></a></li></ul><hr><h1><a aria-hidden="true" tabindex="-1" class="anchor enhancedAnchor_3pqN" id="reference"></a>Reference<a aria-hidden="true" tabindex="-1" class="hash-link" href="#reference" title="Direct link to heading">#</a></h1><h2><a aria-hidden="true" tabindex="-1" class="anchor enhancedAnchor_3pqN" id="methods-1"></a>Methods<a aria-hidden="true" tabindex="-1" class="hash-link" href="#methods-1" title="Direct link to heading">#</a></h2><h3><a aria-hidden="true" tabindex="-1" class="anchor enhancedAnchor_3pqN" id="setrnconfiguration"></a><code>setRNConfiguration()</code><a aria-hidden="true" tabindex="-1" class="hash-link" href="#setrnconfiguration" title="Direct link to heading">#</a></h3><div class="mdxCodeBlock_xYIz"><div class="codeBlockContent_rlEb"><button tabindex="0" type="button" aria-label="Copy code to clipboard" class="copyButton_kOW4">Copy</button><div class="prism-code language-jsx codeBlock_1AP7"><div class="codeBlockLines_1boI" style="color:#FFFFFF;background:#282C34"><div class="token-line" style="color:#FFFFFF;background:#282C34"><span class="token plain">geolocation</span><span class="token punctuation" style="color:#657b83">.</span><span class="token function" style="color:#79b6f2">setRNConfiguration</span><span class="token punctuation" style="color:#657b83">(</span><span class="token plain">config</span><span class="token punctuation" style="color:#657b83">)</span><span class="token punctuation" style="color:#657b83">;</span></div></div></div></div></div><p>Sets configuration options that will be used in all location requests.</p><p><strong>Parameters:</strong></p><table><thead><tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th></tr></thead><tbody><tr><td>config</td><td>object</td><td>Yes</td><td>See below.</td></tr></tbody></table><p>Supported options:</p><ul><li><code>skipPermissionRequests</code> (boolean, iOS-only) - Defaults to <code>false</code>. If <code>true</code>, you must request permissions before using Geolocation APIs.</li></ul><hr><h3><a aria-hidden="true" tabindex="-1" class="anchor enhancedAnchor_3pqN" id="requestauthorization"></a><code>requestAuthorization()</code><a aria-hidden="true" tabindex="-1" class="hash-link" href="#requestauthorization" title="Direct link to heading">#</a></h3><div class="mdxCodeBlock_xYIz"><div class="codeBlockContent_rlEb"><button tabindex="0" type="button" aria-label="Copy code to clipboard" class="copyButton_kOW4">Copy</button><div class="prism-code language-jsx codeBlock_1AP7"><div class="codeBlockLines_1boI" style="color:#FFFFFF;background:#282C34"><div class="token-line" style="color:#FFFFFF;background:#282C34"><span class="token plain">geolocation</span><span class="token punctuation" style="color:#657b83">.</span><span class="token function" style="color:#79b6f2">requestAuthorization</span><span class="token punctuation" style="color:#657b83">(</span><span class="token punctuation" style="color:#657b83">)</span><span class="token punctuation" style="color:#657b83">;</span></div></div></div></div></div><p>Request suitable Location permission based on the key configured on pList. If NSLocationAlwaysUsageDescription is set, it will request Always authorization, although if NSLocationWhenInUseUsageDescription is set, it will request InUse authorization.</p><hr><h3><a aria-hidden="true" tabindex="-1" class="anchor enhancedAnchor_3pqN" id="getcurrentposition"></a><code>getCurrentPosition()</code><a aria-hidden="true" tabindex="-1" class="hash-link" href="#getcurrentposition" title="Direct link to heading">#</a></h3><div class="mdxCodeBlock_xYIz"><div class="codeBlockContent_rlEb"><button tabindex="0" type="button" aria-label="Copy code to clipboard" class="copyButton_kOW4">Copy</button><div class="prism-code language-jsx codeBlock_1AP7"><div class="codeBlockLines_1boI" style="color:#FFFFFF;background:#282C34"><div class="token-line" style="color:#FFFFFF;background:#282C34"><span class="token plain">geolocation</span><span class="token punctuation" style="color:#657b83">.</span><span class="token function" style="color:#79b6f2">getCurrentPosition</span><span class="token punctuation" style="color:#657b83">(</span><span class="token plain"></span></div><div class="token-line" style="color:#FFFFFF;background:#282C34"><span class="token plain"> geo_success</span><span class="token punctuation" style="color:#657b83">,</span><span class="token plain"></span></div><div class="token-line" style="color:#FFFFFF;background:#282C34"><span class="token plain"> </span><span class="token punctuation" style="color:#657b83">[</span><span class="token plain">geo_error</span><span class="token punctuation" style="color:#657b83">]</span><span class="token punctuation" style="color:#657b83">,</span><span class="token plain"></span></div><div class="token-line" style="color:#FFFFFF;background:#282C34"><span class="token plain"> </span><span class="token punctuation" style="color:#657b83">[</span><span class="token plain">geo_options</span><span class="token punctuation" style="color:#657b83">]</span><span class="token plain"></span></div><div class="token-line" style="color:#FFFFFF;background:#282C34"><span class="token plain"></span><span class="token punctuation" style="color:#657b83">)</span><span class="token punctuation" style="color:#657b83">;</span></div></div></div></div></div><p>Invokes the success callback once with the latest location info.</p><p><strong>Parameters:</strong></p><table><thead><tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th></tr></thead><tbody><tr><td>geo_success</td><td>function</td><td>Yes</td><td>Invoked with latest location info.</td></tr><tr><td>geo_error</td><td>function</td><td>No</td><td>Invoked whenever an error is encountered.</td></tr><tr><td>geo_options</td><td>object</td><td>No</td><td>See below.</td></tr></tbody></table><p>Supported options:</p><ul><li><code>timeout</code> (ms) - Is a positive value representing the maximum length of time (in milliseconds) the device is allowed to take in order to return a position. Defaults to INFINITY.</li><li><code>maximumAge</code> (ms) - Is a positive value indicating the maximum age in milliseconds of a possible cached position that is acceptable to return. If set to 0, it means that the device cannot use a cached position and must attempt to retrieve the real current position. If set to Infinity the device will always return a cached position regardless of its age. Defaults to INFINITY.</li><li><code>enableHighAccuracy</code> (bool) - Is a boolean representing if to use GPS or not. If set to true, a GPS position will be requested. If set to false, a WIFI location will be requested.</li></ul><hr><h3><a aria-hidden="true" tabindex="-1" class="anchor enhancedAnchor_3pqN" id="watchposition"></a><code>watchPosition()</code><a aria-hidden="true" tabindex="-1" class="hash-link" href="#watchposition" title="Direct link to heading">#</a></h3><div class="mdxCodeBlock_xYIz"><div class="codeBlockContent_rlEb"><button tabindex="0" type="button" aria-label="Copy code to clipboard" class="copyButton_kOW4">Copy</button><div class="prism-code language-jsx codeBlock_1AP7"><div class="codeBlockLines_1boI" style="color:#FFFFFF;background:#282C34"><div class="token-line" style="color:#FFFFFF;background:#282C34"><span class="token plain">geolocation</span><span class="token punctuation" style="color:#657b83">.</span><span class="token function" style="color:#79b6f2">watchPosition</span><span class="token punctuation" style="color:#657b83">(</span><span class="token plain">success</span><span class="token punctuation" style="color:#657b83">,</span><span class="token plain"> </span><span class="token punctuation" style="color:#657b83">[</span><span class="token plain">error</span><span class="token punctuation" style="color:#657b83">]</span><span class="token punctuation" style="color:#657b83">,</span><span class="token plain"> </span><span class="token punctuation" style="color:#657b83">[</span><span class="token plain">options</span><span class="token punctuation" style="color:#657b83">]</span><span class="token punctuation" style="color:#657b83">)</span><span class="token punctuation" style="color:#657b83">;</span></div></div></div></div></div><p>Invokes the success callback whenever the location changes. Returns a <code>watchId</code> (number).</p><p><strong>Parameters:</strong></p><table><thead><tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th></tr></thead><tbody><tr><td>success</td><td>function</td><td>Yes</td><td>Invoked whenever the location changes.</td></tr><tr><td>error</td><td>function</td><td>No</td><td>Invoked whenever an error is encountered.</td></tr><tr><td>options</td><td>object</td><td>No</td><td>See below.</td></tr></tbody></table><p>Supported options:</p><ul><li><code>timeout</code> (ms) - Is a positive value representing the maximum length of time (in milliseconds) the device is allowed to take in order to return a position. Defaults to INFINITY.</li><li><code>maximumAge</code> (ms) - Is a positive value indicating the maximum age in milliseconds of a possible cached position that is acceptable to return. If set to 0, it means that the device cannot use a cached position and must attempt to retrieve the real current position. If set to Infinity the device will always return a cached position regardless of its age. Defaults to INFINITY.</li><li><code>enableHighAccuracy</code> (bool) - Is a boolean representing if to use GPS or not. If set to true, a GPS position will be requested. If set to false, a WIFI location will be requested.</li><li><code>distanceFilter</code> (m) - The minimum distance from the previous location to exceed before returning a new location. Set to 0 to not filter locations. Defaults to 100m.</li><li><code>useSignificantChanges</code> (bool) - Uses the battery-efficient native significant changes APIs to return locations. Locations will only be returned when the device detects a significant distance has been breached. Defaults to FALSE.</li></ul><hr><h3><a aria-hidden="true" tabindex="-1" class="anchor enhancedAnchor_3pqN" id="clearwatch"></a><code>clearWatch()</code><a aria-hidden="true" tabindex="-1" class="hash-link" href="#clearwatch" title="Direct link to heading">#</a></h3><div class="mdxCodeBlock_xYIz"><div class="codeBlockContent_rlEb"><button tabindex="0" type="button" aria-label="Copy code to clipboard" class="copyButton_kOW4">Copy</button><div class="prism-code language-jsx codeBlock_1AP7"><div class="codeBlockLines_1boI" style="color:#FFFFFF;background:#282C34"><div class="token-line" style="color:#FFFFFF;background:#282C34"><span class="token plain">geolocation</span><span class="token punctuation" style="color:#657b83">.</span><span class="token function" style="color:#79b6f2">clearWatch</span><span class="token punctuation" style="color:#657b83">(</span><span class="token plain">watchID</span><span class="token punctuation" style="color:#657b83">)</span><span class="token punctuation" style="color:#657b83">;</span></div></div></div></div></div><p><strong>Parameters:</strong></p><table><thead><tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th></tr></thead><tbody><tr><td>watchID</td><td>number</td><td>Yes</td><td>Id as returned by <code>watchPosition()</code>.</td></tr></tbody></table><hr><h3><a aria-hidden="true" tabindex="-1" class="anchor enhancedAnchor_3pqN" id="stopobserving"></a><code>stopObserving()</code><a aria-hidden="true" tabindex="-1" class="hash-link" href="#stopobserving" title="Direct link to heading">#</a></h3><div class="mdxCodeBlock_xYIz"><div class="codeBlockContent_rlEb"><button tabindex="0" type="button" aria-label="Copy code to clipboard" class="copyButton_kOW4">Copy</button><div class="prism-code language-jsx codeBlock_1AP7"><div class="codeBlockLines_1boI" style="color:#FFFFFF;background:#282C34"><div class="token-line" style="color:#FFFFFF;background:#282C34"><span class="token plain">geolocation</span><span class="token punctuation" style="color:#657b83">.</span><span class="token function" style="color:#79b6f2">stopObserving</span><span class="token punctuation" style="color:#657b83">(</span><span class="token punctuation" style="color:#657b83">)</span><span class="token punctuation" style="color:#657b83">;</span></div></div></div></div></div><p>Stops observing for device location changes. In addition, it removes all listeners previously registered.</p><p>Notice that this method has only effect if the <code>geolocation.watchPosition(successCallback, errorCallback)</code> method was previously invoked.</p></div></article><div class="docMetadata margin-vert--xl"><div class="row"><div class="col"><a href="https://github.com/facebook/react-native-website/blob/master/website/versioned_docs/version-0.63/geolocation.md" target="_blank" rel="noreferrer noopener"><svg fill="currentColor" height="1.2em" width="1.2em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 40 40" style="margin-right:0.3em;vertical-align:sub"><g><path d="m34.5 11.7l-3 3.1-6.3-6.3 3.1-3q0.5-0.5 1.2-0.5t1.1 0.5l3.9 3.9q0.5 0.4 0.5 1.1t-0.5 1.2z m-29.5 17.1l18.4-18.5 6.3 6.3-18.4 18.4h-6.3v-6.2z"></path></g></svg>Edit this page</a></div><div class="col text--right"><em><small class="docMetadata-updated">Last updated on <time datetime="2020-10-29T04:19:29.000Z" class="docLastUpdatedAt_1gIo">10/29/2020</time></small></em></div></div></div><div class="margin-vert--lg"><nav class="pagination-nav" aria-label="Blog list page navigation"><div class="pagination-nav__item"></div><div class="pagination-nav__item pagination-nav__item--next"></div></nav></div></div></div><div class="col col--3"><div class="tableOfContents_3iuQ"><ul class="table-of-contents table-of-contents__left-border"><li><a href="#configuration-and-permissions" class="table-of-contents__link">Configuration and Permissions</a></li><li><a href="#methods" class="table-of-contents__link">Methods</a></li><li><a href="#methods-1" class="table-of-contents__link">Methods</a><ul><li><a href="#setrnconfiguration" class="table-of-contents__link"><code>setRNConfiguration()</code></a></li><li><a href="#requestauthorization" class="table-of-contents__link"><code>requestAuthorization()</code></a></li><li><a href="#getcurrentposition" class="table-of-contents__link"><code>getCurrentPosition()</code></a></li><li><a href="#watchposition" class="table-of-contents__link"><code>watchPosition()</code></a></li><li><a href="#clearwatch" class="table-of-contents__link"><code>clearWatch()</code></a></li><li><a href="#stopobserving" class="table-of-contents__link"><code>stopObserving()</code></a></li></ul></li></ul></div></div></div></div></main></div></div><footer class="footer footer--dark"><div class="container"><div class="row footer__links"><div class="col footer__col"><h4 class="footer__title">Docs</h4><ul class="footer__items"><li class="footer__item"><a class="footer__link-item" href="/docs/getting-started">Getting Started</a></li><li class="footer__item"><a class="footer__link-item" href="/docs/tutorial">Tutorial</a></li><li class="footer__item"><a class="footer__link-item" href="/docs/components-and-apis">Components and APIs</a></li><li class="footer__item"><a class="footer__link-item" href="/docs/more-resources">More Resources</a></li></ul></div><div class="col footer__col"><h4 class="footer__title">Community</h4><ul class="footer__items"><li class="footer__item"><a class="footer__link-item" href="/help">The React Native Community</a></li><li class="footer__item"><a class="footer__link-item" href="/showcase">Who's using React Native?</a></li><li class="footer__item"><a href="https://stackoverflow.com/questions/tagged/react-native" target="_blank" rel="noopener noreferrer" class="footer__link-item">Ask Questions on Stack Overflow</a></li><li class="footer__item"><a href="https://github.com/facebook/react-native/blob/master/CONTRIBUTING.md" target="_blank" rel="noopener noreferrer" class="footer__link-item">Contributor Guide</a></li><li class="footer__item"><a href="https://dev.to/t/reactnative" target="_blank" rel="noopener noreferrer" class="footer__link-item">DEV Community</a></li></ul></div><div class="col footer__col"><h4 class="footer__title">Find us</h4><ul class="footer__items"><li class="footer__item"><a class="footer__link-item" href="/blog">Blog</a></li><li class="footer__item"><a href="https://twitter.com/reactnative" target="_blank" rel="noopener noreferrer" class="footer__link-item">Twitter</a></li><li class="footer__item"><a href="https://github.com/facebook/react-native" target="_blank" rel="noopener noreferrer" class="footer__link-item">GitHub</a></li></ul></div><div class="col footer__col"><h4 class="footer__title">More</h4><ul class="footer__items"><li class="footer__item"><a href="https://reactjs.org/" target="_blank" rel="noopener noreferrer" class="footer__link-item">React</a></li><li class="footer__item"><a href="https://opensource.facebook.com/legal/privacy" target="_blank" rel="noopener noreferrer" class="footer__link-item">Privacy Policy</a></li><li class="footer__item"><a href="https://opensource.facebook.com/legal/terms" target="_blank" rel="noopener noreferrer" class="footer__link-item">Terms of Service</a></li></ul></div></div><div class="text--center"><div class="margin-bottom--sm"><a href="https://opensource.facebook.com" target="_blank" rel="noopener noreferrer" class="footerLogoLink_19Ac"><img class="footer__logo" alt="Facebook Open Source Logo" src="/img/oss_logo.png"></a></div><div>Copyright © 2020 Facebook, Inc.</div></div></div></footer></div>
|
|
<script src="/styles.07d522c6.js"></script>
|
|
<script src="/runtime~main.c0800141.js"></script>
|
|
<script src="/main.5a3c9855.js"></script>
|
|
<script src="/1.ba9ce8bd.js"></script>
|
|
<script src="/2.58cb5d3d.js"></script>
|
|
<script src="/1f391b9e.a824c215.js"></script>
|
|
<script src="/943.8b024446.js"></script>
|
|
<script src="/ee5b3385.b4fff665.js"></script>
|
|
<script src="/17896441.0c201679.js"></script>
|
|
<script src="/18abb92e.9cf79b2f.js"></script>
|
|
</body>
|
|
</html> |