Skip to content
Go to file

Latest commit


Git stats


Failed to load latest commit information.


Realtime messaging SDK for Xamarin. The Messaging Service is a highly-scalable pub/sub message broker. Using your favorite programming language you'll be able to broadcast messages to millions of users, reliably and securely. It's all in the cloud so you don't need to manage servers.


Supports Android, iOS, and Windows Phone 8 Silverlight.


Important ! Please make sure you install the sdk on all projects in the solution. You must install the nuget package on any pcl 'abstraction' projects as well as the platform specific projects.

This repository includes both the SDK and a sample application using Xamarin Forms iOS, Android, and Windows Phone 8 Silverlight. The SDK includes a platform agnosted Realtime.Messaging project as well as a platform specific 'plugin'. The Android version uses Binding Libraries. iOS uses SocketRocket Binding Libraries. The Windows Phone version uses Websockets Portable and rda.Sockets.



The SDK is avaliable via Nuget. Please include the NugetPackage to all projects. This includes the common PCL as well as your Xamarin platform project.


For IOS 9, you will need to include a key to your This may be done in notepad or any text editor.

App Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure. Temporary exceptions can be configured via your app's Info.plist file." (See also Apple's corresponding tech note.). One way to workaround: Add an NSAppTransportSecurity key to the Info.plist. Under that key, add a dictionary that contains a single NSAppTransportSecurity key set to true:

   <key>NSAllowsArbitraryLoads</key> <true/>


I had an issue where OKHttp was referenced twice in my android project (From modernhttpclient and This causes an error when building as it tried to include the java dependencies twice. The solution was to manually remove the reference (not the package, just the reference) from the Android project.

Dependency Service

I had issues with the dependency service and the linker. Simply put, the [Perserve] annotation sometimes works. If it fails, you will get a "Dependency Service Failed" exception. To fix this, we include a static Link() method within each platform implementation that may be called. This will guarantee that the linker will not strip the solution.

// Inside AppDelegate.cs

Push Notifications

Note: To receive Push Notifications when the app is closed you have to run the application on Release mode.

To include push notifications on your project you have to subscribe the channel with notifications SubscribeWithNotifications(Channel, true, OnMessage) and set the method setOnPushNotification(client_OnPushNotification) to your ortc client on MainView.cs:

		protected OrtcClient client;

          public void DoSubscribeNotifications(object s, EventArgs e)
			Log("Subscribing with notifications...");
			client.SubscribeWithNotifications(Channel, true, OnMessage);

        public MainView()
			client = new OrtcClient();
            client.ClusterUrl = ClusterUrlSSL;
            client.ConnectionMetadata = "Xamarin-" + new Random().Next(1000);
            client.HeartbeatTime = 2;
			//client.GoogleProjectNumber = GoogleProjectNumber;

            client.OnConnected += client_OnConnected;
            client.OnDisconnected += client_OnDisconnected;
            client.OnException += client_OnException;
            client.OnReconnected += client_OnReconnected;
            client.OnReconnecting += client_OnReconnecting;
            client.OnSubscribed += client_OnSubscribed;
            client.OnUnsubscribed += client_OnUnsubscribed;

        void client_OnPushNotification (object sender, string channel, string message, IDictionary payload)
			if (payload != null) {
				var payloadStr = "";
				foreach (var key in payload.Keys)
					payloadStr += key + ":" + payload [key] + ",";

				Write (string.Format ("Push Notification - channel: {0} ; message: {1}; payload: {2}", channel, message, payloadStr));
			} else {
				Write (string.Format ("Push Notification - channel: {0} ; message: {1}:", channel, message));

Note: On Android to use Push Notifications you have set your Google Project Number on your ortc client:

		client.GoogleProjectNumber = "YOUR_GOOGLE_PROJECT_NUMBER";

Finnally you have to do some platform specific configuration:

IOS - Push Notification Configuration

On your iOS project add the following code to AppDelegate.cs:

public override bool FinishedLaunching(UIApplication app, NSDictionary options)

		    Realtime.Messaging.CrossPushNotification.Initialize<Realtime.Messaging.CrossPushNotificationListener> ();

            LoadApplication(new App());

            return base.FinishedLaunching(app, options);
		const string TAG = "PushNotification-APN";
		public override void FailedToRegisterForRemoteNotifications(UIApplication application, NSError error)

			if (Realtime.Messaging.CrossPushNotification.Current is Realtime.Messaging.IOS.IPushNotificationHandler) 

		public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken)
			if (Realtime.Messaging.CrossPushNotification.Current is Realtime.Messaging.IOS.IPushNotificationHandler) 


		public override void DidRegisterUserNotificationSettings(UIApplication application, UIUserNotificationSettings notificationSettings)

        public override void DidReceiveRemoteNotification(UIApplication application, NSDictionary userInfo, Action completionHandler)
			if (CrossPushNotification.Current is IPushNotificationHandler) 

		public override void ReceivedRemoteNotification(UIApplication application, NSDictionary userInfo)
			if (Realtime.Messaging.CrossPushNotification.Current is Realtime.Messaging.IOS.IPushNotificationHandler) 

Android - Push Notification Configuration

On your droid project add the following code to /Properties/AndroidManifest.xml:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="" android:installLocation="auto" 
	package="YOUR_PACKAGE" ...>
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="" />

    <permission android:name="YOUR_PACKAGE.permission.C2D_MESSAGE" android:protectionLevel="signature" />
    <uses-permission android:name="YOUR_PACKAGE.permission.C2D_MESSAGE" />
	<application ...>
        <receiver android:name=""
                <action android:name="" />
                <category android:name="YOUR_PACKAGE" />


Sample of the messaging framework using Xamarin Forms. Source code included under /Sample/

Xamarin.Droid Client


  • Add your application keys to MainView.cs
  • Run the application


Post onto the Github issue system or contact me via my blog

About websockets in Xamarin



No releases published


You can’t perform that action at this time.