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;

}

}

Monday, October 24, 2022

Means of Persisting Form Data

 There are many ways of persisting form data after the form has been submitted. Some of the more popular ways include the following:

  • The values of form fields can be stored in the Session object. Data can be added to the Session object with a line like this (in ASP.NET):

    Session("Name") = "Mike Davis";
    

    Session information can be stored in various locations: inside the ASP.NET runtime process, inside a dedicated Microsoft Windows® service, or inside a Microsoft SQL Server™ database. However, using the Session object, in any of these locations, is costly in server memory. In addition, you have to read the values out of session and put them back into the form on each page load. This routine code bulks up your pages.

  • Another option to persisting data is to duplicate your form content in a hidden field that is posted back to the server. The HiddenField control is used to store a value that needs to be persisted across posts to the server. It is rendered as an <input type= "hidden"/> element. Normally view state, session state, and cookies are used to maintain the state of a Web Forms page.


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 tr...