Xamarin.Forms Plugin.Geofence赋予System.InvalidCastException:指定的强制转换无效

问题描述 投票:1回答:1

我正在使用Plugin.Geofence i实现了它的接口,安装了它的依赖项,即.NETStandard 2.0Xamarin.GooglePlayServices.Location

当我运行System.InvalidCastException: Specified cast is not valid.方法时,我得到了这个例外StartMonitoring

我在App()构造函数中调用此方法。

    public App ()
    {
        InitializeComponent();
        MainPage = new NavigationPage(new MainPage());

        CrossGeofence.Current.StartMonitoring(new GeofenceCircularRegion("MyRegion", 31.475085, 74.305833, 200)
        {

            //To get notified if user stays in region for at least 5 minutes
            NotifyOnStay = true,
            StayedInThresholdDuration = TimeSpan.FromMinutes(5)
        });
    }

尝试了一切,但无法解决这个问题

exception xamarin.forms geofencing
1个回答
0
投票

对于寻找解决方案的任何人,请在调用“CrossGeofence.Current”之前确保已请求并授予了正确的权限。如果没有,你会看到这个错误。

© www.soinside.com 2019 - 2024. All rights reserved.