【问题标题】:trigger.io native iOS module works in inspector, not apptrigger.io 本机 iOS 模块适用于检查器,而不是应用程序
【发布时间】:2013-12-05 02:20:59
【问题描述】:

我正在为 trigger.io 构建一个 iOS 模块。我让它在 ios-inspector 应用程序中按需要工作。

我已尝试按照此处的文档构建模块: https://trigger.io/docs/current/api/native_modules/the_basics.html#ios_2

我得到一个生成的inspector/ios-inspector/build/module.a,然后我将module.a 复制到module/ios/module.a

然后我进入触发工具包并修改版本号并上传新模块。然后在工具包应用部分,我选择新版本的模块并构建应用。

在我的应用代码中

  for(var prop in forge.my_module){
    console.log("prop==", prop, forge.my_module[prop]);
  }

我得到的唯一属性是:

[   INFO] Console.log: prop==,showAlert,function (c, b, a) {forge.internal.call("my_module.showAlert",{text:c},b,a);}

这是来自原始ios-inspector 项目的showAlert 方法。但是,我不再有该方法的任何 Objective C 代码。

我觉得我在这里错过了一个明显的步骤。

【问题讨论】:

    标签: ios trigger.io


    【解决方案1】:

    添加目标 C API 方法将允许您像这样调用它们:

    forge.internal.call('my_module.my_method', {my_param: 2});
    

    不会为您生成任何 JavaScript 方法,它们实际上是在 module/javascript/module.js 中明确定义的。制作模块时生成的默认module.js 包含如下内容:

    // Expose the native API to javascript
    forge.my_module = {
        showAlert: function (text, success, error) {
            forge.internal.call('my_module.showAlert', {text: text}, success, error);
        }
    };
    

    您应该可以在那里添加您的 API。详情请见https://trigger.io/docs/current/api/native_modules/adding_javascript.html

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-06-24
      • 2014-09-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-06-14
      相关资源
      最近更新 更多