Overview

Skill Level: Intermediate

Prerequisites

An app with the Xamarin 3.3.2.4 SDK (or earlier) installed.

Step-by-step

  1. The Xamarin Action subsystem has changed

    With the 3.3.2.5 release, the Action subsystem has changed. The new subsystem is much more flexible, but will require that you modify your existing code. This tutorial explains how to do it.

  2. Add OnStop and OnStart to MainActivity.cs on Android

    Add the following to the MainActivity.cs class in the Android subproject:

    protected override void OnStop()
    {
        base.OnStop();
        IBMMobilePushImpl.OnStop();
    }
    
    protected override void OnStart() 
    {
        base.OnStart();
        IBMMobilePushImpl.OnStart();
    }
    
  3. Remove old plugin files

    Do not use mce/plugins/*json files anymore.

  4. Update OnCreate in MainActivity.cs

    In MainActivity.cs’s OnCreate method, remove:

    var jsonActionString = this.Intent.GetStringExtra("action");
    if (jsonActionString != null)
    {
    	var jsonAction = JObject.Parse(jsonActionString);
    	JObject jsonPayload = null;
    	if (this.Intent.HasExtra("payload"))
    	{
    		jsonPayload = JObject.Parse(this.Intent.GetStringExtra("payload"));
    	}
    	var attribution = this.Intent.GetStringExtra("attribution");
    	int id=0;
    	try
    	{
    		id = Int32.Parse(this.Intent.GetStringExtra("id"));
    	}
    	catch { }
    
    	var mailingId = this.Intent.GetStringExtra("mailingId");
    	LoadApplication(new App(jsonAction, jsonPayload, attribution, mailingId, id));
    }
    else
    {
    	LoadApplication(new App());
    }
    

    and replace it with:

    LoadApplication(new App());
    
  5. Update the Application’s main class

    Remove this from Application’s main Class:

    public App (JObject jsonAction = null, JObject jsonPayload = null, String attribution = null, String mailingId = null, int id = 0)
    

    and replace it with

    public App()
    

    Next, remove this from the main class:

    if (jsonAction != null)
    {
        SDK.Instance.ExecuteAction(jsonAction, jsonPayload, attribution, mailingId, id);
    }
    

Expected outcome

An app with the Xamarin 3.3.2.5 SDK installed.

Join The Discussion

Your email address will not be published. Required fields are marked *