diff --git a/pebblekitjs/pebblekitjs-tests.ts b/pebblekitjs/pebblekitjs-tests.ts index f822e00434..8ed8891560 100644 --- a/pebblekitjs/pebblekitjs-tests.ts +++ b/pebblekitjs/pebblekitjs-tests.ts @@ -59,3 +59,18 @@ Pebble.timelineSubscriptions( console.log('Error getting subscriptions: ' + errorString); } ); + +Pebble.appGlanceReload( + [{ + layout: { + 'icon': 'system://images/HOTEL_RESERVATION', + 'subtitleTemplateString': 'Nice Slice!' + } + }], + function (appGlanceSlices) { + console.log('AppGlanceReload is successful'); + }, + function (appGlanceSlices) { + console.log('AppGlanceReload has failed'); + } +); diff --git a/pebblekitjs/pebblekitjs.d.ts b/pebblekitjs/pebblekitjs.d.ts index b28542732d..c4200a7f82 100644 --- a/pebblekitjs/pebblekitjs.d.ts +++ b/pebblekitjs/pebblekitjs.d.ts @@ -1,4 +1,4 @@ -// Type definitions for PebbleKit JS +// Type definitions for PebbleKit JS v4.0.0 // Project: https://developer.pebble.com/docs/js/Pebble/ // Definitions by: Makoto Kawasaki // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -15,6 +15,19 @@ declare namespace PebbleKit { response?: string; } + interface Layout { + icon: string; + subtitleTemplateString: string; + } + + /** + * The structure of an app glance. + */ + interface AppGlanceSlice { + expirationTime?: string; + layout: Layout; + } + interface AppMessageData { transactionId: string; } @@ -55,6 +68,14 @@ declare namespace PebbleKit { */ addEventListener(type: string, callback: (e: Event) => void): void; + /** + * Attaches an event handler to the specified events. Synonymous with addEventListener. + * Only applicable to Rocky.js applications. + * @param type The type of the event, from the three described above. + * @param callback A developer-defined function to receive any events of the type specified that occur. + */ + on(type: string, callback: (e: Event) => void): void; + /** * Remove an existing event listener previously registered with Pebble.addEventListener(). * @param type The type of the event listener to be removed. @@ -64,6 +85,16 @@ declare namespace PebbleKit { */ removeEventListener(type: string, callback?: (e: Event) => void): void; + /** + * Remove an existing event handler from the specified events. Synonymous with removeEventListener. + * Only applicable to Rocky.js applications. + * @param type The type of the event listener to be removed. + * See Pebble.addEventListener() for a list of available types. + * @param callback The existing developer-defined function that was previously registered. + * @see addEventListener + */ + off(type: string, callback?: (e: Event) => void): void; + /** * Show a simple modal notification on the connected watch. * @param title The title of the notificati @@ -137,6 +168,14 @@ declare namespace PebbleKit { */ getWatchToken(): string; + /** + * Triggers a reload of the app glance which first clears any existing slices and then adds the provided slices. + * @param appGlanceSlices + * @param onSuccess + * @param onFailure + */ + appGlanceReload(appGlanceSlices: AppGlanceSlice[], onSuccess: (appGlanceSlices: AppGlanceSlice[]) => void, onFailure: (appGlanceSlices: AppGlanceSlice[]) => void): void; + /** * to start displaying this webview * @param url