A demo app that showcases .NET MAUI development using a Model View View-Model pattern. The app allows to visualize and post data which is stored on a strapi CMS using JWT authentication. A sample test project is provided in order to illustrate how the business logic layer can be unit tested independently thanks to the loose coupling provided by the MVVM separation of concerns.
In order to run one should first setup the strapi project by running the following commands inside the strapi
directory
yarn install
yarn build
yarn start
Then the MauiApp can be compiled from visual studio and deployed to your device or simulator. Make sure that MauiAppExample\Shared.cs
contains the correct API base address since it is the one that will be used while the application is running.
The SecureStorage compatibility has been ensured only for iOS/MacCatalyst platforms, but it can be added for Windows or Android by following the steps reported on the official docs.
Here are the steps I had to accomplish in order to correctly use the SecureStorage API on both physical devices and the iOS simulator.
By following these steps I had to create a blank XCode project and deploy it to my iOS device (iPhone 11) in order to generate a provisioning file. The bundle identifier of the iOS app had to be the same of the MAUI app (com.companyname.mauiappexample
in this case).
I had to create the file Platforms/iOS/Entitlements.plist
in which I had to configure the keychain access group for the current bundle identifier. This can be done through the Visual Studio editor, otherwise the file can be edited manually pasting the following code (be sure to change the bundle identifier if it differs).
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>keychain-access-groups</key>
<array>
<string>$(AppIdentifierPrefix)com.companyname.mauiappexample</string>
</array>
</dict>
</plist>
Here's an explanation from the Microsoft Docs.
I had to source the custom Entitlements.plist
file in Platforms/iOS
(source it again if it was already sourced) and set the newly created provisioning profile and signing identity in the iOS bundle signing options in the project options menu. If possible, delete bin
and obj
folders and recompile the solution.