einerixcode
einerixcode

Reputation: 35

How to make Notification in Xamarin.Forms

How to make Notification in Xamarin.Forms with XAML or C# Code?

Can I use this in Ios with Xamarin.Forms?

Upvotes: 1

Views: 1436

Answers (1)

Johannes
Johannes

Reputation: 958

Have a look at the wonderful Toasts.Forms.Plugin

You can simply trigger a notification like this

var notificator = DependencyService.Get<IToastNotificator>();

var options = new NotificationOptions()
        {
            Title = "Title",
            Description = "Description"
        };
await notificator.Notify(options);

You can event react to if the user clicked, dismissed, etc. the notification

var result = await notificator.Notify(options);

// result is a NotificationResult with a NotificationAction in it
public enum NotificationAction
{
    Timeout = 1, // Hides by itself
    Clicked = 2, // User clicked on notification
    Dismissed = 4, // User manually dismissed notification
    ApplicationHidden = 8, // Application went to background
    Failed = 16 // When failed to display the toast
} 

For android you are able to choose between Snackbar or Notification style. Have a look at the documentation to gain control to do your notification as you want!

Upvotes: 3

Related Questions