pebble
  • Tutorials
  • Get the SDK
  • Guides
  • Documentation
  • Examples
  • Community
  • Blog
  • More
Privacy
Cookies
Publish

Pebble C API

  • Pebble C API
  • Moddable API (Alloy)
  • PebbleKit JS
  • PebbleKit iOS
  • PebbleKit Android
  • Foundation
    • Alloy
    • App
    • App Communication
    • App Glance
    • AppMessage
    • AppSync
    • AppWorker
    • DataLogging
    • DataStructures
      • UUID
    • Dictation
    • Dictionary
    • Event Service
      • AccelerometerService
      • AppFocusService
      • BatteryStateService
      • CompassService
      • ConnectionService
      • HealthService
      • TickTimerService
    • Exit Reason
    • Internationalization
    • Launch Reason
    • Logging
    • Math
    • Memory Management
    • Platform
    • Resources
      • File Formats
    • Storage
    • Timer
    • Wakeup
    • Wall Time
    • WatchInfo
  • Graphics
    • Draw Commands
    • Drawing Paths
    • Drawing Primitives
    • Drawing Text
    • Fonts
    • Graphics Context
    • Graphics Types
      • Color Definitions
  • User Interface
    • Animation
      • PropertyAnimation
    • Clicks
    • Layers
      • ActionBarLayer
      • BitmapLayer
      • MenuLayer
      • RotBitmapLayer
      • ScrollLayer
      • SimpleMenuLayer
      • StatusBarLayer
      • TextLayer
    • Light
    • Preferences
    • UnobstructedArea
    • Vibes
    • Window
      • ActionMenu
      • NumberWindow
    • Window Stack
  • Standard C
    • Format
    • Locale
    • Math
    • Memory
    • String
    • Time

App Glance

API for the application to modify its "glance" i.e. app menu subtitle.

Apps have the ability to show a temporary icon and subtitle in the app selection menu; this is known as a "glance". For example, the app might use it to display a preview of its current state such as the currently playing song or the number of pending notifications.

The glance is loaded with a stack of AppGlanceSlice structs; only the latest slice is shown, and they are set to expire at a certain time to show the next slice in the stack.

To update the glance with a stack of slices, you must define an AppGlanceReloadCallback and give it to app_glance_reload. The implementation of your AppGlanceReloadCallback should call app_glance_add_slice to add slices to the glance.

The main window's unload handler is usually a good place to call app_glance_reload.

PBL_PLATFORM_APLITE does not support App Glance. Example code:

#if !PBL_PLATFORM_APLITE
static void glance_reload_callback(AppGlanceReloadSession *session, size_t limit, void *context) {
  AppGlanceSlice slice = {
    .expiration_time = APP_GLANCE_SLICE_NO_EXPIRATION,
    .layout.icon = APP_GLANCE_SLICE_DEFAULT_ICON,
    .layout.subtitle_template_string = "hello!",
  };
  AppGlanceResult result = app_glance_add_slice(session, slice);
  if (result != APP_GLANCE_RESULT_SUCCESS){
    APP_LOG(APP_LOG_LEVEL_ERROR, "app_glance_add_slice() returned %d", result);
  }
}
#endif // !PBL_PLATFORM_APLITE

static void main_window_unload(Window *window) {
#if !PBL_PLATFORM_APLITE
  app_glance_reload(glance_reload_callback, NULL);
#endif // !PBL_PLATFORM_APLITE
}

Function Documentation

AppGlanceResult app_glance_add_slice(AppGlanceReloadSession * session, AppGlanceSlice slice)

Add a slice to the app's glance. This function will only succeed if called with a valid AppGlanceReloadSession that is provided in an AppGlanceReloadCallback.

Parameters

session

The session variable provided in an AppGlanceReloadCallback

slice

The slice to add to the app's glance

Returns

The result of trying to add the slice to the app's glance

void app_glance_reload(AppGlanceReloadCallback callback, void * context)

Clear any existing slices in the app's glance and trigger a reload via the provided callback.

Parameters

callback

A function that will be called to add new slices to the app's glance; even if the provided callback is NULL, any existing slices will still be cleared from the app's glance

context

User-provided context that will be passed to the callback

Data Structure Documentation

  • SDK 3
  • SDK 4
  • SDK 4.9+
struct AppGlanceSlice

An app's glance can change over time as defined by zero or more app glance slices that each describe the state of the app glance at a particular point in time. Slices are displayed in the order they are added, and they are removed at the specified expiration time.

Data Fields

struct AppGlanceSlice layout

Describes how the slice should be visualized in the app's glance in the launcher.

time_t expiration_time

The UTC time after which this slice should no longer be shown in the app's glance. Use APP_GLANCE_SLICE_NO_EXPIRATION if the slice should never expire.

struct AppGlanceSlice

An app's glance can change over time as defined by zero or more app glance slices that each describe the state of the app glance at a particular point in time. Slices are displayed in the order they are added, and they are removed at the specified expiration time.

Data Fields

struct AppGlanceSlice layout

Describes how the slice should be visualized in the app's glance in the launcher.

time_t expiration_time

The UTC time after which this slice should no longer be shown in the app's glance. Use APP_GLANCE_SLICE_NO_EXPIRATION if the slice should never expire.

struct AppGlanceSlice

An app's glance can change over time as defined by zero or more app glance slices that each describe the state of the app glance at a particular point in time. Slices are displayed in the order they are added, and they are removed at the specified expiration time.

Data Fields

AppGlanceSliceLayout layout

Describes how the slice should be visualized in the app's glance in the launcher.

time_t expiration_time

The UTC time after which this slice should no longer be shown in the app's glance. Use APP_GLANCE_SLICE_NO_EXPIRATION if the slice should never expire.

struct AppGlanceSliceLayout

Describes how the slice should be visualized in the app's glance in the launcher.

Data Fields

PublishedId icon

The published resource ID of the bitmap icon to display in the app's glance. Use APP_GLANCE_SLICE_DEFAULT_ICON to use the app's default bitmap icon.

const char * subtitle_template_string

A template string to visualize in the app's glance. The string will be copied, so it is safe to destroy after adding the slice to the glance. Use NULL if no string should be displayed.

Enum Documentation

enum AppGlanceResult

Bitfield enum describing the result of trying to add an AppGlanceSlice to an app's glance.

Enumerators

APP_GLANCE_RESULT_SUCCESS

The slice was successfully added to the app's glance.

APP_GLANCE_RESULT_INVALID_TEMPLATE_STRING

The subtitle_template_string provided in the slice was invalid.

APP_GLANCE_RESULT_TEMPLATE_STRING_TOO_LONG

The subtitle_template_string provided in the slice was longer than 150 bytes.

APP_GLANCE_RESULT_INVALID_ICON

The icon provided in the slice was invalid.

APP_GLANCE_RESULT_SLICE_CAPACITY_EXCEEDED

The provided slice would exceed the app glance's slice capacity.

APP_GLANCE_RESULT_EXPIRES_IN_THE_PAST

The expiration_time provided in the slice expires in the past.

APP_GLANCE_RESULT_INVALID_SESSION

The AppGlanceReloadSession provided was invalid.

Typedef Documentation

typedef uint32_t PublishedId

The ID of a published app resource defined within the publishedMedia section of package.json.

typedef struct AppGlanceReloadSession AppGlanceReloadSession
typedef void(* AppGlanceReloadCallback)(AppGlanceReloadSession *session, size_t limit, void *context)

User-provided callback for reloading the slices in the app's glance.

Parameters

session

A session variable that must be passed to app_glance_add_slice when adding slices to the app's glance; it becomes invalid when the AppGlanceReloadCallback returns

limit

The number of entries that can be added to the app's glance

context

User-provided context provided when calling app_glance_reload()

Macro Definition Documentation

#define APP_GLANCE_SLICE_NO_EXPIRATION ((time_t)0)

Can be used for the expiration_time of an AppGlanceSlice so that the slice never expires.

#define APP_GLANCE_SLICE_DEFAULT_ICON ((PublishedId)0)

Can be used for the icon of an AppGlanceSlice so that the slice displays the app's default icon.

Need some help?

Functions

  • app_glance_add_slice
  • app_glance_reload

Data Structures

  • AppGlanceSlice
  • AppGlanceSliceLayout

Enums

  • AppGlanceResult

Typedefs

  • PublishedId
  • AppGlanceReloadSession
  • AppGlanceReloadCallback

Macro Defintions

  • APP_GLANCE_SLICE_NO_EXPIRATION
  • APP_GLANCE_SLICE_DEFAULT_ICON

Getting Help

Do you have questions about the Pebble SDK?

Do you need some help understanding something on this page?

You can either take advantage of our awesome developer community and check out the SDK Help forums, or you can join us on the Discord!