Monday, January 13, 2025

How to add the .NET MAUI App Accelerator in Visual Studio

 To add the .NET MAUI App Accelerator in Visual Studio, follow these steps:

Prerequisites:

  1. Ensure you have Visual Studio 2022 (17.3 or later) installed on your machine.
  2. During installation, include the .NET Multi-platform App UI (MAUI) workload.

Steps to Add the .NET MAUI App Accelerator:

  1. Open Visual Studio: Launch Visual Studio on your system.

  2. Install the .NET MAUI Workload (if not installed):

    • Go to the Visual Studio Installer.
    • Modify your current installation of Visual Studio.
    • In the Workloads tab, check .NET Multi-platform App UI development.
    • Click Modify to install the necessary components.
  3. Launch the .NET MAUI App Accelerator:

    • Open Visual Studio and go to Extensions > Manage Extensions.
    • In the search bar, type Maui App Accelerator.
    • Select the appropriate entry and click Download.
  4. Restart Visual Studio: After downloading the extension, you need to restart Visual Studio to complete the installation.

  5. Use the App Accelerator:

    • After restarting, create a new project.
    • Look for the Maui App Accelerator template in the project types.
    • Select it and proceed with the configuration to generate a base .NET MAUI project structure with the accelerator’s features.
  6. Install Additional Dependencies (Optional): If your app requires specific libraries or templates, configure these after project creation via NuGet Package Manager.

Let me know if you need help with any step!

Tuesday, April 30, 2024

If you’re using Visual Studio to build your .NET MAUI app on a Mac, locating the IPA (iOS App Package) file can be a bit tricky

 If you’re using Visual Studio to build your .NET MAUI app on a Mac, locating the IPA (iOS App Package) file can be a bit tricky. Let’s explore where you can find it:

  1. Build Server Location:

    • When building a .NET MAUI app with a Mac as a build server, the “Show IPA File on Build Server” option in Visual Studio is grayed out.

    • However, you can still find the IPA file on the Mac.

    • Navigate to the following directory on your Mac:


~/Library/Caches/Xamarin/mtbs/builds

    • Replace ~ with your user’s home directory.

    • Keep in mind that the user’s Library folder is hidden by default. You can either:

      • Show hidden files using Cmd + Shift + . in Finder.
      • Navigate through the terminal or Finder’s “Go to folder…” option using Cmd + Shift + G.
  1. IPA File Location:

    • Inside the builds folder, you’ll find the generated IPA files corresponding to your .NET MAUI builds.


Remember that the ~/Library/Caches/Xamarin/mtbs/builds directory contains the IPA files created during the build process. If you encounter any issues or don’t see the expected files, double-check the path and ensure that you’re looking in the correct location.

Thursday, April 4, 2024

Open default email app in .NET MAUI

Sample Code:

 if (Email.Default.IsComposeSupported)

{

    string subject = "Hello!";

    string body = "Excellent!";

    string[] recipients = new[] { "Support@3MbSolutions.com", "Marketing@3MbSolutions.com" };


    var message = new EmailMessage

    {

        Subject = subject,

        Body = body,

        BodyFormat = EmailBodyFormat.PlainText,

        To = new List<string>(recipients)

    };


    await Email.Default.ComposeAsync(message);

}

If your project's Target Android version is set to Android 11 (R API 30) or higher, you must update your Android Manifest with queries that use Android's  package visibility requirements.

In the Platforms/Android/AndroidManifest.xml file, add the following queries/intent nodes in the manifest node:

<queries>

  <intent>

    <action android:name="android.intent.action.SENDTO" />

    <data android:scheme="mailto" />

  </intent>

</queries>


Monday, December 5, 2022

FIX :ERROR ITMS-90717: "INVALID APP STORE ICON. THE APP STORE ICON IN THE ASSET CATALOG IN '_____' CAN'T BE TRANSPARENT NOR CONTAIN AN ALPHA CHANNEL

 

When you upload the archive to the App Store using the tool from Xcode, you may get the following error:

1

ERROR ITMS-90717: "Invalid App Store Icon. The App Store Icon in the asset catalog in '_____.app' can't be transparent nor contain an alpha channel.

Reason: Your Icon image has feature: Alpha

Solution: Make a PNG without an alpha channel.

How to fix it:

Open file: Assets.xcassets From Runner > Runner > Assets.xcassets
1. Select the AppIcon item, scroll down to the bottom to select the image size 1024 pt.

2.Right-click : Open in Finder
3. Double Click on that photo to open
4. Select File > Export...
5. In the Export screen: Untick Alpha, save the image file 

6. Replace the entire App icon with that
Image 

7. Archive and Distribute => OK

 

Tuesday, November 1, 2022

Generate Random Numbers in .NET6

 We can generate random number using the following code:

Console.WriteLine("Generate Randoms!");

var objRandom = new Random();

var myValue = objRandom.Next();

Console.WriteLine($"{myValue}");

In the above example, you obtain an int number as result.

You can use the methods NextBytes and NextDouble to obtain the results to obtain random bytes or random doubles values.


In .NET 6 you can use the class RandomNumberGenerator present in the namespace System.Security.Cryptography.


  Console.WriteLine("Generate Randoms in .NET 6!");

   var objRandom = RandomNumberGenerator.Create();

   var objBytes = new byte[sizeof(int)]; // 4 bytes

   objRandom.GetNonZeroBytes(objBytes);

    var myResult = BitConverter.ToInt32(objBytes, 0);

    Console.WriteLine($"{myResult}");

Friday, October 28, 2022

Copy to Clipboard using Javascript

 Copying the text to clipboard makes it easier to use the web page, so users will definitely like this functionality. You can achieve it using JavaScript.

Note: For this function to work in production environment, make sure your website has SSL Certificate

Sample:

  <asp:Button ID="btnCopyResult" Visible ="false"   OnClientClick="CopyToClipBoard();"   class="btn btn-primary btn-sm"   runat="server" Text="Copy Result" />  

 <script type="text/javascript">

  function CopyToClipBoard()

 {

var sData = "Copy ME!";

try 

{

      navigator.clipboard.writeText(sData);

     return true;

 }

 catch (err) 

{

    alert('Could not write to clipboard', err);

    return false;

}

}

How to add the .NET MAUI App Accelerator in Visual Studio

 To add the .NET MAUI App Accelerator in Visual Studio, follow these steps: Prerequisites: Ensure you have Visual Studio 2022 (17.3 or lat...