MCPcopy Create free account
hub / github.com/transistorsoft/react-native-background-geolocation / NativeModule

Class NativeModule

src/NativeModule.js:160–433  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

158* Native API
159*/
160export default class NativeModule {
161 /**
162 * Core API Methods
163 */
164 static ready(config) {
165 return RNBackgroundGeolocation.ready(validateConfig(config));
166 }
167
168 static configure(config) {
169 console.warn('[BackgroundGeolocation] Method #configure is deprecated in favor of #ready');
170 return RNBackgroundGeolocation.configure(validateConfig(config));
171 }
172
173 static requestPermission() {
174 return RNBackgroundGeolocation.requestPermission();
175 }
176
177 static requestTemporaryFullAccuracy(purpose) {
178 return RNBackgroundGeolocation.requestTemporaryFullAccuracy(purpose);
179 }
180
181 static getProviderState() {
182 return RNBackgroundGeolocation.getProviderState();
183 }
184
185 static setConfig(config) {
186 return RNBackgroundGeolocation.setConfig(validateConfig(config));
187 }
188
189 static reset(config) {
190 config = config || {};
191 return RNBackgroundGeolocation.reset(validateConfig(config));
192 }
193
194 static addListener(event, success, failure) {
195 const handler = (response) => {
196 if (response.hasOwnProperty("error") && (response.error != null)) {
197 if (typeof(failure) === 'function') {
198 failure(response.error);
199 } else {
200 success(response);
201 }
202 } else {
203 success(response);
204 }
205 }
206 const subscription = EventEmitter.addListener(event, handler);
207
208 if (typeof(subscription.remove) === 'function') {
209 // React Native 0.65+ altered EventEmitter
210 //
211 // Wrap .remove() to remove from our own local EVENT_SUBSCRIPTIONS cache.
212 // Eventually we can remove this local cache entirely once people are trained
213 // to not use removeListener.
214 const originalRemove = subscription.remove;
215 subscription.remove = () => {
216 originalRemove.call(subscription);
217 removeEventSubscription(subscription);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected