The MSAL.NET library, or the Microsoft.Identity.Client helps your app acquire tokens from Azure AD B2C - in fact it's indispensable when performing any of the policies - as it handles shelling out to the system web views, communicating to B2C, and caching the tokens so the user doesn't have to log every time the app launches.
But there's something wrong with the iOS Simulator - because the token caching does not seem to persist between app launches and you're forced to login again and again and again.
But we don't have to live like this ... we can persist logins across app launches!
Persisting Login Tokens Across App Launches
The key to everything is to add an Entitlements.plist
file!
The file can be completely blank - nothing needs to be in it, it only needs to be a part of the iOS project.
Then, unless you need the entitlements for other things in your app - you can modify the build configurations such that the Entitlements.plist
are only included on Debug-iPhone Simulator builds.
On Visual Studio for Mac, that's found in the iOS project properties dialog, under the iOS Bundle Signing option.
Notice that for the Debug->iPhone configuration I do not have the Custom Entitlements set. It's only needed for the simulator.
That's It!
Add the Entitlements.plist
file. Keep it empty unless you need it for something else. Make sure it's added as the value for Custom Entitlements for the Debug->Simulator configuration iOS Build Signing setting and you're set!
Comments