Customizing the Android Agent Download Location for Tenants
Do you want the users who are under the tenant foo1.com
to download and install an Android agent that is different from the users under the tenant foo2.com
? This document guides you on how to change the Android agent download URL among tenants.Â
Follow the steps given below:
- Make a copy of theÂ
cdmf.unit.device.type.android.type-view
directory that is in theÂ<IOTS_HOME>/repository/deployment/server/jaggeryapps/devicemgt/app/units
directory in the same directory. - Rename the newly copied file as follows:
<TENANT_DOMAIN>.cdmf.unit.device.type.android.type-view
.
For example, if your tenant domain isfoo.com
the directory name needs to beÂfoo.com.
cdmf.unit.device.type.android.type-view
. - Remove the
t
ype-view.hbs
 files from theÂ<TENANT_DOMAIN>.
cdmf.unit.device.type.android.type-view
directory. - Update the following files in theÂ
<TENANT_DOMAIN>.
cdmf.unit.device.type.android.type-view
 directory.Open theÂ
type-view.js
 file and replace all the content in it with the following configurations:
Update theenrollmentURL
with the URL to download the agent.function onRequest(context) { var viewModel = {}; var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"]; var isCloud = devicemgtProps["isCloud"]; viewModel["isVirtual"] = request.getParameter("type") == 'virtual'; viewModel["isCloud"] = isCloud; viewModel["hostName"] = devicemgtProps["httpsURL"]; viewModel["enrollmentURL"] = "http://abc.com"; return viewModel; }
Open theÂ
type-view.json
 file and replace all the content in it with the following configurations:{ "version": "1.0.0", "extends": "cdmf.unit.device.type.android.type-view" }
Why am I extending this unit?
For this tutorial only the Android agent download URL changes. All the other content of the Android agent is the same. Therefore, all you need to do is extend the existingÂ
cdmf.unit.device.type.android.type-view
unit.
What's next?
- Sign in to WSO2 IoT Server's Device Management console. The username needs to be in the following format
<USERNAME>@TENANT_DOMAIN
. - Now, try enrolling an Android device and you see that the agent download URL has changed.