CopyPastor

Detecting plagiarism made easy.

Score: 1.6496363282203674; Reported for: String similarity, Exact paragraph match Open both answers

Possible Plagiarism

Plagiarized on 2017-05-08
by Jay Patel

Original Post

Original - Posted on 2017-03-08
by Alessandro Caliaro



            
Present in both answers; Present only in the new answer; Present only in the old answer;

You can display toast message using Toasts.Forms.Plugin
**Setup**
In your iOS, Android, WinRT and UWP projects please call:
DependencyService.Register<ToastNotification>(); // Register your dependency ToastNotification.Init(); // If you are using Android you must pass through the activity ToastNotification.Init(this);
If you are using Xamarin Forms, you must do this AFTER your call to Xamarin.Forms.Init();
**Permissions**
In iOS you must request permission to show local notifications first since it is a user interrupting action.
// Request Permissions if (UIDevice.CurrentDevice.CheckSystemVersion(10, 0)) { // Request Permissions UNUserNotificationCenter.Current.RequestAuthorization(UNAuthorizationOptions.Alert | UNAuthorizationOptions.Badge | UNAuthorizationOptions.Sound, (granted, error) => { // Do something if needed }); } else if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0)) { var notificationSettings = UIUserNotificationSettings.GetSettingsForTypes( UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound, null); app.RegisterUserNotificationSettings(notificationSettings); }
**Usage**
Use dependency service in order to resolve IToastNotificator.
var notificator = DependencyService.Get<IToastNotificator>(); var options = new NotificationOptions() { Title = "Title", Description = "Description" }; var result = await notificator.Notify(options);
The result that is returned is a NotificationResult with an Action inside with one of the following values.
[Flags] 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 }
If you want the Clicked NotificationAction you must set IsClickable = true in the NotificationOptions.
Taking a look to [this plugin][1]
It say that
In iOS you must request permission to show local notifications first since it is a user interrupting action.
// Request Permissions if (UIDevice.CurrentDevice.CheckSystemVersion(10, 0)) { // Request Permissions UNUserNotificationCenter.Current.RequestAuthorization(UNAuthorizationOptions.Alert | UNAuthorizationOptions.Badge | UNAuthorizationOptions.Sound, (granted, error) => { // Do something if needed }); } else if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0)) { var notificationSettings = UIUserNotificationSettings.GetSettingsForTypes( UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound, null); app.RegisterUserNotificationSettings(notificationSettings); }
I don't know if it is helpful for you [1]: https://github.com/EgorBo/Toasts.Forms.Plugin

        
Present in both answers; Present only in the new answer; Present only in the old answer;