Wednesday, June 12, 2019

Accordion ListView implementation in Xamarin.Forms

Purpose of this blog is to implement listview inside another listview, technically its called as Accordian ListView or Expandable ListView. I didn't find any relevant or useful plugin to implement this in my project. While surfing internet, I found this link https://xamarinexplorer.com/2018/02/17/accordion-listview-in-xamarin-forms/ which helped me to incorporate accordion listview in my project.

In the above reference link, Author has demonstrated the accordion by implementing 2 levels of listview. As per my project requirement that was not sufficient because, my project demanded 3 levels of listview and also header for each listview. So I tried to implement the required extra features in my project with the example present in the above reference link. And mean while I thought of creating a similar app with 3 levels of listview and with header for each listview, so that it may help other developers who are interested in implementing these addition features.

I tried implementing accordion listview both in iOS and Android platforms. Please find the screen recording below:

 AndroidiOS

For source code please refer my github link https://github.com/GovardhanNag/AccordionListView-Xamarin.Forms

Reference:

Thursday, May 2, 2019

Send email from your app using SMTP, without using any external apps.

Intention of this post is to send email using SMTP protocol, without using any external applications(like Gmail, Outlook, and other mail applications). Here I'm making use of Xamarin.Forms to implement this concept. This post will help the cross platform developers, especially Xamarin developers to integrate SMTP in their applications.

We have plenty of plugins in Xamarin.Forms to send mail, but these plugins rely on the external mail applications which are installed in the users mobile. But our requirement is to send mail without invoking any external applications.

In this post and in my examples, I will use Gmail's SMTP address to configure email transactions. To do that we have to get access from Gmail for utilizing its SMTP. We have a simple steps below to enable this access:
  1. Login to your gmail account.
  2. Open the Url : https://myaccount.google.com/lesssecureapps in new tab, which look like the below screen shot:
  3. Enable Allow less secure apps switch to provide access to use gmail's SMTP.
Initial setup to utilize SMTP protocol is done, now we will understand some basics for SMTP host address and port numbers. Generic SMTP host address will be in the form of smtp.domain.com and default port will be 25. Since we are using gmail account, the SMTP address will look like smtp.gmail.com and the post number is 587. Now lets see how to use these details in our Xamarin.Forms application to send email.
  1. Create a simple .Net Standard application in Xamarin.Forms.
  2. In MainPage.xaml add some required fields for sending email.
    • To entry field 
    • Cc entry field 
    • Subject entry field 
    • Body editor field 
    • Send button
  3. In code behind page of MainPage i.e. MainPage.xaml.cs add below code in Send button click event.

Source code is available in Github : https://github.com/GovardhanNag/SendEmailViaSMTP. Download the project, update the NetworkCredentials with your google id and password. Run and enjoy testing. Please feel free to relay your comments, suggestions or corrections.

Reference Link:
https://docs.microsoft.com/en-us/dotnet/api/system.net.mail.smtpclient.sendasync?view=netframework-4.8

SSO login using Launcher in .NET MAUI

  Some of the scenarios require to open the external/system browser to perform oAuth 2.0 login and then receive the auth code via redirect U...