Book Image

Hands-On Mobile Development with .NET Core

By : Can Bilgin
Book Image

Hands-On Mobile Development with .NET Core

By: Can Bilgin

Overview of this book

.NET Core is the general umbrella term used for Microsoft’s cross-platform toolset. Xamarin, used for developing mobile applications, is one of the app model implementations for .NET Core infrastructure. In this book, you'll learn how to design, architect, and develop attractive, maintainable, and robust mobile applications for multiple platforms, including iOS, Android, and UWP, with the toolset provided by Microsoft using Xamarin, .NET Core, and Azure Cloud Services. This book will take you through various phases of application development using Xamarin, from environment setup, design, and architecture to publishing, with the help of real-world scenarios. Throughout the book, you'll learn how to develop mobile apps using Xamarin, Xamarin.Forms, and .NET Standard. You'll even be able to implement a web-based backend composed of microservices with .NET Core using various Azure services including, but not limited to, Azure App Services, Azure Active Directory, Notification Hub, Logic Apps, Azure Functions, and Cognitive Services. The book then guides you in creating data stores using popular database technologies such as Cosmos DB, SQL, and Realm. Finally, you will be able to set up an efficient and maintainable development pipeline to manage the application life cycle using Visual Studio App Center and Visual Studio Services.
Table of Contents (26 chapters)
Title Page
Copyright and Credits
About Packt
Contributors
Preface
Index

Preface

In this book, you will learn how to design and develop highly attractive, maintainable, and robust mobile applications for multiple platforms, including iOS, Android, and UWP, with the toolset provided by Microsoft using Xamarin, .NET Core, and Azure Cloud Services.

Who this book is for

This book is for mobile developers who wish to develop cross-platform mobile applications. Programming experience with C# is required. Some knowledge and understanding of core elements and of cross-platform application development with .NET is required.

What this book covers

Chapter 1, Getting Started with .NET Core, gives you a brief introduction to .NET Core while explaining the different tiers of the .NET Core infrastructure. Languages, runtimes, and extensions that can be used together with .NET Core will be discussed and analyzed.

Chapter 2, Xamarin, Mono, and .NET Standard, tries to explain the relationship between .NET Core and Xamarin. You will learn about how the Xamarin source code is executed with MonoTouch on iOS and Mono Runtime on Android. 

Chapter 3, Universal Windows Platform, discusses the components that allow UWP apps to be portable within the Windows 10 ecosystem and how they are associated with .NET Core.

Chapter 4Developing Mobile Applications with Xamarin, explains Xamarin and Xamarin.Forms development strategies, and we will create a Xamarin.Forms application that we will develop throughout the remainder of the book. We will also discuss the architectural models that might help us along the way.

Chapter 5, UI Development with Xamarin, takes a look at certain UI patterns that allow developers and UX designers to create a compromise between the user expectations and product demands in order to create a platform and product with a consistent user experience across platforms.

Chapter 6Customizing Xamarin.Forms, goes through the steps and procedures of customizing Xamarin.Forms without compromising the performance or user experience. Some of the features that will be analyzed include effects, behaviors, extensions, and custom renderers.

Chapter 7, Azure Services for Mobile Applications, discusses the fact that there are a number of services that are offered as services (SaaS), platform (PaaS), or infrastructure (IaaS), such as Notification Hub, Cognitive Services, and Azure Functions, that can change the impressions of the users regarding your application with little or no additional development hours. This chapter will give you a quick overview of using some of these services while developing .NET Core applications.

Chapter 8, Creating a Datastore with Cosmos DB, explains that Cosmos DB offers a multi-model and multi-API paradigm that allows applications to use multiple data models while storing application data with the most suitable API for the application, such as SQL, JavaScript, Gremlin, and MongoDB. In this chapter, we will create the data store for our application and implement the data access modules. 

Chapter 9, Creating Microservices Azure App Services, goes through the basics of Azure App Services, and we will create a simple data-oriented backend for our application using ASP.NET Core with authentication provided by Azure Active Directory. Additional implementation will include offline sync and push notifications.

Chapter 10, Using .NET Core for Azure Serverless, shows how to incorporate Azure Functions into our infrastructure to process data on different triggers, and integrate Azure Functions with a Logic App that will be used as a processing unit in our setup.

Chapter 11, Fluid Applications with Asynchronous Patterns, explains that when developing Xamarin applications and ASP.NET Core applications, both the task's framework and the reactive modules can help distribute the execution threads and create a smooth and uninterrupted execution flow. This chapter will go over some of the patterns associated with these modules and apply them to various sections of the application.

Chapter 12, Managing Application Data, explains that, in order to avoid data conflicts and synchronization issues, developers must be diligent regarding the procedures implemented according to the type of data at hand. This chapter will discuss the possible data synchronization and offline storage scenarios using products such as SQLite and Realm, as well as the out-of-the-box offline support provided by Azure App Services.

 

Chapter 13, Engaging Users with Notifications and the Graph API, briefly explains how notifications and the graph API can be used to improve user engagement by taking advantage of push notifications and the graph API. We will create a notification implementation for cross-platform applications using Azure Notification Hub. We will also create so-called activity entries for our application sessions so that we can create a timeline that is accessible on multiple platforms.

Chapter 14, Introducing Cognitive Services, adds speech recognition to our application using the speech API. Additionally, we will be creating a computer vision training set to categorize user-uploaded images. After the Xamarin tasks for Android and iOS are completed, we will be creating a simple machine learning example using the client SDK that's available for UWP.

Chapter 15, Azure DevOps and Visual Studio App Center, shows how to use Visual Studio Team Service and App Center to set up a complete automated pipeline for Xamarin applications that will connect the source repository to the final store submission.

Chapter 16, Application Telemetry with Application Insights, explains how Application Insights is a great candidate for collecting telemetry from Xamarin applications that use an Azure-hosted web service infrastructure because of its intrinsic integration with Azure modules, as well as the continuous export functionality for App Center telemetry.

Chapter 17, Automated Testing, discusses how to create unit and coded UI tests, and the architectural patterns that revolve around them. Data-driven unit tests, mocks, and Xamarin UI tests are some of the concepts that will be discussed.

Chapter 18, Deploying Azure Modules, demonstrates how to configure the ARM template for the Azure web service implementation, as well as other services (such as Cosmos DB and Notification Hub) that we used previously so that we can create deployments using the Visual Studio Team Services build and release pipeline. Introducing configuration values into the template and preparing it to create staging environments are our primary focus of this chapter.

Chapter 19, CI/CD with Azure DevOps, explains how developers can create fully automated templates for builds, testing, and deployments using the toolset provided with Visual Studio Team Services. In this chapter, we will set up the build and release pipeline for Xamarin in line with the Azure deployment pipeline.

To get the most out of this book

The book is primarily aimed at .NET developers with slim to moderate experience with Xamarin and .NET Core. The cloud infrastructure-related sections heavily use various services in the Azure cloud infrastructure. However, familiarity with basic management concepts of Azure portal should be enough for the more advanced topics.

For the code samples, a combination of Windows and macOS development environments are used throughout the book. The ideal setup to utilize the samples would be to use macOS together with a Windows 10 virtual machine. This way, samples from both environments can be used. 

The IDE of choice for implementing the code walk-throughs is Visual Studio 2019 on Windows, and Visual Studio for Mac on macOS. Visual Studio Code, which supports both platforms, can be used to create the scripting and Python examples.

Download the example code files

You can download the example code files for this book from your account at www.packt.com. If you purchased this book elsewhere, you can visit www.packt.com/support and register to have the files emailed directly to you.

You can download the code files by following these steps:

  1. Log in or register at www.packt.com.
  2. Select the SUPPORT tab.
  3. Click on Code Downloads & Errata.
  4. Enter the name of the book in the Search box and follow the onscreen instructions.

Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:

  • WinRAR/7-Zip for Windows
  • Zipeg/iZip/UnRarX for Mac
  • 7-Zip/PeaZip for Linux

The code bundle for the book is also hosted on GitHub at https://github.com/PacktPublishing/Hands-On-Mobile-Development-with-.NET-Core. In case there's an update to the code, it will be updated on the existing GitHub repository. Refer GitHub README for more details on prerequisites of services.

We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!

Download the color images

We also provide a PDF file that has color images of the screenshots/diagrams used in this book. You can download it here: https://www.packtpub.com/sites/default/files/downloads/9781789538519_ColorImages.pdf.

Conventions used

There are a number of text conventions used throughout this book.

CodeInText: Indicates code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles. Here isan example: "Mount the downloaded WebStorm-10*.dmg disk image file as another disk in your system."

A block of code is set as follows:

namespace FirstXamarinFormsApplication
{
    public partial class MainPage : ContentPage
    {
        public MainPage()
        {
            InitializeComponent();
            BindingContext = new MainPageViewModel();
        }
    }
}

 

 

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

public App ()
{
    InitializeComponent();
MainPage = new NavigationPage(new ListItemView());
}

Any command-line input or output is written as follows:

docker run -p 8000:80 netcore-usersapi

Bold: Indicates a new term, an important word, or words that you see onscreen. For example, words in menus or dialog boxes appear in the text like this. Here is an example: "Both the ALM process and the version control options are available under theAdvancedsection of the project settings."

Note

Warnings or important notes appear like this.

Note

Tips and tricks appear like this.

Get in touch

Feedback from our readers is always welcome.

General feedback: If you have questions about any aspect of this book, mention the book title in the subject of your message and email us at [email protected].

Errata: Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you have found a mistake in this book, we would be grateful if you would report this to us. Please visit www.packt.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details.

 

 

Piracy: If you come across any illegal copies of our works in any form on the Internet, we would be grateful if you would provide us with the location address or website name. Please contact us at [email protected] with a link to the material.

If you are interested in becoming an author: If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, please visit authors.packtpub.com.

Reviews

Please leave a review. Once you have read and used this book, why not leave a review on the site that you purchased it from? Potential readers can then see and use your unbiased opinion to make purchase decisions, we at Packt can understand what you think about our products, and our authors can see your feedback on their book. Thank you!

For more information about Packt, please visit packt.com.