【问题标题】:Worklight 6.1: How to add EULA to hybrid appWorklight 6.1:如何将 EULA 添加到混合应用程序
【发布时间】:2015-06-29 19:22:51
【问题描述】:

环境: 工作灯 6.1.0.2 道场 1.9.4

我们使用 Worklight 6.1 为 android、iOS 和 windows8 平台创建了一个混合应用程序。现在我们想在应用程序首次启动时向用户添加并显示最终用户许可协议 (EULA) 窗口。它应该有接受和拒绝按钮。如果用户点击接受按钮,那么他应该能够使用该应用程序。 我想知道,我们如何使用 Worklight 6.1 实现这一目标。

对此的任何帮助,将不胜感激。

【问题讨论】:

    标签: ibm-mobilefirst hybrid-mobile-app


    【解决方案1】:

    仅供参考,这里没有针对 Worklight 的特定内容。
    您可以通过多种方式实现这一点,而无需使用任何 Worklight API。

    你可以像这样实现它(未经测试的代码 - 你需要试验):

    1. 在 main.js 中创建一些全局变量 eulaAccepted:

      var eulaAccepted; // 您需要使用HTML5 Local Storage 处理此属性,以便在下次启动应用程序时保持该属性,并让应用程序采取相应措施。

    2. 然后,在wlCommonInit()

      function wlCommonInit() {
          if (!eulaAccepted) {
              displayEula();
          } else {
              displayApp();
          }
      }
      
    3. 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...
      }
      

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-14
      • 1970-01-01
      • 2015-07-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多