Skip to content

Location Notifications

Elvin (Tharindu) Thudugala edited this page Aug 4, 2022 · 7 revisions

From Version 10.0.1 and above

You can set up Geofence to trigger a notification.

By default notification trigged on Entry.

var notification = new NotificationRequest
{
    NotificationId = notificationId,
    Title = "Test",
    Description = $"Test Description",
    Geofence =
    {
        Center =
        {
            Latitude = -37.003578276665095,
            Longitude = 174.78484574983338
        },
        RadiusInMeters = 100                
    }
};
LocalNotificationCenter.Current.Show(notification);

To trigged on both Entry and Exit

var notification = new NotificationRequest
{
    NotificationId = notificationId,
    Title = "Test",
    Description = $"Test Description",
    Geofence =
    {
        Center =
        {
            Latitude = -37.003578276665095,
            Longitude = 174.78484574983338
        },
        RadiusInMeters = 100,
        GeofenceNotifyOn = NotificationRequestGeofence.GeofenceNotifyOn.OnEntry | NotificationRequestGeofence.GeofenceNotifyOn.OnExit                
    }
};
LocalNotificationCenter.Current.Show(notification);

To repeat

var notification = new NotificationRequest
{
    NotificationId = notificationId,
    Title = "Test",
    Description = $"Test Description",
    Geofence =
    {
        Center =
        {
            Latitude = -37.003578276665095,
            Longitude = 174.78484574983338
        },
        RadiusInMeters = 100,
        iOS = 
        {
           Repeats = true
        },
        Android =
        {
            ExpirationDurationInMilliseconds = -1
        },         
    }
};
LocalNotificationCenter.Current.Show(notification);