Question

I'm trying to send a notification to my pebble watch. I'm using this code, which is basically 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);
}

I'm getting the message in LogCat, but no notification on the watch. The procedure seems simple enough, is there something too obvious I missed? Or is the documentation just incomplete?

Edit: The obvious questions:

  • Yes, the watch is connected
  • Yes, I have third party notifications enabled
Was it helpful?

Solution

Okay, this was my problem:

By default the Pebble app only sends notifications to the watch while the screen of the phone is off. For development I always have the screen active while the phone is connected via USB. So, the solution was: Enable the "Always send Notifications" option in the Pebble app.

Maybe this spares someone else a headache.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top