我正在尝试在iOS 8中为自定义区域调用委托方法locationManager:didEnterRegion。这是代码:
Task.Factory.StartNew(() =>
{
//here
departments = new ObservableCollection<Department>(this.GetAllDepartments());
});
它调用方法<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
</configSections>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="mssqllocaldb"/>
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer"/>
</providers>
</entityFramework>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup>
</configuration>
,但它不调用“enter”或“exit”区域方法。
另一个奇怪的事情是,如果我对locationManager使用requestAlwaysAuthorization,它会起作用。但我需要使用“何时使用”。
注意:在iOS7中,它适用于WhenInUse和Always Authorization方法。
答案 0 :(得分:1)
区域监控 - 它不适用于requestWhenInUseAuthorization
检查Apple文档:
“.. “when-in-use” ... Apps cannot use any services that automatically relaunch the app, such as region monitoring or the significant location change service
”
你必须致电requestAlwaysAuthorization
!!!
https://developer.apple.com/library/ios/documentation/CoreLocation/Reference/CLLocationManager_Class/index.html#//apple_ref/occ/instm/CLLocationManager/requestWhenInUseAuthorization