Android

This integration has been done with the IDE Visual Studio.

You can see it in this tutorial video or read the instructions below:

Adding Firebase Services

    1. To start you need a file called google-services.json. This file can be exported from the Firebase console. Move it to the root folder of your project.
    1. Add the services from indigitall to your AndroidManifest.xml as you can see below.
<manifest ...>
  <!-- ... -->
  <!-- START indigitall permissions -->
  <uses-permission android:name="android.permission.INTERNET" />
  <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
  <uses-permission android:name="android.permission.VIBRATE" />
  <uses-permission android:name="android.permission.WAKE_LOCK" />
  <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
  <!-- END indigitall permissions -->

  <application ...>
    <!-- ... -->

    <!-- START indigitall services -->
    <service android:name="com.indigitall.android.services.StatisticService" />
    <service android:name="com.indigitall.android.services.NightService" />
    <receiver android:name="com.indigitall.android.receivers.BootReceiver">
      <intent-filter>
        <action android:name="android.intent.action.BOOT_COMPLETED" />
      </intent-filter>
    </receiver>
    <receiver android:name="com.indigitall.android.receivers.LocationReceiver">
      <intent-filter>
        <action android:name="LocationReceiver.Action.LOCATION_UPDATE" />
      </intent-filter>
    </receiver>
    <service android:name="com.indigitall.android.services.FirebaseMessagingService">
      <intent-filter>
        <action android:name="com.google.firebase.MESSAGING_EVENT" />
      </intent-filter>
    </service>

    <meta-data android:name="indigitall.color" android:resource="@color/colorprimary" />
    <meta-data android:name="indigitall.icon" android:resource="@mipmap/launcher_foreground" />
    <!-- END indigitall services -->

  </application>
</manifest>

Adding HMS Services

Before you start, you have to add the following nuget package: Com.Indigitall.Xamarin.Hms

  1. To start you need a file called agconnect-services.json. This file can be exported from the Huawei developer console.

  2. Copy agconnect-services.json into the Assets folder of your project.

  3. Create a file HmsLazyInputStream.cs in the root of the project that will be used to read the content of agconnect-services.json.

250250
  1. Add the following code in the AttachBaseContext of the MainActivity to call HmsLazyInputStream.cs:
protected override void AttachBaseContext(Context context)
{
    base.AttachBaseContext(context);
    AGConnectServicesConfig config = AGConnectServicesConfig.FromContext(context);
    config.OverlayWith(new HmsLazyInputStream(context));
}
  1. Add the following code in HmsLazyInputStream.cs
using System;
using System.IO;
using Android.Content;
using Android.Util;
using Com.Huawei.Agconnect.Config;

namespace XamarinDemo.Droid
{
    public class HmsLazyInputStream : LazyInputStream
    {
        public HmsLazyInputStream(Context context) : base(context)
        {
        }

        public override Stream Get(Context context)
        {
            try
            {
                return context.Assets.Open("agconnect-services.json");
            }
            catch (Exception e)
            {
                Log.Error(e.ToString(), "Can't open agconnect file");
                return null;
            }
        }
    }
}
  1. Add the following HMS Nuget packages to have the push and location services in your application:
355355
  1. Add the HMS services indigitall in your AndroidManifest.xml.
<!--HMS Services START-->
<service android:name="Com.Huawei.Hms.Location.LocationServices"></service>
<service android:name="com.indigitall.android.hms.services.HMSMessagingService" android:exported="false">
    <intent-filter>
            <action android:name="com.huawei.push.action.MESSAGING_EVENT" />
    </intent-filter>
</service>
<!--HMS Services END-->