2017-05-22 1 views
0

AndroidStudio에서 설정 한 지오 펜싱을 사용하는 프로토 타입 응용 프로그램이 있으며 Android 에뮬레이터에서 성공적으로 테스트 할 수있었습니다. 내가 iOS가되기 위해 애플리케이션이 필요하기 때문에 Xamarin/Visual Studio 2017에 프로토 타입을 이식하여 해당 환경에서 작동하는지 확인 했으므로 Android 및 iOS에서 앱의 핵심 로직을 코딩하지 않아도됩니다. 그러나 동일한 에뮬레이터에서 Xamarin 기반 앱에서 지오 펜스를 실행할 수는 없습니다. Xamarin에서이 기술을 사용하는 사람이 있습니까? Xamarin이이 작업을 수행하기 위해 변경해야하는 특정 설정이 있습니까?에뮬레이터에서 Xamarin Geofence 프로토 타입 테스트에 실패했습니다.

+0

당신을 했 : 여기

[Service] public class GeofenceTransitionsIntentService : IntentService, IEnableDatabaseLogger { public GeofenceTransitionsIntentService() : base(nameof(GeofenceTransitionsIntentService)) { } protected override void OnHandleIntent(Intent intent) { base.OnHandleIntent(intent); this.Log().Info("Intent received"); var geofencingEvent = GeofencingEvent.FromIntent(intent); if (geofencingEvent.HasError) { var errorMessage = GeofenceErrorMessages.GetErrorString(this, geofencingEvent.ErrorCode); this.Log().Error(errorMessage); return; } var geofenceTransition = geofencingEvent.GeofenceTransition; var geofences = geofencingEvent.TriggeringGeofences; var location = geofencingEvent.TriggeringLocation; if (geofenceTransition == Geofence.GeofenceTransitionEnter) { foreach (var geofence in geofences) this.Log().Info($"Entered {geofence.RequestId} at {location.Latitude}/{location.Longitude}"); // do something } else if (geofenceTransition == Geofence.GeofenceTransitionExit) { foreach (var geofence in geofences) this.Log().Info($"Exited {geofence.RequestId} at {location.Latitude}/{location.Longitude}"); // do something } else { this.Log().Error($"Geofence transition invalid type: {geofenceTransition}"); } } } 

데모 내가 최근 한 (작업) 프로젝트 실제 장치를 사용해 보시겠습니까? 작동합니까? 코드 문제를 무시하기 위해서 ... – xleon

+0

에뮬레이터에서 설정> 위치> 모드> 고정밀도로 시도 할 수 있습니다. – xleon

+0

실제 장치에서 테스트하기 위해 노력하고 있습니다. 에뮬레이터에서 Mode를 High Accuracy로 설정하고 결과를 변경하지 않았습니다. – tanzencoder

답변

0

문제는 아마도 매니페스트에서 비롯된 것입니다. Xamarin에서 서비스 (또는 인 텐트 서비스)를 만들 때 manifest에 수동으로 추가하는 대신 [Service] 속성으로 태그를 지정해야합니다.

(이미 그 일을하지 않는 경우) 의도를 처리 할 때 당신은 또한 오류를 확인해야합니다

: https://github.com/xleon/geofencing-playground

+0

POC를 이용해 주셔서 감사합니다. 적어도 에뮬레이터와 솔루션 모두에 이상이 있음을 확인하는 데 도움이되었습니다. 귀하의 솔루션은 내 에뮬레이터에서 작동하지 않았지만 지금까지 할 수 없었던 장치에서 작동했습니다. 어떻게 다른지보기 위해 코드를 분석하겠습니다. 다행히도 에뮬레이터에 어떤 문제가 있는지 알 수 있습니다. – tanzencoder

+0

설정 위치 모드를 고정밀 도로 변경하기 전까지 내 POC가 에뮬레이터에서 작동하지 않았습니다. – xleon

+0

Android 에뮬레이터 또는 Android 용 Visual Studio 에뮬레이터를 사용하고 있습니까? – tanzencoder