Geofence/Geofence/Geofence.Plugin.iOS/GeofenceImplementation.cs
/// <summary>
/// Checks if has passed to stayed state
/// </summary>
/// <param name="regionId"></param>
/// <returns></returns>
Checks if has passed to stayed state
Checks if has passed to stayed state
public async Task CheckIfStayed(string regionId)
        {
            if (CrossGeofence.Current.GeofenceResults.ContainsKey(regionId) && CrossGeofence.Current.Regions.ContainsKey(regionId) && CrossGeofence.Current.Regions[regionId].NotifyOnStay && CrossGeofence.Current.GeofenceResults[regionId].Transition == GeofenceTransition.Entered && CrossGeofence.Current.Regions[regionId].StayedInThresholdDuration.TotalMilliseconds != 0)
            {
                await Task.Delay((int)CrossGeofence.Current.Regions[regionId].StayedInThresholdDuration.TotalMilliseconds);
                if (CrossGeofence.Current.GeofenceResults[regionId].LastExitTime == null && CrossGeofence.Current.GeofenceResults[regionId].Transition != GeofenceTransition.Stayed)
                {
                    CrossGeofence.Current.GeofenceResults[regionId].Transition = GeofenceTransition.Stayed;
                    CrossGeofence.GeofenceListener.OnRegionStateChanged(CrossGeofence.Current.GeofenceResults[regionId]);
                    if (CrossGeofence.Current.Regions[regionId].ShowNotification)
                    {
                        CreateNotification(ViewAction, string.IsNullOrEmpty(CrossGeofence.Current.Regions[regionId].NotificationStayMessage) ? CrossGeofence.Current.GeofenceResults[regionId].ToString() : CrossGeofence.Current.Regions[regionId].NotificationStayMessage);
                    }
                }
            }
        }
public async Task CheckIfStayed ( string regionId ) { if ( CrossGeofence . Current . GeofenceResults . ContainsKey ( regionId ) && CrossGeofence . Current . Regions . ContainsKey ( regionId ) && CrossGeofence . Current . Regions [ regionId ] . NotifyOnStay && CrossGeofence . Current . GeofenceResults [ regionId ] . Transition == GeofenceTransition . Entered && CrossGeofence . Current . Regions [ regionId ] . StayedInThresholdDuration . TotalMilliseconds != 0 ) { await Task . Delay ( ( int ) CrossGeofence . Current . Regions [ regionId ] . StayedInThresholdDuration . TotalMilliseconds ) ; if ( CrossGeofence . Current . GeofenceResults [ regionId ] . LastExitTime == null && CrossGeofence . Current . GeofenceResults [ regionId ] . Transition != GeofenceTransition . Stayed ) { CrossGeofence . Current . GeofenceResults [ regionId ] . Transition = GeofenceTransition . Stayed ; CrossGeofence . GeofenceListener . OnRegionStateChanged ( CrossGeofence . Current . GeofenceResults [ regionId ] ) ; if ( CrossGeofence . Current . Regions [ regionId ] . ShowNotification ) { CreateNotification ( ViewAction , string . IsNullOrEmpty ( CrossGeofence . Current . Regions [ regionId ] . NotificationStayMessage ) ? CrossGeofence . Current . GeofenceResults [ regionId ] . ToString ( ) : CrossGeofence . Current . Regions [ regionId ] . NotificationStayMessage ) ; } } } }
Checks if has passed to stayed state
Checks if has passed to stayed state
None
regionId
string
None