Tip: Hide that annoying iOS privacy prompt

Do your users get annoyed by the privacy prompt in iOS (13+) during logon?

iOS Privacy Prompt

The prompt is meant to let users know that they are being tracked using cookies. However, it can be annoying to the users. There is a way to hide it.

If you are developing on native iOS platform, it can be hidden by settings “prefersEphemeralWebBrowserSession” to true on browser before calling start method.

MSAL.NET provides a way to hide the prompt in version 4.31. SystemWebViewOptions has a new property iOSHidePrivacyPrompt. By default, this property is false. When the property is set to true and the options is added to PublicClientApplicationBuilder, it will hide the prompt.

e.g.

// Hide the privacy prompt
SystemWebViewOptions systemWebViewOptions = new SystemWebViewOptions()
                                                                                           { 
                                                                                               iOSHidePrivacyPrompt = true,
                                                                                           };

var authResult = await App.PCA.AcquireTokenInteractive(App.Scopes)
                                                   .WithParentActivityOrWindow(App.ParentWindow)
                                                   .WithSystemWebViewOptions(systemWebViewOptions)
                                                   .ExecuteAsync();

This can be added to the common code across the platforms as it ignores the platforms where it is not applicable. Updated sample can be seen here.

Unknown's avatar

Published by: Sameer Khandekar

I am a passionate software engineer who loves to work on Azure microservices, REST API, SDKs, and .NET apps using WPF, Xamarin, and MAUI. The work includes highly scalable geo-distributed services and an authentication library with nearly 500 million downloads. I also had fun integrating with hardware using Bluetooth (BLE). More here: https://www.sameer.blog/about/

Categories .net, dotnet, Xamarin, Xamarin.FormsTags, , Leave a comment

Leave a comment