1

我正在尝试在 Xamarin 的 WatchOS 应用上使用定位服务。我的 InterfaceController.Awake() 方法中有以下代码

        _locationManager = new CLLocationManager();
        _locationManager.Delegate = new MyLocationDelegate(LatitudeLabel, LongitudeLabel);
        _locationManager.DesiredAccuracy = CLLocation.AccuracyBest;
        _locationManager.RequestWhenInUseAuthorization();
        _locationManager.StartUpdatingLocation();

LocationDelegate 具有以下 AuthorizationChanged 实现:

  public override void AuthorizationChanged(CLLocationManager manager, CLAuthorizationStatus status)
    {
        Console.WriteLine("Location authorization changed: {0}", status);
    }

在 WatchOS 模拟器中运行应用程序时,我得到以下输出:

   2020-12-28 12:51:42.519358+0100 watchgpsWatchOSExtension[8630:441021] Location authorization changed: NotDetermined

我的所有 Info.plist(WatchOS App/Extension 和 iOS Companion 应用程序)中都有以下键/值:

<key>NSLocationWhenInUseUsageDescription</key>
<string>To get locations</string>

根据这个SO问题:

仅在 Apple Watch 上请求位置,在配对手机上没有代码

我应该在模拟 iPhone 上收到授权请求,但没有任何反应。

有什么想法我在这里做错了吗?

4

0 回答 0