NAV

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 of your app being called using deep linking, that URL will also have a new parameter - app_state :

https://my.ecwid.com/cp/#app:name=my-cool-app&parent-menu=sales&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.

Default user authentication

Default user authentication

GET https://www.example.com/my-app-iframe-page#53035362c226163636573735f746f6b656e223a22776d6
{
  "store_id": 1003,
  "lang": "en",
  "access_token":"xxxxxxxxxxxxxxxx",
  "app_state":"orderId%3A%2012",
  "public_token":"public_QnWFi7GpGemRUvz3SJ18crtJ5ru8yjfy"
}

Get app state with Ecwid JS SDK

  var storeData = EcwidApp.getPayload();
  var storeId = storeData.store_id;
  var accessToken = storeData.access_token;
  var language = storeData.lang;

  if (storeData.public_token !== undefined){
    var publicToken = storeData.public_token;
  }

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

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 on the right.

Learn more about Default User Authentication

Enhanced security 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

Get app state from GET parameter

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

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 on the right.

Learn more about Enhanced Security User Authentication