【问题标题】:Sending a Notification to Pebble向 Pebble 发送通知
【发布时间】:2013-05-13 17:35:31
【问题描述】:

我正在尝试向我的卵石手表发送通知。我用的是这段代码,基本上是the example from the website:

public void sendPebble(String title, String body) {
    final Intent i = new Intent("com.getpebble.action.SEND_NOTIFICATION");

    final Map<String, String> data = new HashMap<String, String>();
    data.put("title", title);
    data.put("body", body);

    final JSONObject jsonData = new JSONObject(data);
    final String notificationData = new JSONArray().put(jsonData).toString();
    i.putExtra("messageType", "PEBBLE_ALERT");
    i.putExtra("sender", "Test");
    i.putExtra("notificationData", notificationData);

    Log.d("Test", "Sending to Pebble: " + notificationData);
    sendBroadcast(i);
}

我在 LogCat 中收到消息,但手表上没有通知。该程序似乎很简单,我错过了一些太明显的东西吗?还是文档不完整?

编辑:显而易见的问题:

  • 是的,手表已连接
  • 是的,我启用了第三方通知

【问题讨论】:

  • 我认为你需要在清单文件中声明com.getpebble.action.SEND_NOTIFICATION,不确定,只是在想......
  • 如果我理解正确,只有接收类必须这样做。

标签: java android pebble-watch pebble-sdk


【解决方案1】:

好的,这是我的问题:

默认情况下,Pebble 应用仅在手机屏幕关闭时向手表发送通知。对于开发,当手机通过 USB 连接时,我总是让屏幕处于活动状态。因此,解决方案是:在 Pebble 应用中启用“始终发送通知”选项。

也许这会让其他人头疼。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-07-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多