top of page
Search
  • Writer's picturePavel Chuvak

Intercom 6.1.0 for Xamarin


Hi everyone!

A while ago, one of my clients sent me an email with the request. He wanted to implement a real online chat into the app. He suggested using Intercom, as that solution has been already used on their website.


However, we faced the problem: Intercom doesn’t have a package for both Xamarin Native and Xamarin Forms. I decided to investigate the solutions, which the Xamarin community provides. I found a couple of options, but none of them were for Xamarin Forms. Moreover, most of them appeared to be out of date ;(


As a result, it was decided to create its own Xamarin wrapper for Intercom.



Installation

Intercom packages

Step 1 — Adding references to Intercom

If you are a new Intercom user, you’ll need to create an account and start your free trial period.

Android

Permissions

We include the INTERNET permission by default as we need it to make network requests:


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

You should also include the READ_EXTERNAL_STORAGE permission if you have enabled image attachments:

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>

You can also include VIBRATE to enable vibration in push notifications:

<uses-permission android:name="android.permission.VIBRATE"/>

iOS

Update Info.plist

Photo Library usage: Add a “Privacy — Photo Library Usage Description” entry to your Info.plist.

This is required by Apple for all apps that access the photo library. It is necessary when installing Intercom due to the image upload functionality. Users will be prompted for the photo library permission only when they tap the image upload button.

Step 2 — Initialize Intercom

First, you’ll need to get your Intercom app ID and Android API key. To find these, just select the ‘Intercom for Android/iOS’ option in your app settings.

Android

Then, initialize Intercom by calling the following in the onCreate() method of your Application class:

Intercom.initialize(this, "your api key", "your app id");

Note: If you don’t currently implement a custom application, you’ll need to create one. A custom application looks like this:

public class CustomApplication extends Application {
    @Override public void onCreate() {
        super.onCreate();
        Intercom.initialize(this, "your api key", "your app id");
   }
}

You’ll need to update your manifest to use your application:

<application
    android:name=".CustomApplication">
</application>

Intercom must be initialized inside the application onCreate() method. Initializing anywhere else will result in Intercom not behaving as expected and could even result in the host app crashing.

iOS

Then, initialize Intercom by calling the following in the FinishedLaunching() method of your AppDelegate class:

Intercom.SetApiKey("your api key", "your app id");

Step 3 — Create a user

Finally, you’ll need to create a user, like this:

Android

Registration registration = Registration.create().withUserId("123456");
Intercom.client().registerIdentifiedUser(registration);

iOS

Intercom.iOS.Intercom.RegisterUnidentifiedUser();

That’s it — now you’ve got a working Intercom app. However, you’ll need to register your users before you can talk to them and track their activity in your app. For more details, see Intercom for Android or Intercom for iOS.

To sum the things up, at the moment I am working on a package for Xamarin Forms. The next step will be the creation of the Xamarin library for the latest version of Intercom 7.2.0.

The full version of Inercom installing guide is available here — https://developers.intercom.com/installing-intercom/docs


  • Xamarin

  • Intercom

  • Nuget

  • Libraries

  • Xamarin Forms


59 views0 comments

Comentários


bottom of page