【问题标题】:React Native Background Geolocation stationary not working反应本机背景地理定位静止不动
【发布时间】:2021-01-07 02:18:45
【问题描述】:

我正在使用https://github.com/mauron85/react-native-background-geolocation,但固定不工作。我的提供商是 DISTANCE_FILTER_PROVIDER,我按照代码进行操作

BackgroundGeolocation.on('stationary', (stationaryLocation) => {
  // handle stationary locations here
  console.log(stationaryLocation, 'STATIONARY')
});

但 console.log 中没有显示任何内容,删除 BackgroundGeolocation.on('location', (location) => {}) 并显示固定。这是怎么回事?有人可以帮助我如何使用文具。我在自动暂停中使用它。感谢您的帮助,谢谢。

【问题讨论】:

    标签: android react-native geolocation


    【解决方案1】:

    尝试使用此代码。

    将此添加到您的配置对象

    stationaryRadius: 50
    

    当你使用console.log需要添加字符串变量时,需要用+号连接

    BackgroundGeolocation.on('stationary', (stationaryLocation) => {
          // handle stationary locations here
          console.log(stationaryLocation + "STATIONARY")
        });
    

    或尝试使用日志记录

    【讨论】:

    • desiredAccuracy: BackgroundGeolocation.HIGH_ACCURACY, locationProvider: BackgroundGeolocation.DISTANCE_FILTER_PROVIDER, stationaryRadius: 50, distanceFilter: 50, notificationTitle: 'Sample', notificationText: 'Tract your run!', startOnBoot: true, stopOnTerminate: true, 这是我的配置,但仍然没有显示静止不动
    猜你喜欢
    • 1970-01-01
    • 2018-09-07
    • 1970-01-01
    • 2016-12-23
    • 1970-01-01
    • 2021-12-29
    • 2015-01-11
    • 2021-04-15
    • 1970-01-01
    相关资源
    最近更新 更多