Integration of Xamarin.Forms requires the steps on this page in addition to those covered in the main Xamarin integration guide.


There are three files needed to add the Xtremepush functionality to your Xamarin.Forms app. These are the Xtremepush interface, and its implementation for the Android and iOS platforms.

Add the IXPushDelegate to the shared code section of your app.

Open the IXPushDelegate and be sure to change the namespace to your own.

Add the XPushDelegate.cs files from the Android and iOS folders to the relevant platform section. Again, afterwards, you will need to open these files and change the namespace to your own.

For Android, you will also need to add the nuget package Plugin.CurrentActivity and initialise the same in your Application class.

Using Xtremepush

Once the project has been set up with a common interface and implementations for each platform, use DependencyService to get the correct implementation at runtime.

Example to call hitTag:


The APIs available are:

//sends a single string tag to the platform

        //sends a tag key-value pair tag consisting of title and value to the platform
DependencyService.Get<IXPushDelegate>().HitTag("TagTitle", "TagValue");

        //sends an event to the platform

        //sends an event key-value pair tag consisting of title and value to the platform
DependencyService.Get<IXPushDelegate>().HitEvent("SampleEvent", "WithValue");

        //opens up the Xtremepush inbox

        //Sets subscribed to push messages as true or false

        //Sets the Id associated with the user

        //Returns an iDictionary containing details about device

        //Sends request to XPush to get list of push messages, 
                //uint offset = amount from latest to return messages
                //uint limit = number of messages to be returned
DependencyService.Get<IXPushDelegate>().GetPushList(offset, limit);

        //Marks a message as opened (This is tracked automatically so this is not required in most situations) 
                //string messageId = the id of the message to mark as opened

Using GetPushList


On Android, to handle the returned Message list, you must implement the IPushListListener interface.

This interface has a single method PushListReceived. An example is shown below.

public class MainApplication : Application, Application.IActivityLifecycleCallbacks, IPushListListener

        public void PushListReceived(IList<Message> p0, Java.Lang.Ref.WeakReference p1)
                foreach (Message m in p0){
                    Log.Debug("XPushExample", "create_time: " + m.Metadata["create_time"]);
            } catch (Exception e)
                Log.Debug("XPushExample", "Empty message list received");


On iOS, in the XPushDelagate.cs file, GetPushList takes a callback method as its third parameter. This is set as default, to a method called PushListCallback, which is also in the file. However you can change this to another method if you wish.

An example of an implementation on iOS:

public void GetPushList(uint offset, uint limit)
      //replace PushListCallback with your callback function if named differently
      XP.XPush.GetPushNotificationsOffset(offset, limit, PushListCallback);

public void PushListCallback(Foundation.NSArray arg1, Foundation.NSError arg2) {
          for (nuint i = 0; i < arg1.Count; i++){
              XP.XPMessage xpm = arg1.GetItem<XP.XPMessage>(i);
              System.Diagnostics.Debug.WriteLine("XPushExample - create_time: " + xpm.Metadata["create_time"]);
      } catch (Exception e)
          System.Diagnostics.Debug.WriteLine("XPushExample - Empty message list received");

Xtremepush Message Object

The XPush Message object contains the following keys:

  • ID: The ID of the message
  • Title: The title from the message
  • Text: The text of the message
  • Campaign ID: The ID of the Xtremepush campaign
  • Data: Data includes additional information such as payloads associated with message
  • MetaData: Additional data about the message, such as create_time and read (user clicked message)

Updated 6 months ago


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.