PebbleKit JS can insert pins into the timeline directly from the phone. Local pins are created by the new Pebble app and synced to the watch, which means:
The new Pebble app does not support the timeline web API, so pins can no longer be pushed to users from a web server. Local pins are the only way to add pins to the timeline.
Pass a pin object (or a JSON string) in the format described in Creating Pins:
Pebble.insertTimelinePin({
id: 'local-pin-1',
time: new Date().toISOString(),
layout: {
type: 'genericPin',
title: 'Local pin',
tinyIcon: 'system://images/NOTIFICATION_FLAG'
}
});
The id is chosen by you and only needs to be unique within your app.
Inserting a pin with an id that already exists updates that pin, rather than
creating a second one.
Pins are removed using the same id they were inserted with:
Pebble.deleteTimelinePin('local-pin-1');
Apps written against the timeline web API do not need to be rewritten to keep
working. Requests made from PebbleKit JS to timeline-api.rebble.io or
timeline-api.getpebble.com under /v1/user/pins are intercepted by the phone
and turned into local pins instead of being sent to a server - a PUT or
POST inserts the pin in the request body, and a DELETE removes the pin
named in the URL. The request completes with a 200 response and an empty
body.
Only requests made by your app's JS are intercepted. Pins your backend pushes to the timeline web API will never reach the watch.
Interception can be turned off by the user with the 'Emulate Timeline Webservice' setting in the Pebble app, so new apps should call
Pebble.insertTimelinePin()directly.
Local pins use the pin format described in Creating Pins, with the following exceptions:
| Field | Behavior |
|---|---|
createNotification |
Ignored - no notification is shown when the pin is created. |
updateNotification |
Ignored - no notification is shown when the pin is updated. |
actions |
Ignored. Every local pin gets a 'Remove' action. |
primaryColor, secondaryColor, backgroundColor |
Ignored. |
All other fields, including duration and reminders, are supported.