ios - iOS:如果没有GPS,是否可以检测用户是否在驾驶车辆?

标签 ios objective-c gps

我正在开发一个具有弹出消息的应用程序(如果用户正在驾驶车辆)。我已经实现了SOMotionDetector库。这个库工作的很好,但是我不想跟踪用户的位置,我当然也不想显示一条消息,要求获得跟踪他们位置的权限。还有其他选择吗?

这是我添加的代码,不确定是否会有所帮助。

[SOLocationManager sharedInstance].allowsBackgroundLocationUpdates = NO;

[[SOMotionDetector sharedInstance] startDetection];

[SOMotionDetector sharedInstance].useM7IfAvailable = YES; //Use M7 chip if available, otherwise

[SOMotionDetector sharedInstance].motionTypeChangedBlock = ^(SOMotionType motionType) {
    switch (motionType) {
        case MotionTypeNotMoving:
            break;
        case MotionTypeWalking:
            break;
        case MotionTypeRunning:
            break;
        case MotionTypeAutomotive:[self alertMessage];
            break;
    }
};

最佳答案

是的,有可能。

  • 您可以在设备上使用Core Motion来指示是否
    用户可能正在开车。 CoreMotion API 为您提供iOS的最佳体验
    猜测用户的 Activity ,但不能保证是100%
    准确。 (例如,我不确定乘坐火车是否可以算
    作为汽车。另请注意,不同的 Activity 类型不是
    相互排斥。)最好让您的应用检查
    您感兴趣的 Activity 类型,而不是尝试排除那些 Activity 类型
    你不要
  • 通过以下方法检查用户的当前速度。如果用户
    比20英里每小时的行驶速度快,那么我可以假设
    用户在车上:
    - (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations {
       CLLocation *recentLocation = [locations lastObject];
       recentLocation.speed; //If speed is over 20 MPH, assume the user is not on their feet.
      }
    
  • 关于ios - iOS:如果没有GPS,是否可以检测用户是否在驾驶车辆?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36818462/

    相关文章:

    android - location 和 currentBestLocation 从哪里来?在 Android 开发指南中(获取用户位置)

    ios - 使用自定义登录按钮检索 Facebook 页面喜欢

    ios - 在 iOS 7.1 应用程序 xcode 5.1 中获取数字百分比时遇到问题

    iOS:如何通过按 UIButton 更改 UIImageView

    android - 如何以编程方式将 GPS 位置发送到 Android Studio 2.0 AVD

    android - 无法使用 GPS 在 android 中显示确切地址

    iphone - 预加载的 "Core data"数据库在更新数据库后未显示正确的新数据

    ios - SSKeychain 不保留数据

    ios - seekToTime 不适用于 iOS 9 中的实时 Assets

    ios - 单击 IOS 后按钮标签颜色更改