在simply.js github 页面https://github.com/Meiguro/simplyjs/issues/11 上发现了一个类似的问题/问题。下面的代码示例来自 Meiguros 第一个答案。该代码将用户发送到您的配置网站,您应该将其配置为发送回 json。
您可能可以复制用于启用配置窗口的代码示例并将其粘贴到您的主 pebble app.js 文件的开头。不要忘记在 appinfo.json 文件中添加 "capabilities": [ "configurable" ],。如果您使用的是 cloudpebble,您应该转到应用程序的设置页面并确保选中可配置框。
var initialized = false;
Pebble.addEventListener("ready", function() {
console.log("ready called!");
initialized = true;
});
Pebble.addEventListener("showConfiguration", function() {
console.log("showing configuration");
//change this url to yours
Pebble.openURL('http://assets.getpebble.com.s3-website-us-east-1.amazonaws.com/pebble-js/configurable.html');
});
Pebble.addEventListener("webviewclosed", function(e) {
console.log("configuration closed");
// webview closed
var options = JSON.parse(decodeURIComponent(e.response));
console.log("Options = " + JSON.stringify(options));
});
(https://github.com/pebble-hacks/js-configure-demo/blob/master/src/js/pebble-js-app.js - 删除 https:// 后的空格)
然后将设置推回卵石,我认为您需要添加
Pebble.sendAppMessage(options);
就在之前
console.log("configuration closed");
// webview closed
我在这个 pebble 论坛帖子 http://forums.getpebble.com/discussion/12854/appmessage-inbox-handlers-not-getting-triggered-by-javascript-configuration-data 的最后一篇帖子中发现了这一点
您还可以在与 https://github.com/pebble-hacks/js-configure-demo 的代码示例相同的 git 中找到一个名为 configure.html 的配置网站示例,删除 https:// 后的空格
希望这对您实现目标有所帮助