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.
#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
}
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.
The session variable provided in an AppGlanceReloadCallback
The slice to add to the app's glance
The result of trying to add the slice to the app's glance
Clear any existing slices in the app's glance and trigger a reload via the provided 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
User-provided context that will be passed to the callback
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.
Describes how the slice should be visualized in the app's glance in the launcher.
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.
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.
Describes how the slice should be visualized in the app's glance in the launcher.
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.
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.
Describes how the slice should be visualized in the app's glance in the launcher.
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.
Describes how the slice should be visualized in the app's glance in the launcher.
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.
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.
Bitfield enum describing the result of trying to add an AppGlanceSlice to an app's glance.
The slice was successfully added to the app's glance.
The subtitle_template_string provided in the slice was invalid.
The subtitle_template_string provided in the slice was longer than 150 bytes.
The icon provided in the slice was invalid.
The provided slice would exceed the app glance's slice capacity.
The expiration_time provided in the slice expires in the past.
The AppGlanceReloadSession provided was invalid.
The ID of a published app resource defined within the publishedMedia section of package.json.
User-provided callback for reloading the slices in the app's glance.
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
The number of entries that can be added to the app's glance
User-provided context provided when calling app_glance_reload()
Can be used for the expiration_time of an AppGlanceSlice so that the slice never expires.
Can be used for the icon of an AppGlanceSlice so that the slice displays the app's default icon.
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!