question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

geolocation.watchPosition() - subscription.listener.apply is not a function

See original GitHub issue

Environment

  • React Native 0.31.0
  • OSX 10.11.6
  • iOS Emulator 9.6 (doesn’t happen on Android)

The code

class MyComponent extends Component {
  constructor() {
    super();
    this.state = {};
  }

  componentDidMount() {
    this.watcher = navigator.geolocation.watchPosition(
      pos => this.setState(pos.coords);
    );
  }

  componentWillUnmount() {
    navigator.geolocation.clearWatch(this.watcher);
  }

  render() {
    return (
      <Text>{this.state.latitude}</Text> 
    );
  }
}

Steps to reproduce

  1. Load the app in an iOS emulator (9.6). Coords load fine.
  2. Change the location Debug -> Location -> …. Coords load fine.
  3. Change the location again. You should see: subscription.listener.apply is not a function

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

7reactions
jschloercommented, Jan 11, 2017

For people encountering this later… I ran into this as well because I passed a position options object without an error handler. If you do so, the eventEmitter will try to run your options object as the error handler function. Also, this means that your options aren’t being processed properly without an error handler, so if you need to send options to watchPosition, make sure to send the semi-optional error handler as well.

0reactions
facebook-github-botcommented, Nov 14, 2016

@charpeni tells me to close this issue. If you think it should still be opened let us know why.

Read more comments on GitHub >

github_iconTop Results From Across the Web

subscription.listener.apply is not a function | Voters
geolocation.watchPosition() - subscription.listener.apply is not a function. Nicolas Charpentier.
Read more >
subscription.listener.apply is not a function (react-native iOS)
Whenever I am opening the app for the first time from Testflight, the app crashes with the following error. TypeError: subscription.listener.
Read more >
Geolocation.watchPosition() - Web APIs | MDN
An optional object that provides configuration options for the location watch. See Geolocation.getCurrentPosition() for more details on possible ...
Read more >
BackgroundGeolocation | React Native Background Geolocation
The heartbeat event does not actively engage location-services. If you wish to get the current location in your callback , use getCurrentPosition.
Read more >
Location - Expo Documentation
expo-location allows reading geolocation information from the device. ... To use Background Location methods, the following requirements apply:.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found