AzureAD / microsoft-authentication-library-for-dotnet

Microsoft Authentication Library (MSAL) for .NET
https://aka.ms/msal-net
MIT License
1.39k stars 340 forks source link

[Bug] iOS does not launch app after the LaunchingFinished() method has run #4833

Open jaiGMS opened 4 months ago

jaiGMS commented 4 months ago

Library version used

4.61.3

.NET version

.net 8

Scenario

PublicClient - mobile app

Is this a new or an existing app?

This is a new app or experiment

Issue description and reproduction steps

The app works on the Android emulator, but when trying to run it in the iOS emulator for iPhone 15 iOS 17.5, the app never launches. It just shows a black screen with the date and time and the wifi indicator. There is an output message in the console of "enabledRemoteNotificationTypes is not supported in iOS 8.0 and later." and the launchOptions are null. I have tried searching for a way to overcome this error, but have found nothing helpful. As I said, this works fine on the Android Emulator, but the FinishedLaunching() method never launches the app.

Relevant code snippets

using MAUI.MSALClient;
using Microsoft.Identity.Client;
using Microsoft.Maui;
using Microsoft.Maui.Hosting;
using System.Threading.Tasks;
using UIKit;

namespace TourGrosses
{
    [Register("AppDelegate")]
    public class AppDelegate : MauiUIApplicationDelegate
    {
        private const string iOSRedirectURI = "msauth.[id hidden]://auth"; // TODO - Replace with your redirectURI
        protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();

        public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
        {
            // configure platform specific params
            PlatformConfig.Instance.RedirectUri = PublicClientSingleton.Instance.MSALClientHelper.AzureADConfig.iOSRedirectUri;

            // Initialize MSAL and platformConfig is set
            IAccount existinguser = Task.Run(async () => await PublicClientSingleton.Instance.MSALClientHelper.InitializePublicClientAppAsync()).Result;

            return base.FinishedLaunching(application, launchOptions);
        }
    }
}

Expected behavior

The app launches after it checks whether a user is cached or not

Identity provider

Microsoft Entra ID (Work and School accounts and Personal Microsoft accounts)

Regression

No response

Solution and workarounds

No response

DharshanBJ commented 2 months ago

@jaiGMS, we tried this flow with the sample app and we are not able to repro this issue, could you take the latest version of msal.net and check if you are still running into this issue?