Migration guide

This topic details how to migrate from MXO Cordova SDK to MXO CapacitorJS SDK.
  1. Uninstall the MXO Cordova Plugin.
    cordova plugin remove @medallia/mxo-cordova-sdk
  2. Migrate to CapacitorJS.
    See Cordova to Capacitor migration guide.
    Note: If you are using typeScript the compiler may throw an error stating that it can not find the MXO Types. You need to ignore those errors, using your preferred method, until you can migrate all the APIs as mentioned below.
  3. Install the MXO CapacitorJS Plugin.
  4. Migrate all MXO method calls.
    All MXO CapacitorJS SDK APIs return a Promise<MXOResult<T>> where <T> can be an MXO Type, null, or explicitly the MXOError Type. This is because CapacitorJS only supports returning JSObjects from Plugin APIs. For more information, see this open issue. This means that when migrating from MXO Cordova to MXO CapacitorJS you must now access the value property to get the result of an API which can be one of the Types mentioned above.
    For example let’s consider the API to get the current TID.
    • The Cordova Signature is () => Promise<null | string | MXOError>.
    • The Capacitor Signature is () => Promise<MXOResult<string>>.
    • In Cordova you would get the TID as follows:
      MedalliaMXO.getTid()
      	.then((tid) => {
      		console.log('getTid: ' + tid)
      	}
    • In CapacitorJS you must now unwrap the tid from the MXOResult:

      MedalliaMXO.getTid()
      	.then((mxoResult) => {
      		if(mxoResult.value && mxoResult.value.apiName) {
      			// error case
      			console.error(mxoResult.value)
      		} else {
      			console.log('getTid: ' + mxoResult.value)
      		}
      }
    All APIs will need to be migrated to follow this new pattern.
  5. Update all module imports.
    If you are using the module import syntax, you will need to update all module imports to use the new npm package.
    Using the TID example above it is expected that you will have the following import:
    import MedalliaMXO from '@medallia/mxo-capacitor-js-sdk'

For more information, see Getting started with CapacitorJS SDK.