CONTENTS

  • Introduction To Xamarin

  • Xamarin Features

  • Xamarin Architecture

  • Pros and Cons of  Xamarin

  • Xamarin vs React Native

Part 1

CONTENTS

  • Xamarin.Essentials

 

 

Part 2

-  Features

- Connectivity

- Preferences

- Version tracking

 

  • Xamarin Project Structure

 

 

Introduction to Xamarin 

  • Owned by Microsoft

  • Open-source platform for building modern application for iOs, Android and Windows with .NET

  • Abstraction layer that manages communication of shared code with underlying platform code.

Introduction to Xamarin 

Xamarin Features 

  • C# Language

  • Based on .Net Framework

  • Share code, test and business logic across platform

  • Write cross-platform applications in C# with Visual Code.

  • Provides access to platform-specific SDKs (Cocoa Touch - iOS, Android SDK) via simple C# syntax

Xamarin Architecture

*MCW : Managed Callable Wrappers

*ACW : Android Callable Wrappers

Xamarin.Android

*MCW : Managed Callable Wrappers

*ACW : Android Callable Wrappers

Pros

  • Full hardware support (camera, GPS)
  • Compatibility with MVC & MVVM architecture
  • Complete development ecosystem (C#, .NET & Visual Studio)
  • Open-source and free
  • Simplified maintenance
  • The Xamarin Component Store which provides a lot of components

Cons

  • Familiarity with platform-specific code might be needed
  • Minimal community support
  • Not a great choices for apps with complex UI
  • The large size of the application
  • UI development is time-consuming and not mobile-friendly

Pros and Cons 

       Xamarin

vs

XAMARIN REACT NATIVE
Code C# JavaScript
Compilation
iOS
AOT Interpreter
Compilation
Android
JIT/AOT JIT
Portability iOS
Android
Windows
Mac OS
iOS
Android
Code Reuse Up to 90% of code Up to 70% of code

       Xamarin

vs

XAMARIN REACT NATIVE
GitHub Stars 5k 69.3k
Price Open Source/Visual Studio for commercial use $539 - 2,999 Open Source
Community Large Large
Stability Has some issues with iOS development Stable and running

Company use Xamarin

Part 2

Xamarin project structure

Project Structure 

*Properties

- AndroidManifest.xml : Describes all of the requirements for Xamarin.Android application

- AssembyInfo.cs : .NET assembly metadata file.

Project Structure 

*References

- Contains the assemblies required to build and run the application.

Project Structure 

* Assets

- Contains the application needs to run including fonts, local data files and text files.

Project Structure 

* Resources

- Contains application resources such as strings, images and layouts.

Xamarin.Essentials

A library that provides cross-platform APIs for native device features

Xamarin.Essentials

Features:

 

  • App Information – Find out information about the application.
  • Battery – Easily detect battery level, source, and state.
  • Connectivity – Check connectivity state and detect changes.
  • Preferences – Quickly and easily add persistent preferences.
  • Version Tracking – Track the applications version and build numbers.
  • File Picker – Allow user to pick files from the device.

 

Xamarin.Essentials

Connectivity

The Connectivity class lets you monitor for changes in the device's network conditions, check the current network access, and how it is currently connected.

using Xamarin.Essentials;

var current = Connectivity.NetworkAccess;

if (current == NetworkAccess.Internet)
{
    // Connection to internet is available
}

Xamarin.Essentials

Connectivity

Network access falls into the following categories:

  • Internet – Local and internet access.

  • ConstrainedInternet – Limited internet access. Indicates captive portal connectivity, where local access to a web portal is provided, but access to the Internet requires that specific credentials are provided via a portal.

  • Local – Local network access only.

  • None – No connectivity is available.

  • Unknown – Unable to determine internet connectivity.

Xamarin.Essentials

Preferences

The Preferences class helps to store application preferences in a key/value store.

Supported Data Types

  • bool
  • double
  • int
  • float
  • long
  • string
  • DateTime
using Xamarin.Essentials;

namespace MyIPCS.FL.Core.Preference
{
    class XamarinPreferences : IPreferenceDelegate
    {
        public int Get(string key, int defaultValue)
        {
            return Preferences.Get(key, defaultValue);
        }

        public long Get(string key, long defaultValue)
        {
            return Preferences.Get(key, defaultValue);
        }

        public string Get(string key, string defaultValue)
        {
            return Preferences.Get(key, defaultValue);
        }.....

Xamarin.Essentials

Version Tracking

The VersionTracking class lets you check the applications version and build numbers along with seeing additional information such as if it is the first time the application launched ever or for the current version, get the previous build information, and more

using Xamarin.Essentials;

VersionTracking.Track();

Xamarin Android

By nur amirah

Xamarin Android

  • 130