Toast make disappear very fast in iOS devices.

Bhuwan 616 Reputation points
2024-03-11T17:12:04.65+00:00

In Android below code is working fine but in iOS it's disappear very fast means come and then directly close within milli second

iOS version 17.2 in .NET 8.0
XCode version - 15.3
CommunityToolkit.Maui Version - 7.0.1


public class ToastMessageFunction

{
    /// <summary>`

    /// ToastErrorMessage`

    /// </summary>`

    /// <returns></returns>`

    /// <param name="Message"></param>`

    /// <param name="toastDuration"></param>`

    /// <param name="textSize"></param>`

    public static Toast ToastErrorMessage(string Message, ToastDuration toastDuration, int textSize)

    {

        return (Toast)Toast.Make(Message, duration: toastDuration, textSize: textSize);

    }

    /// <summary>

    /// ToastSucessMessage

    /// </summary>

    /// <returns></returns>

   /// <param name="Message"></param>

    /// <param name="toastDuration"></param>

    /// <param name="textSize"></param>

    public static Toast ToastSucessMessage(string Message, ToastDuration toastDuration, int textSize)`

    {

        return (Toast)Toast.Make(Message, duration: toastDuration, textSize: textSize);

    }

    /// <summary>

    /// ToastWarningMessage

   /// </summary>
   /// <returns></returns>

    /// <param name="Message"></param>

    /// <param name="toastDuration"></param>

    /// <param name="textSize"></param>

   public static Toast ToastWarningMessage(string Message, ToastDuration toastDuration, int textSize)

    {

       return (Toast)Toast.Make(Message, duration: toastDuration, textSize: textSize);

    }

used like this

await (Functions.ToastMessageFunction.ToastErrorMessage(message, CommunityToolkit.Maui.Core.ToastDuration.Short, 14)).Show(cancellationTokenSource.Token);
.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
2,853 questions
{count} votes