Worklight 6.1:如何将 EULA 添加到混合应用程序
Worklight 6.1: How to add EULA to hybrid app
环境:
工作灯 6.1.0.2
道场 1.9.4
我们使用 Worklight 6.1 为 android、iOS 和 windows8 平台创建了一个混合应用程序。现在我们想在应用首次启动时向用户添加并显示最终用户许可协议 (EULA) window。它应该有接受和拒绝按钮。如果用户点击接受按钮,那么他应该能够使用该应用程序。
我想知道,我们如何使用 Worklight 6.1 实现这一目标。
如有任何帮助,我们将不胜感激。
仅供参考,此处没有任何特定于 Worklight 的内容。
您可以使用任何 Worklight API 以多种方式 w/out 实现这一点。
你可以像这样实现它(未经测试的代码 - 你需要试验):
在main.js中创建一些全局变量eulaAccepted
:
var eulaAccepted;
// 您需要使用 HTML5 Local Storage 来处理此 属性,以便它在应用程序下次启动时持续存在,并让应用程序执行相应操作。
然后,在wlCommonInit()
:
function wlCommonInit() {
if (!eulaAccepted) {
displayEula();
} else {
displayApp();
}
}
在displayEula()
:
function displayEula() {
// either display a dialog using `WL.SimpleDialog`...
// Or maybe custom HTML with "accept" and "not accept" buttons
WL.SimpleDialog.show(
"Eula Agreement", "your-eula-text-here",
[{text: "Accept", handler: acceptEula },
{text: "Reject", handler: rejectEula}]
);
}
处理结果:
function acceptEula() {
eulaAccepted = true;
... // Some code that will store the `eulaAccepted` variable using HTML5 Local Storage API
displayApp();
}
function rejectEula() {
// Display some other custom HTML instead of your app.
// Maybe also additional logic to try again to accept the Eula...
}
环境: 工作灯 6.1.0.2 道场 1.9.4
我们使用 Worklight 6.1 为 android、iOS 和 windows8 平台创建了一个混合应用程序。现在我们想在应用首次启动时向用户添加并显示最终用户许可协议 (EULA) window。它应该有接受和拒绝按钮。如果用户点击接受按钮,那么他应该能够使用该应用程序。 我想知道,我们如何使用 Worklight 6.1 实现这一目标。
如有任何帮助,我们将不胜感激。
仅供参考,此处没有任何特定于 Worklight 的内容。
您可以使用任何 Worklight API 以多种方式 w/out 实现这一点。
你可以像这样实现它(未经测试的代码 - 你需要试验):
在main.js中创建一些全局变量
eulaAccepted
:var eulaAccepted; // 您需要使用 HTML5 Local Storage 来处理此 属性,以便它在应用程序下次启动时持续存在,并让应用程序执行相应操作。
然后,在
wlCommonInit()
:function wlCommonInit() { if (!eulaAccepted) { displayEula(); } else { displayApp(); } }
在
displayEula()
:function displayEula() { // either display a dialog using `WL.SimpleDialog`... // Or maybe custom HTML with "accept" and "not accept" buttons WL.SimpleDialog.show( "Eula Agreement", "your-eula-text-here", [{text: "Accept", handler: acceptEula }, {text: "Reject", handler: rejectEula}] ); }
处理结果:
function acceptEula() { eulaAccepted = true; ... // Some code that will store the `eulaAccepted` variable using HTML5 Local Storage API displayApp(); } function rejectEula() { // Display some other custom HTML instead of your app. // Maybe also additional logic to try again to accept the Eula... }