Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
  1. Create a new Xamarin Android application in Visual Studio/Xamarin Studio

  2. Add.dll into your project: open the Solution Explorer →  right-click on the References → Choose Add Reference-> Click on Browse option  (on the bottom right angle) →  browse the binding file (.dll), and click OK

  3. Add Google Play Service into your project: right-click on Packages → Add Google Play Service → select  InstanceIDMessagingIdentityLocation and click Add Packages

  4. Mapp Android library requires the following dependencies (those dependencies can be downloaded using NuGet): 

    1. Google.Gson

    2. Xamarin.Android.Glide 

    3. Xamarin.Google.Dagger

    4. Xamarin.AndroidX.Media

  5. Add the Google Service Json file

    1. Copy google-services.json to the project folder

    2. Add google-services.json to the app project

    3. Right-click google-services.json

    4. Set the Build Action to GoogleServicesJson 

  6. The project must be on AndroidX and use Dex Compiler D8

  7. Create a class that extends Application. At the beginning of class import binding application:  

    Code Block
    using Appoxee;
    using Android.Gms.Common;
    using Appoxee.Push;


    And add the following code snippet: 

    Code Block
    languagec#
     [Service]
     [IntentFilter(new[] { "com.google.firebase.INSTANCE_ID_EVENT" })]
     [Application]
        public class MappApp : Application
        {
            const string TAG = "MyFirebaseIIDService";
            public MappApp(IntPtr handle, JniHandleOwnership ownerShip) : base(handle, ownerShip)
            {
            }
    
            public override void OnCreate()
            {
                base.OnCreate();
                AppoxeeOptions opt = new AppoxeeOptions();
                opt.SdkKey = "SDK_KEY";
                opt.GoogleProjectId = "GOOGLE_PROJECT_ID";
                opt.CepURL = "CEP_URL";
                opt.AppID = "APP_ID";
                opt.TenantID = "TENANT_ID";
                opt.NotificationMode = NotificationModeNotificationModes.BackgroundAndForeground;
    
                opt.Server = AppoxeeOptions.ServerForUsing.Test;
              
                Appoxee.EngageApoxee.Engage(this, opt); //
            }
    
            public bool IsPlayServicesAvailable()
            {
                int resultCode = GoogleApiAvailability.Instance.IsGooglePlayServicesAvailable(this);
                if (resultCode != ConnectionResult.Success)
                {
                    if (GoogleApiAvailability.Instance.IsUserResolvableError(resultCode))
                        Android.Util.Log.Debug(TAG, GoogleApiAvailability.Instance.GetErrorString(resultCode));
                    else
                    {
                        Android.Util.Log.Debug(TAG, "This device is not supported");
                        //Finish();
                    }
                    return false;
                }
                else
                {
                    Android.Util.Log.Debug(TAG, "Google Play Services is available.");
                    return true;
                }
            }
        }


    NotificationMode is an enum and you can choose one of three options:

    • BACKGROUND_ONLY - notification will show only when an app is closed or in idle mode.

    • BACKGROUND_AND_FOREGROUND - notification will show every time when a push notification comes.

    • SILENT_ONLY - notification never shows on the device.

    If you don't choose one of these options, by default is BACKGROUND_ONLY.  

    AppoxeeOptions.The server is an enum and you can choose one of four options:

    • L3

    • EMC

    • CROC

    • TEST

    An account manager will provide you info which one you should use in your application (L3, EMC or CROC). If you don't choose one of these options, by default is a TEST. 
    Our developers use TEST for development purpose purposes and you shouldn't use this one.

  8. In AndroidManifest.xml mandatory add internet permission:

    Code Block
    <uses-permission android:name="android.permission.INTERNET" />


    Within application tag you must add a receiver for push notification:

    Code Block
    <receiver android:name="com.google.firebase.iid.FirebaseInstanceIdInternalReceiver" android:exported="false" />
    <receiver android:name="com.google.firebase.iid.FirebaseInstanceIdReceiver" android:exported="true" android:permission="com.google.android.c2dm.permission.SEND">
         <intent-filter>
              <action android:name="com.google.android.c2dm.intent.RECEIVE" />
              <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
              <category android:name="${applicationId}" />
         </intent-filter>
    </receiver> 

  9. Add a callback when Engage finished all initialization, the callback will be called when Engaged is up and ready, or if server hand-shaking is failed.

    Code Block
    public void OnInitCompleted(bool p0, Java.Lang.Exception p1)
    {
       Log.Info(" ENGAGE", "init completed listener - MainActivity");
    }