Mocking Mobile Device

Sometimes it is may helpful to prove that the mobile part of unblu with an app is working from at least the server site. To do this, it is possible to call the URL which is normally navigated to by the mobile SDK. Furthermore a mock can be enabled to see if a session could be started.

The URL you would navigate to is:

<server-base-URL>/unblu/device?apiKey=<api-key>&namedarea=<named area>

where server-base-URL could be something like https://start.unblu.com.

The api-key must be set to the account which you want to test against, e.g. MZsy5sFESYqU7MawXZgR_w

The namedarea parameter can be omitted if there should be none used.

 

If the server is reachable, a short loading view appears and then there is a white page (normally this is in a hidden webview and should not have any UI).

As a normal browser is not our SDK, this is detected by the java script code and will result in the error inside the console "The provider returned a null object for the non op?e.api.MobileDeviceApiFactory], dependencies=null]". If this happens, it should normally work already with the mobile SDK.

 

To prove a session could also be started, it is possible to activate a mock device, which is used even if it is a normal device. Enable the property mobiledevice.mockDeviceEnabled. Additionally to be able to control the sessions, you must also enable the property mobiledevice.makeDeviceUnbluSessionManagerAvailable.

After both properties were enabled, in the browser console the object DeviceSessionManager is available. On this object you can call functions to start chat, pin sessions or terminate a session for example. See the class MobileDeviceSessionManagementService for details of the functions. If a function call requires a "callId", you can simply use an empty string as value. Examples:

DeviceSessionManager.startChatSession("My-Name");

DeviceSessionManager.joinPinSession("callId not used", "12356", "My-Name");


After a session has been started the image which is defined as base64 encoded string in the property mobiledevice.client.core.api.internal.MockMobileDeviceApi.mockDeviceImage. Per default this is only set in the IDE settings.