Deep linking

Native apps in Ecwid Control Panel support deep linking, which means that they can receive information prior to being loaded and opened. This can provide your app with a new level of interactivity with a user by reacting to the context, sent to your app.

This functionality is achieved by passing a URL-encoded value – app_state to your application prior to loading and opening it for a user.

Sending app state

A typical native application URL looks like this: https://my.ecwid.com/cp/CP.html#app:name=my-cool-app&parent-menu=sales

In case your app is called using deep linking, that URL will also have a new parameter - app_state : https://my.ecwid.com/cp/#app:name=my-cool-app&app_state=orderId%3A%2012

The app_state parameter value is a URL encoded string with a specific application state your app can understand and process.

Receiving app state

Receiving and processing the externally called app state depends on the type of user authentication you are using. See the details below.

{
  "store_id": 1003,
  "lang": "en",
  "access_token":"xxxxxxxxxxxxxxxx",
  "app_state":"orderId%3A%2012"
}

Default user authentication

GET https://www.example.com/my-app-iframe-page#53035362c226163636573735f746f6b656e223a22776d6

When using default user authentication, the app state will be delivered through the Ecwid JavaScript SDK in the EcwidApp.getPayload() method. Once it's called, you can save the user details and app state into your client-side variables. See example:

var storeData = EcwidApp.getPayload();

  if (storeData.app_state !== undefined){
    var appState = storeData.app_state;
  }

Learn more about Default User Authentication

Enhanced security user authentication

GET https://www.example.com/my-app-iframe-page?payload=353035362c226163636573735f746f6b656e223a22776d6&app_state=orderId%3A%2012&cache-killer=13532

When using enhanced security user authentication, the app state will be delivered as a GET parameter app_state of your iframe URL alongside the standard parameters. You can retrieve it just like any other value of a GET parameter on a server-side and then save and use it in your app code. See example:

<?php

// URL Encoded App state passed to the app
  if (isset($_GET['app_state'])){
    $app_state = $_GET['app_state'];
  }
?>

Learn more about Authentication in native apps