Stay organized with collections
Save and categorize content based on your preferences.
Contacts let your Glassware receive timeline items that it did not create.
Users must explicitly share a timeline item with your contact by tapping on a card's
Share menu item.
How they work
Once you create a sharing contact, sharing timeline cards follows this general flow:
Create a contact and define MIME types that your contact supports.
Insert the contact to your user's timeline.
The user receives a timeline item that has a Share menu item. Glassware must explicitly allow users to share their items with this menu item.
The user taps the timeline item, selects the Share menu item, and selects your contact.
The Mirror API creates a copy of the shared timeline card, gives your contact access to the copy, and inserts the copy into the user's timeline. Your Glassware cannot access the original timeline item.
You modify the shared timeline card and update the existing timeline card
with Timeline.update.
When to use them
By default, Glassware cannot access timeline items that it did not create,
so contacts allow Glassware to Glassware data sharing with user consent.
There are two main ways that your Glassware can use contacts:
Allow users to share your timeline items with other contacts: Add the
SHARE built-in menu item
to a timeline card. When users tap the share menu item, Glass displays a list
of possible contacts to share with.
Allow users to share timeline items with your Glassware: Create a contact
that represents your Glassware. When users want to share a timeline card, your
contact appears as an option. You can also declare a list of
acceptable MIME types
so that your contact only appears for cards that you are interested in.
To get notified of when users share a timeline card with your contact, you can
subscribe to timeline notifications.
All contacts must specify an id, which identifies the contact to the Glassware
receiving the notifications. You must also specify a
displayName and at least one imageUrls, which Glass uses to display
the contact information to the user.
The Mirror API allows you to
subscribe to notifications
that are sent when the user takes specific actions on a
Timeline Item or when the user location
has been updated. When you subscribe to a notification, you
provide a callback URL that processes the notification.
A notification from the Mirror API is sent as a POST request to the
subscribed endpoint containing a JSON request body.
The itemId attribute is the ID of the shared timeline item, which you can use
with Timeline.get to obtain the timeline item.
The following example shows a typical timeline item with a photo attachment:
Your service must respond to the API with a 200 OK HTTP status
code if no error occurred.
If your service responds with an error code, the Mirror API might
try to resend the notification to your service.
Receiving speech transcription
Users can share transcribed speech with your contact through the main voice menu.
There are currently two voice commands that your contact can use:
"take a note"
"post an update"
For example, a user can tell us about Chipotle's
upcoming birthday with the phrase: "Ok Glass... post an update to...
Cat Stream... Chipotle's birthday is tomorrow!"
If more than one Glassware registers a contact with the same voice command,
Glass displays a second-level menu showing the
displayName of each contact.
Users can then speak the contact of their choosing. If your contact's
displayName contains
unpronounceable characters or is not phonetic, use the
speakableName property
to declare the expected pronunciation of your sharing contact.
Captions for shared photos
Users have the ability to share photos with your Glassware with an accompanying
caption that they input with speech. The general user flow is:
The user taps a timeline item containing a photo, selects the Share
menu item, and selects your contact.
The user taps again within a short period of time to add a caption to the
photo.
The user speaks a caption.
The timeline item is shared with your Glassware as described previously in
How they work. In addition, the
timeline item's text property is
set with the user's transcribed caption.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-07-10 UTC."],[[["\u003cp\u003eGlassware contacts enable users to share timeline items, facilitating data sharing between users and your Glassware.\u003c/p\u003e\n"],["\u003cp\u003eUsers share timeline cards by selecting a "Share" menu item and choosing your contact, triggering a notification to your service.\u003c/p\u003e\n"],["\u003cp\u003eYou can define acceptable MIME types for your contact, enabling selective sharing of specific timeline card types.\u003c/p\u003e\n"],["\u003cp\u003eSubscribe to timeline notifications to receive updates when users share timeline items, including transcribed speech and photo captions, with your Glassware.\u003c/p\u003e\n"],["\u003cp\u003eCreate a contact with a clear display name and icon to represent your Glassware in the user's contact list for easy sharing.\u003c/p\u003e\n"]]],[],null,["Contacts let your Glassware receive timeline items that it did not create.\nUsers must explicitly share a timeline item with your contact by tapping on a card's\n**Share** menu item.\n\nHow they work\n\nOnce you create a sharing contact, sharing timeline cards follows this general flow:\n\n1. Create a contact and define MIME types that your contact supports.\n2. Insert the contact to your user's timeline.\n3. The user receives a timeline item that has a **Share** menu item. Glassware must explicitly allow users to share their items with this menu item.\n4. The user taps the timeline item, selects the **Share** menu item, and selects your contact.\n5. The Mirror API creates a copy of the shared timeline card, gives your contact access to the copy, and inserts the copy into the user's timeline. Your Glassware cannot access the original timeline item.\n6. If you [subscribed to share notifications](#subscribing_to_sharing_notifications), you receive a payload containing the timeline card's identifying information. You can then retrieve the timeline item with [Timeline.get](/glass/v1/reference/timeline/get).\n7. You modify the shared timeline card and update the existing timeline card with [Timeline.update](/glass/v1/reference/timeline/update).\n\nWhen to use them\n\nBy default, Glassware cannot access timeline items that it did not create,\nso contacts allow Glassware to Glassware data sharing with user consent.\n\nThere are two main ways that your Glassware can use contacts:\n\n- **Allow users to share your timeline items with other contacts** : Add the\n [`SHARE` built-in menu item](/glass/v1/reference/timeline/insert#menuItems.action)\n to a timeline card. When users tap the share menu item, Glass displays a list\n of possible contacts to share with.\n\n- **Allow users to share timeline items with your Glassware** : Create a contact\n that represents your Glassware. When users want to share a timeline card, your\n contact appears as an option. You can also declare a list of\n [acceptable MIME types](/glass/reference/contacts#acceptTypes)\n so that your contact only appears for cards that you are interested in.\n To get notified of when users share a timeline card with your contact, you can\n subscribe to timeline notifications.\n\nCreating a contact\n\nTo allow users to share timeline items with your Glassware, insert\na contact by POSTing a\n[JSON representation of a contact](/glass/v1/reference/contacts) to\nthe [insert REST endpoint](/glass/v1/reference/contacts/insert).\n\nAll contacts must specify an `id`, which identifies the contact to the Glassware\nreceiving the notifications. You must also specify a\n`displayName` and at least one `imageUrls`, which Glass uses to display\nthe contact information to the user.\n**Note:** For best results, use a PNG icon image that is 640 by 360 pixels with a transparent background for `imageUrls`. \n\nRaw HTTP \n\n POST /mirror/v1/contacts HTTP/1.1\n Authorization: Bearer {auth token}\n Content-Type: application/json\n Content-Length: {length}\n\n {\n \"id\": \"harold\"\n \"displayName\": \"Harold Penguin\",\n \"iconUrl\": \"https://developers.google.com/glass/images/harold.jpg\"\n \"priority\": 7\n }\n\nSubscribing to sharing notifications\n\nThe Mirror API allows you to\n[subscribe to notifications](/glass/reference/subscriptions/insert)\nthat are sent when the user takes specific actions on a\n[Timeline Item](/glass/reference/timeline) or when the user location\nhas been updated. When you subscribe to a notification, you\nprovide a callback URL that processes the notification.\n| **Note:** In production, your callback URL must support SSL. For development purposes, we provide an [subscription proxy server](/glass/subscription-proxy) that can forward notifications to your non-SSL development server.\n\nA notification from the Mirror API is sent as a `POST` request to the\nsubscribed endpoint containing a `JSON` request body. \n\nRaw HTTP \n\n {\n \"collection\": \"timeline\",\n \"itemId\": \"3hidvm0xez6r8_dacdb3103b8b604_h8rpllg\",\n \"operation\": \"INSERT\",\n \"userToken\": \"harold_penguin\",\n \"verifyToken\": \"random_hash_to_verify_referer\",\n \"userActions\": [\n {\n \"type\": \"SHARE\"\n }\n ]\n }\n\nThe `itemId` attribute is the `ID` of the shared timeline item, which you can use\nwith [Timeline.get](/glass/reference/timeline/get) to obtain the timeline item.\nThe following example shows a typical timeline item with a photo attachment: \n\n {\n \"id\": \"3hidvm0xez6r8_dacdb3103b8b604_h8rpllg\",\n \"attachments\": [\n {\n \"contentType\": \"image/jpeg\",\n \"id\": \"\u003cATTACHMENT_ID\u003e\"\n }\n ],\n \"recipients\": [\n {\n \"kind\": \"glass#contact\",\n \"source\": \"api:\u003cSERVICE_ID\u003e\",\n \"id\": \"\u003cCONTACT_ID\u003e\",\n \"displayName\": \"\u003cCONTACT_DISPLAY_NAME\u003e\",\n \"imageUrls\": [\n \"\u003cCONTACT_ICON_URL\u003e\"\n ]\n }\n ]\n }\n\nYour service must respond to the API with a `200 OK` HTTP status\ncode if no error occurred.\nIf your service responds with an error code, the Mirror API might\ntry to resend the notification to your service.\n| **Note:** The connection will time out after 10 seconds. If a long process is required, respond right away and do the process in another thread.\n\nReceiving speech transcription\n\nUsers can share transcribed speech with your contact through the main voice menu.\nThere are currently two voice commands that your contact can use:\n\n- \"take a note\"\n- \"post an update\"\n\nFor example, a user can tell us about Chipotle's\nupcoming birthday with the phrase: \"Ok Glass... post an update to...\nCat Stream... Chipotle's birthday is tomorrow!\"\n\nTo use voice commands:\n\n1. Specify the\n [`acceptCommands`](/glass/reference/contacts#acceptCommands)\n property with the appropriate\n [`type`](/glass/reference/contacts#acceptCommands.type):\n\n {\n ...\n\n \"displayName\": \"Cat Stream\",\n \"id\": \"CAT_STREAM\",\n \"acceptCommands\": [\n {\"type\": \"POST_AN_UPDATE\"}\n ]\n }\n\n2. Subscribe to timeline notifications\n to be notified that transcribed speech is available. Your Glassware receives\n a notification when this occurs:\n\n {\n \"collection\": \"timeline\",\n \"operation\": \"UPDATE\",\n \"userToken\": \"\u003cUSER_TOKEN\u003e\",\n \"verifyToken\": \"\u003cVERIFY_TOKEN\u003e\",\n \"itemId\": \"\u003cITEM_ID\u003e\",\n \"userActions\": [\n {\"type\": \"LAUNCH\"}\n ]\n }\n\n3. Use the `itemId` to fetch the timeline item:\n\n {\n \"id\": \"\u003cITEM_ID\u003e\",\n \"text\": \"Chipotle's birthday is tomorrow\",\n \"recipients\": [\n {\"id\": \"CAT_STREAM\"}\n ]\n }\n\n | **Note:** When you receive the shared timeline item, update the existing timeline card with [Timeline.update](/glass/reference/timeline/update) instead of creating a new one if you are modifying the item.\n4. If more than one Glassware registers a contact with the same voice command,\n Glass displays a second-level menu showing the\n [`displayName`](/glass/v1/reference/contacts#menuItems.values.displayName) of each contact.\n Users can then speak the contact of their choosing. If your contact's\n [`displayName`](/glass/v1/reference/contacts#menuItems.values.displayName) contains\n unpronounceable characters or is not phonetic, use the\n [`speakableName`](/glass/reference/contacts#speakableName) property\n to declare the expected pronunciation of your sharing contact.\n\nCaptions for shared photos\n\nUsers have the ability to share photos with your Glassware with an accompanying\ncaption that they input with speech. The general user flow is:\n\n1. The user taps a timeline item containing a photo, selects the **Share** menu item, and selects your contact.\n2. The user taps again within a short period of time to add a caption to the photo.\n3. The user speaks a caption.\n4. The timeline item is shared with your Glassware as described previously in [How they work](#how_they_work). In addition, the timeline item's [`text`](/glass/reference/timeline#text) property is set with the user's transcribed caption."]]