geolocation.watchPosition() - subscription.listener.apply is not a function
See original GitHub issueEnvironment
- 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
- Load the app in an iOS emulator (9.6). Coords load fine.
- Change the location Debug -> Location -> …. Coords load fine.
- Change the location again. You should see: subscription.listener.apply is not a function
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (4 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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.
@charpeni tells me to close this issue. If you think it should still be opened let us know why.