0
지오 펜스를 사용하여 위치 기반 알림 응용 프로그램을 개발하려고합니다. 나는 단지 ana locaiton을 사용할 때 완벽하게 작동합니다. 그러나 두 위치를 추가하면 첫 번째 추가 된 위치에서만 작동합니다. 오류 또는 예외가 나타나지 않습니다. 그러나 두 번째 위치는 전혀 나타나지 않습니다. 나는 이것에 대한 이유를 찾을 수 없었다.WP 앱용 지오 펜스를 여러 개 추가하는 방법은 무엇입니까?
BasicGeoposition pos1 = new BasicGeoposition { Latitude = 6.931522, Longitude = 79.842005 };
BasicGeoposition pos2 = new BasicGeoposition { Latitude = 6.978166, Longitude = 79.927376 };
Geofence fence1 = new Geofence("loc", new Geocircle(pos1, 100));
Geofence fence2 = new Geofence("loc", new Geocircle(pos2, 100));
try
{
monitor.Geofences.Add(fence1);
monitor.Geofences.Add(fence2);
}
이렇게 위치를 생성하고 지오 펜스에 추가하는 방법입니다. 그런 다음 루프와 함께 호출됩니다.
var reports = sender.ReadReports();
await Dispatcher.RunAsync(CoreDispatcherPriority.High,() =>
{
foreach (GeofenceStateChangeReport changeReport in reports)
{
if (changeReport.NewState == GeofenceState.Entered)
{
Dispatcher.RunAsync(CoreDispatcherPriority.High, async() =>
{
MessageDialog dialog = new MessageDialog("u re in the location");
await dialog.ShowAsync();
});
}
if (changeReport.NewState == GeofenceState.Exited)
{
Dispatcher.RunAsync(CoreDispatcherPriority.High, async() =>
{
MessageDialog dialog = new MessageDialog("u exited from the location");
await dialog.ShowAsync();
});
}
}
});
그것은 단지 전체 생성자의'지오 펜스 (문자열, IGeoshape , MonitoredGeofenceStates, Boolean, TimeSpan, DateTime, TimeSpan)'마지막 항목은 단일 사용, 휴지 시간, 시작 시간, 지오 펜스 지속 시간입니다. 자세한 내용은 답변과 함께 게시 한 링크를 참조하십시오. 가능한 모든 생성자를 볼 수 있습니다. – Fred
나는 이것을 제외하고 모든 것을 시도했다. 당신의 도움을 주셔서 대단히 감사합니다. 나는 너의 suggetion에 대해 생각했다. 하지만 지오 펜스를 만들 때 전달하는 마지막 매개 변수에 대해 물어볼 수 있습니까 ?? 통과해야하는 항목 계속 확인하려면? 다시 많이 감사 드리며 정말로 도움을 주셔서 감사합니다. – user9480