Adding javascript as a shortcut on kiosk mode screen

T
Teerapat
Gosoft (Thailand) Co.,Ltd.

Hi, Could you please suggest or any solution to add the javascript as below as a shortcut on kiosk mode

mobicontrol.agent.enterAdminMode();
        setTimeout(function() {
        const ACTION_CALL = "android.intent.action.CALL";
        const URI_CALL_NUMBER = "tel:*933%23";
        var intent = mobicontrol.android.createIntent()
            .withAction(ACTION_CALL)
            .withData(URI_CALL_NUMBER);
        mobicontrol.android.startActivity(intent);
        },5000);
        mobicontrol.agent.enterUserMode();
 
**Mobicontrol Server Version : 15.3**
**Device Kind : Android Enterprise**
Edited 3 months ago
SOTI MobiControl
ANSWERS
RS
Rafael Schäfer
3 months ago (edited 3 months ago)

You can just add it as a script to the template and assign this script to a button.

We use that to create a configurator lockjown screen creating an ini file as an enrollment step.

T
Teerapat
3 months ago

Thanks, I'm not sure about syntax to call function through the button. Could you checking for example as below was correct ?

<button onclick="MyFunction()">MyButton</button>

<script type="text/javascript">
function MyFunction(){
		mobicontrol.agent.enterAdminMode();
		setTimeout(function() {
  			const ACTION_CALL = "android.intent.action.CALL";
			const URI_CALL_NUMBER = "tel:*933%23";
				var intent = mobicontrol.android.createIntent()
    				.withAction(ACTION_CALL)
    				.withData(URI_CALL_NUMBER);
		mobicontrol.android.startActivity(intent);
		},5000);
		mobicontrol.agent.enterUserMode();
	}
</script>
RS
Rafael Schäfer
3 months ago

We use the submit functionality as we have a form to fill out before and I'm not too good in HTML and JS but here are some parts of it.

Sorry for the screenshot but if i try to use the coding here i always get errors and not able to post them.

MD
Matt Dermody Diamond Contributor
3 months ago
  1. Put the script in a *.cmd file
  2. Add the following at the top of the script to declare that it is a javascript based script
    • #!/usr/bin/env js
       
  3. Deliver the *.cmd file to the device (eg. Package, File Sync)
  4. Reference the *.cmd in your lockdown via a Custom action and then script:///sdcard/<yourscript>.cmd
  5. Add an icon and name for your lockdown item
  6. (optional) If using Native mode lockdown you'll also need to whitelist any of the activities that your script might be running. 
RR
Richard Rosso
2 months ago

As Matt said above, this is the easiest way I think to perform the task you mentioned, and it is also well used and tested. 

A
ASMOD@SOTI
2 months ago

Hi Teerapat,

Thanks for posting on SOTI Pulse.  Thanks Rafael, Matt and Richard for responding to the post, your expertise and willingness to help are greatly appreciated! 

Kindly let me know if your query has been resolved? If this post did not assist you in resolving the issue completely and you have additional questions, please do not hesitate to reach out or you can contact SOTI Support (support@soti.net) to open a new case and one of our support engineer will be there to assist you.

Kind Regards,

Technical Support | SOTI Inc. | Call Us | SOTI.net | Discussion Forum | Log a Case Online