I'm hoping someone can help me with this example script to be used as pre-install script in package studio to give the users a choise to click install when I update an app
I want to know where I should put in the bundleID or package name.
We can say that I want this to be used on soti surf (net.soti.surf).
#!/usr/bin/env js
var FIVE_MINUTES = 5 * 60 * 1000;
var ONE_HOUR = 60 * 60 * 1000;
var buttonLabels = ['Install now', 'Install in 5 minutes', 'Install in 1 hour'];
if (isAppRunningInForeground('com.acme.importantapp')) {
mobicontrol.message.createInfoDialog('Would you like to install ImportantApp?')
.withButtons(buttonLabels[0], buttonLabels[1], buttonLabels[2])
.withCallback(onConfirm).show();
}
function onConfirm(result) {
if (result.buttonIndex != null) {
switch (buttonLabels[result.buttonIndex]) {
case 'Install now':
installImportantPcg();
break;
case 'Install in 5 minutes':
setTimeout(installImportantPcg, FIVE_MINUTES);
break;
case 'Install in 1 hour':
setTimeout(installImportantPcg, ONE_HOUR);
break;
}
}
}
function installImportantPcg() {
// Do nothing - the normal return from the script will launch the package installation
}
function isAppRunningInForeground(app) {
return mobicontrol.app.foregroundActivities.filter(activity => activity.packageName == app).length > 0;
}