2014-02-17 49 views
1

我开发了一个自定义本机模块,以便在我的应用程序中保持屏幕清醒。Trigger.io本机模块 - 此平台不支持此方法

测试与forgeInspector模块,并将其添加到通过trigger.io工具箱我的应用程序后,该错误显示在控制台日志:

[DEBUG] Returned: {"content":{"message":"Method not supported on this platform","type":"UNAVAILABLE","subtype":null},"callid":"CE53E970-807C-4179-8F02-BCAF4950A0AB","status":"error"} 

使用JavaScript,我通过以下调用模块:

forge.stayawake.showAlert('test alert box',function(){alert('success');},function(e){ alert(e); }); 

我module.js是:

forge.stayawake = { 
    showAlert: function (text, success, error) { 
     forge.internal.call('stayawake.showAlert', {text: text}, success, error); 
    } 
}; 

io.trigger.forge .android.modules.stayawake读取

package io.trigger.forge.android.modules.stayawake; 

import io.trigger.forge.android.core.ForgeApp; 
import io.trigger.forge.android.core.ForgeParam; 
import io.trigger.forge.android.core.ForgeTask; 
import android.app.AlertDialog; 
import android.content.DialogInterface; 

public class API { 
    public static void showAlert(final ForgeTask task, @ForgeParam("text") final String text) { 
     if (text.length() == 0) { 
      // Error if there is no text to show 
      task.error("No text entered"); 
      return; 
     } 
     task.performUI(new Runnable() { 
      public void run() { 
       AlertDialog.Builder builder = new AlertDialog.Builder(ForgeApp.getActivity()); 
       builder.setMessage(text).setCancelable(false).setPositiveButton("Ok", new DialogInterface.OnClickListener() { 
        public void onClick(DialogInterface dialog, int which) { 
         task.success(); 
        } 
       }); 
       AlertDialog alert = builder.create(); 
       alert.show(); 
      } 
     }); 
    } 
} 

作为对照试验,以确保模块实际上是正确加载我试图重新命名“stayawake.set”到“foo.test”,我得到确切的消息相同。

我也将所有事情都还原回了检查员的初始下载。如果我将它包含在我的主应用程序中,并调用默认的“showAlert”,我仍会得到错误Method not supported on this platform。同样,当使用检查员进行测试时,一切正常。

我遵循trigger.io中的所有说明,但仍然无法执行。

我只是不打电话给我的模块正确或方式?

+0

因此,为了继续测试,我将所有事情都恢复到了最初的检查员下载。如果我将其包含在我的主应用程序中并调用默认的“showAlert”,则会出现“此平台不支持方法”错误。同样,当使用检查员进行测试时,一切正常。 – Bill

+0

你有没有到过这个底部?我有类似的问题。 – BiscuitBaker

回答

2

在相同的情况下接收相同的错误后,我才发现自己错过了模块的Android的构建步骤:

https://trigger.io/docs/current/api/native_modules/the_basics.html

建筑/打包模块

Android

构建和导出你的模块 被包括在实际应用锻造:

  • 右键单击src文件夹并选择导出...

  • 使用向导到该文件夹​​的内容导出为一个JAR

  • 您必须包括JAR生成的类文件和资源(不需要Java源)

  • 保存该JAR在android/module.jar你模块文件夹。(module_name/module/android/module.jar

这里是我的设置截图:

Settings

当时我能够上传模块,包括它在我成功的项目,没有上述错误。

相关问题