public TaskCompletionSource <string> ProcessGeofence() { completionSource = new TaskCompletionSource <string>(); GeofenceBuilder builder = new GeofenceBuilder(); builder.SetCircularRegion(37.3309, -121.8939, 2000); builder.SetExpirationDuration(60 * 60 * 100); //one hour builder.SetRequestId("SanJose Downtown"); builder.SetLoiteringDelay(10000); builder.SetTransitionTypes(Geofence.GeofenceTransitionEnter); builder.SetExpirationDuration(50000); builder.SetNotificationResponsiveness(100); ACPPlaces.ProcessGeofence(builder.Build(), 1); //1 is Geofence Enter Transition. completionSource.SetResult("Geofence Processing Completed"); return(completionSource); }
public void AddGeofences(GeofenceModel geofenceModel) { //Set parameters geofenceModel.Id = Guid.NewGuid().ToString(); if (geofenceModel.Conversion == 5) //Expiration value that indicates the geofence should never expire. { geofenceModel.Timeout = Geofence.GeofenceNeverExpire; } else { geofenceModel.Timeout = 10000; } List <IGeofence> geofenceList = new List <IGeofence>(); //Geofence Service GeofenceService geofenceService = LocationServices.GetGeofenceService(activity); PendingIntent pendingIntent = CreatePendingIntent(); GeofenceBuilder somewhereBuilder = new GeofenceBuilder() .SetUniqueId(geofenceModel.Id) .SetValidContinueTime(geofenceModel.Timeout) .SetRoundArea(geofenceModel.LatLng.Latitude, geofenceModel.LatLng.Longitude, geofenceModel.Radius) .SetDwellDelayTime(10000) .SetConversions(geofenceModel.Conversion);; //Create geofence request geofenceList.Add(somewhereBuilder.Build()); GeofenceRequest geofenceRequest = new GeofenceRequest.Builder() .CreateGeofenceList(geofenceList) .Build(); //Register geofence //Task geoTask = geofenceService.CreateGeofenceList(geofenceRequest, pendingIntent); //geoTask.AddOnSuccessListener(new CreateGeoSuccessListener(activity)); //geoTask.AddOnFailureListener(new CreateGeoFailListener(activity)); }