Mobincube protocol: sharing data with the native side

The core of all apps built with Mobincube is native. That means, it is developed using specific's platform native language (java on Android and objective-c on iOS). The native core manages all the app cycle, renders native screens and handles web-based addons.

One of the strengths of Mobincube addons is that they can interact with the native side of the app and/or with other addons. This is very useful in case you need to use some system values (location, file system, etc.) from within your addon. You can also get or set user vars and/or cookies in order to communicate with other parts of the app.

All this communication is handled by the app's internal protocol.


Documentation

All the documentation of Mobincube's app internal protocol is available at Mobincube's help site.


Basics of the Mobincube protocol

The communication protocol is based on the use of internal http requests. The native side of the app captures every attempt to change the window.location. Using the "mobincube://" protocol will tell the native side that you want to communicate with it, while the window.location will remain the same.

 ...
 window.location = "mobincube://action/section/main";
 ...

You can use the protocol in two ways:

  1. Invoke actions. (mobincube://action/[name_of_the_action]/[parameter])
  2. Make the native side call a javascript function to send data. (mobincube://javascript/myFunction(param1,param2,...)

For detailed information, please check Mobincube's help site.


Making consecutive requests

Because of using the window.location to send data to the native side, there might be some issues when trying to make two or more consecutive requests, since following requests will make the current request stop working. In case you need to make consecutive requests in the same function, you should nest them inside a timeout structure. Even if the timeout's time is zero, nested requests are put into a buffer, so they don't start until the previous request has finished.

window.location = "mobincube://action/set/{cookie.userID}=123456";
setTimeout(function(){
 windows.location = "mobincube://javascript/getLocation('{location}')";
});