Android and iOS integration

EMMA has two SDK for Xamarin, one for Android and one for iOS. Both are "bindings" of the respective native libraries, therefore methods share name and how to integrate it is very similar to the native.

1. Download the SDK

  • iOS binding 4.5.2 of native SDK.
  • Android 4.5.3 of native SDK.

Download from Github

2. Add the .dll to the project

First, you have to import the EMMA SDK our Xamarin project. You have to add in the References folder, in this folder system libraries or third-party libraries are housed.

Captura_de_pantalla_2019-03-31_a_las_23.59.27.png

To add the SDK as a reference, copy the .dll file to the root folder of the project, then add the reference, giving right-click on the folder.

Captura_de_pantalla_2019-03-31_a_las_23.58.24.png

Once open the Edit Reference screen, access to the .Net Assembly tab and choose the .dll file.

Captura_de_pantalla_2019-04-01_a_las_0.07.35.png

Click OK and you have the SDK integrated into the project.

The Android procedure is the same, it will only be necessary to add a reference to the project next to the EMMA SDK binding, InstallReferrer.dll, this reference can be found with SDK dll in Github repository.

3. Start session

In both OS to start session, you must specify the use of the library in the code:

using EMMASDK; 

In Android add it to Application extension:

EMMA.Instance.StartSession(this);

You have to add the following code in AndroidManfiest.xml:

<meta-data 
     android:name="io.emma.SESSION_KEY" 
     android:value="@string/emma_session_key" />

in iOS in AppDelegate.cs:

EMMA.StartSession("<EMMA Session Key>");

NOTE: If you are using iOS XamarinForms, add the following attribute in the AppDelegate.cs:

public override UIWindow Window {
      get;
      set;
}

4. Dependencies (Android only)

To integrate the SDK in Android, add the following packages in order:

  1. Kwon.Squareup.OkHttp3.Logging-interceptor (3.9.1.1)
  2. Kwon.Squareup.Retrofit2.Retrofit-converter (2.3.0.1)
  3. Karamunting.Xamarin.BumpTech.Glide (v4.8.0)
  4. Xamarin.Firebase.Messaging (71.1733.0) Optional, only for push. You have check the box "Show pre-release" to activate it. 

Remember add the reference InstallReferrer.dll cited above.

5. Continue with integration

Once the above points, and you can use all the options offered by the SDK EMMA, you must consult the documentation of native libraries. The method names are identical, only changes the manner of invocation with C#.

Important

If you use push notifications, it is important to keep in mind that every time a Rebuild is made and a subsequent installation in Visual Studio, when the app is installed, the push token is invalidated because FCM detects that the app has been uninstalled. If this happens, uninstall the app manually and reinstall it, this will generate a new token. Before sending a test push from the EMMA platform, you can try the following Curl method to know if the token is valid. If "Not Registered" appears, the token has been invalidated.

integration documentation

6. Sample App

For viewing the sample app go to this GitHub repository:  

https://github.com/EMMADevelopment/EMMAXamarinSample

Have more questions? Submit a request

0 Comments

Article is closed for comments.