Skip to content

Commit

Permalink
GITBOOK-418: Add connect_webview.login_failed/succeeded events
Browse files Browse the repository at this point in the history
  • Loading branch information
DebbieAtSeam authored and gitbook-bot committed Aug 16, 2024
1 parent 584346b commit 12a6b17
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion docs/api-clients/events/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,11 @@ Noise sensors emit an event whenever a predefined noise threshold has been excee
| `access_code.unmanaged.removed` | An unmanaged `access_code` has been removed. |
| `connected_account.created` | A connected account has been imported into your Seam workspace. |
| `connected_account.connected` | Seam has established connection to or is reconnected to a connected account. |
| `connected_account.successful_login` | A webview login was successfully completed for a connected account. Sent even if the account was previously connected, and a separate webview login was completed. |
| `connected_account.disconnected` | Seam has lost connection to a connected account. Please ask the account owner to sign in to their account through a new connect webview again. |
| `connected_account.deleted` | A connected account has been deleted from your Seam workspace. |
| `connected_account.completed_first_sync` | Seam has finished the first sync of a connected account and devices are now available. |
| `connect_webview.login_succeeded` | <p>A login using a Connect Webview was completed successfully.</p><p>Sent even if the account was previously connected and a separate Connect Webview login was completed.</p> |
| `connect_webview.login_failed` | A login using a Connect Webview failed. |
| `device.accessory_keypad_connected` | An accessory keypad has been connected to a device. |
| `device.accessory_keypad_disconnected` | An accessory keypad has been disconnected from a device. |
| `device.connected` | A device has come online. |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,15 +251,15 @@ For more information, see [Webhooks](../../core-concepts/webhooks.md).

When you [host a Connect Webview in an HTML iframe](../../core-concepts/connect-webviews/embedding-a-connect-webview-in-your-app.md#embed-the-connect-webview-in-an-iframe), the [iframe](https://www.w3schools.com/html/html\_iframe.asp) uses `window.parent.postMessage` to send messages to the parent window that is hosting the iframe. `window.parent.postMessage` is a cross-origin communication mechanism available in web browsers.

Register an event listener for the parent window containing the iframe to monitor for `message` events. Specifically, listen for a `webview.login_successful` event. This event indicates that Seam has successfully established the connection to the user's device or ACS account. A `webview.login_failed` event indicates that the account connection did not complete successfully. Further, the `webview.login_failed` event contains an `error_code` and `error_message` to help you troubleshoot the issue.
Register an event listener for the parent window containing the iframe to monitor for `message` events. Specifically, listen for a `connect_webview.login_succeeded` event. This event indicates that Seam has successfully established the connection to the user's device or ACS account. A `connect_webview.login_failed` event indicates that the account connection did not complete successfully.

For example:

```javascript
window.addEventListener(
"message",
(event) => {
if (event.data?.event?.event_type === "webview.login_successful") {
if (event.data?.event?.event_type === "connect_webview.login_succeeded") {
// Do something.
}
},
Expand Down

0 comments on commit 12a6b17

Please sign in to comment.