我开发了一个自定义本机模块,以便在我的应用程序中保持屏幕清醒。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中的所有说明,但仍然无法执行。
我只是不打电话给我的模块正确或方式?
因此,为了继续测试,我将所有事情都恢复到了最初的检查员下载。如果我将其包含在我的主应用程序中并调用默认的“showAlert”,则会出现“此平台不支持方法”错误。同样,当使用检查员进行测试时,一切正常。 – Bill
你有没有到过这个底部?我有类似的问题。 – BiscuitBaker