MAUI iOS just hangs on refresh of data

Jai Holloway 40 Reputation points
2024-09-04T08:08:28.48+00:00

I have redeveloped a Xamarin Forms app into .NET MAUI and it was working fine until recently. I have two problems, but will post the other problem into a different question.

For this problem, when pulling down to refresh the data the app just hangs on UIApplication.Main(args,null, typeof(AppDelegate));

It never gets past that point. Has anyone come across this problem and how did you solve it?

 public class Program
 {
     // This is the main entry point of the application.
     static void Main(string[] args)
     {
         // if you want to use a different Application Delegate class from "AppDelegate"
         // you can specify it here.
         IAccount existingAccount = Task.Run(async () => await PublicClientSingleton.Instance.MSALClientHelper.InitializePublicClientAppAsync()).Result;
         UIApplication.Main(args, null, typeof(AppDelegate));
     }
 }


Microsoft Authenticator
Microsoft Authenticator
A Microsoft app for iOS and Android devices that enables authentication with two-factor verification, phone sign-in, and code generation.
6,941 questions
.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
3,541 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Wenyan Zhang (Shanghai Wicresoft Co,.Ltd.) 31,976 Reputation points Microsoft Vendor
    2024-09-05T03:36:07.5133333+00:00

    Hello,

    .Result is used to synchronously wait for the task to complete, and you put the method in Main function, so the app hangs on.

    I noticed that this PublicClientSingleton.Instance.MSALClientHelper.InitializePublicClientAppAsync() method is to initialize the MSAL client app, I added the Microsoft Authenticator tag to let them focus on this thread and support further.

    (Official doc -Tutorial: Sign in users in .NET MAUI shell app using an external tenant - Microsoft Entra External ID | Microsoft Learn)

    Best Regards,

    Wenyan Zhang


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.