@react-native-community/geolocation:NativeModule.RNCGeolocation 为空

@react-native-community/geolocation:NativeModule.RNCGeolocation is null

我正在尝试在我的 React Native 应用程序上使用地理定位(Ios,expo)。我已经安装了 react-native-community/geolocation,当我导入它时我得到这个错误:

@react-native-community/geolocation:NativeModule.RNCGeolocation 为空。

它要求我在项目根目录中 运行 “react-native link @react-native-community/geolocation”,但是当我这样做时它说:调用 react-native link [packageName] 已弃用,取而代之的是 autolinking.

我不知道该怎么办了。谁能帮我这个?请

如果您使用的是 Expo,则可以使用 Location from Expo

但是如果你想使用 @react-native-community/geolocation,因为 react-native 0.60 或更高 autolinking should configure the library for you automatically. But if use react-native 0.59 or lower, you must make a manual installation 对于 iOS 和 Android 当 react-native link 不起作用。