Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.16.0

Adds sounds for Push Notifications and Live Activities. Set `sound` to one of the 30 sounds bundled with the ActivitySmith app, such as `coin` or `glitch`, to `default` for the sound picked in the app, or to `none` for no sound.

## 1.15.0

Adds Push Notification dismissal. Pass a `notification_id` to `notifications.dismiss` to clear a Push Notification you already sent from the Lock Screen and Notification Center. History keeps it. Also adds `metrics.create` to create a Lock Screen Widget metric and set its label and format, such as currency or percent, and `devices.list` to list the iPhones and iPads paired to your account.
Expand Down
56 changes: 55 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,26 @@ activitysmith.notifications.send(
)
```

### Push Notification Sounds

Use `sound` to choose the sound a Push Notification plays. Omit it to play the Push Notifications sound picked in the ActivitySmith app under Settings > Sounds.

| Value | Behavior |
| --- | --- |
| `default` | Plays the sound picked on the device. This is the same as omitting `sound`. |
| `none` | Plays no sound. |
| A sound name | Plays one of the sounds bundled with the app: `arrive`, `bell`, `bells`, `bitflip`, `bloom`, `callout`, `chime`, `coin`, `corrupt`, `crest`, `cue`, `ding`, `drop`, `ember`, `emblem`, `flourish`, `glimmer`, `glint`, `glitch`, `lantern`, `nightfall`, `nudge`, `pixel`, `pop`, `signal`, `streak`, `tally`, `wand`, `whoosh`, or `zip`. |

Passive Push Notifications play no sound.

```python
activitysmith.notifications.send(
title="💸 New sale",
message="Pro plan, $29/month",
sound="coin",
)
```

### Replace a Push Notification

Every send returns a `notification_id`. Pass it to `replace` to update a Push Notification you already sent, for example when an incident you alerted on is resolved. The replacement takes the old notification's place on the Lock Screen and in history instead of stacking a second one. It arrives silently, without sound or waking the screen, and goes to the same recipients as the original.
Expand Down Expand Up @@ -404,6 +424,21 @@ For a countdown, send `duration_seconds`. You can update `title`, `subtitle`, `c

To start at 00:00 and count up, set `counts_down=False` and leave out `duration_seconds`.

To count down to a set time, send `timer_end_at` instead of `duration_seconds`. If the timer started earlier, also send `timer_start_at`. The progress bar then shows the time already gone.

```python
activitysmith.live_activities.stream(
"nightly-backup",
content_state=content_state(
title="Nightly Backup",
subtitle="uploading archive",
type="timer",
timer_start_at="2026-11-19T01:00:00Z",
timer_end_at="2026-11-19T02:00:00Z",
),
)
```

### End Live Activity

Call `end_stream(...)` with the same `stream_key` to dismiss the Live Activity. You can include final values before it is removed. Set `auto_dismiss_seconds` to dismiss it after a delay in seconds, or `auto_dismiss_minutes` for minutes. Use `0` for immediate dismissal. Seconds take precedence if both are set.
Expand Down Expand Up @@ -606,6 +641,25 @@ activitysmith.live_activities.stream(
)
```

### Live Activity Sounds

Starting a Live Activity plays the Live Activities sound picked in the ActivitySmith app. Updates and ends are silent. Set `sound` on a start, update, or end to choose its sound, with the same values as [Push Notification Sounds](#push-notification-sounds). A sound on an update or end also expands the Live Activity on the Lock Screen, so use it for moments that need attention, such as a failed step.

```python
activitysmith.live_activities.stream(
"deploy-api",
content_state=content_state(
title="Deploying API",
subtitle="Step 3 failed",
type="segmented_progress",
number_of_steps=4,
current_step=3,
color="red",
),
sound="glitch",
)
```

## Lock Screen Widgets

![Lock screen widgets](https://cdn.activitysmith.com/features/lock-screen-widgets.png)
Expand Down Expand Up @@ -697,7 +751,7 @@ Values can be strings, numbers, or booleans. Metadata supports up to 50 entries

## Tags

Use Tags to organize and filter Push Notification and Live Activity history. Tags are created automatically when you first use them. Sending Tags requires SDK version 1.10.0 or later.
Use Tags to organize and filter Push Notification and Live Activity history. Tags are created automatically when you first use them.

```python
activitysmith.notifications.send(
Expand Down
44 changes: 43 additions & 1 deletion activitysmith/client.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
from __future__ import annotations

from .normalization import normalize_metadata_request

from dataclasses import dataclass
from datetime import datetime
from typing import Any

from activitysmith_openapi.configuration import Configuration
Expand All @@ -17,7 +19,7 @@

from .normalization import normalize_live_activity_request, normalize_metric_request

SDK_VERSION = "1.15.0"
SDK_VERSION = "1.16.0"
SDK_HEADER_NAME = "X-ActivitySmith-SDK"
SDK_HEADER_VALUE = f"python-v{SDK_VERSION}"

Expand Down Expand Up @@ -188,6 +190,8 @@ def content_state(
upper_limit: int | float | None = None,
duration_seconds: int | float | None = None,
counts_down: bool | None = None,
timer_start_at: str | datetime | None = None,
timer_end_at: str | datetime | None = None,
color: str | None = None,
step_color: str | None = None,
auto_dismiss_seconds: int | None = None,
Expand All @@ -209,6 +213,8 @@ def content_state(
"upper_limit": upper_limit,
"duration_seconds": duration_seconds,
"counts_down": counts_down,
"timer_start_at": timer_start_at,
"timer_end_at": timer_end_at,
"color": color,
"step_color": step_color,
"auto_dismiss_seconds": auto_dismiss_seconds,
Expand All @@ -233,6 +239,7 @@ def _build_push_request(
metadata: Any | None = None,
icon: Any | None = None,
interruption_level: Any | None = None,
sound: Any | None = None,
) -> Any:
request_fields = _compact_dict(
{
Expand All @@ -248,6 +255,7 @@ def _build_push_request(
"metadata": metadata,
"icon": icon,
"interruption_level": interruption_level,
"sound": sound,
}
)

Expand Down Expand Up @@ -307,6 +315,8 @@ def _build_live_activity_request(
upper_limit: Any | None = None,
duration_seconds: Any | None = None,
counts_down: Any | None = None,
timer_start_at: Any | None = None,
timer_end_at: Any | None = None,
color: Any | None = None,
step_color: Any | None = None,
auto_dismiss_seconds: Any | None = None,
Expand All @@ -318,6 +328,7 @@ def _build_live_activity_request(
channels: Any | None = None,
tags: Any | None = None,
metadata: Any | None = None,
sound: Any | None = None,
) -> Any:
content_state_fields = _compact_dict(
{
Expand All @@ -335,6 +346,8 @@ def _build_live_activity_request(
"upper_limit": upper_limit,
"duration_seconds": duration_seconds,
"counts_down": counts_down,
"timer_start_at": timer_start_at,
"timer_end_at": timer_end_at,
"color": color,
"step_color": step_color,
"auto_dismiss_seconds": auto_dismiss_seconds,
Expand All @@ -352,6 +365,7 @@ def _build_live_activity_request(
"channels": channels,
"tags": tags,
"metadata": metadata,
"sound": sound,
}
)

Expand Down Expand Up @@ -413,6 +427,7 @@ def send(
metadata: Any | None = None,
icon: Any | None = None,
interruption_level: Any | None = None,
sound: Any | None = None,
):
request = _build_push_request(
request,
Expand All @@ -428,6 +443,7 @@ def send(
metadata=metadata,
icon=icon,
interruption_level=interruption_level,
sound=sound,
)
normalized = normalize_metadata_request(_validate_push_request(_normalize_channels_target(request)))
return self._api.send_push_notification(
Expand Down Expand Up @@ -550,6 +566,8 @@ def start(
upper_limit: Any | None = None,
duration_seconds: Any | None = None,
counts_down: Any | None = None,
timer_start_at: Any | None = None,
timer_end_at: Any | None = None,
color: Any | None = None,
step_color: Any | None = None,
action: Any | None = None,
Expand All @@ -559,6 +577,7 @@ def start(
channels: Any | None = None,
tags: Any | None = None,
metadata: Any | None = None,
sound: Any | None = None,
):
request = _build_live_activity_request(
request,
Expand All @@ -577,6 +596,8 @@ def start(
upper_limit=upper_limit,
duration_seconds=duration_seconds,
counts_down=counts_down,
timer_start_at=timer_start_at,
timer_end_at=timer_end_at,
color=color,
step_color=step_color,
action=action,
Expand All @@ -586,6 +607,7 @@ def start(
channels=channels,
tags=tags,
metadata=metadata,
sound=sound,
)
return self._api.start_live_activity(
live_activity_start_request=_normalize_channels_target(request)
Expand All @@ -611,12 +633,15 @@ def update(
upper_limit: Any | None = None,
duration_seconds: Any | None = None,
counts_down: Any | None = None,
timer_start_at: Any | None = None,
timer_end_at: Any | None = None,
color: Any | None = None,
step_color: Any | None = None,
action: Any | None = None,
secondary_action: Any | None = None,
tags: Any | None = None,
metadata: Any | None = None,
sound: Any | None = None,
):
request = _build_live_activity_request(
request,
Expand All @@ -636,12 +661,15 @@ def update(
upper_limit=upper_limit,
duration_seconds=duration_seconds,
counts_down=counts_down,
timer_start_at=timer_start_at,
timer_end_at=timer_end_at,
color=color,
step_color=step_color,
action=action,
secondary_action=secondary_action,
tags=tags,
metadata=metadata,
sound=sound,
)
return self._api.update_live_activity(live_activity_update_request=request)

Expand Down Expand Up @@ -672,6 +700,7 @@ def end(
secondary_action: Any | None = None,
tags: Any | None = None,
metadata: Any | None = None,
sound: Any | None = None,
):
request = _build_live_activity_request(
request,
Expand All @@ -698,6 +727,7 @@ def end(
secondary_action=secondary_action,
tags=tags,
metadata=metadata,
sound=sound,
)
return self._api.end_live_activity(live_activity_end_request=request)

Expand All @@ -721,6 +751,8 @@ def stream(
upper_limit: Any | None = None,
duration_seconds: Any | None = None,
counts_down: Any | None = None,
timer_start_at: Any | None = None,
timer_end_at: Any | None = None,
color: Any | None = None,
step_color: Any | None = None,
action: Any | None = None,
Expand All @@ -730,6 +762,7 @@ def stream(
channels: Any | None = None,
tags: Any | None = None,
metadata: Any | None = None,
sound: Any | None = None,
):
request = _build_live_activity_request(
request,
Expand All @@ -748,6 +781,8 @@ def stream(
upper_limit=upper_limit,
duration_seconds=duration_seconds,
counts_down=counts_down,
timer_start_at=timer_start_at,
timer_end_at=timer_end_at,
color=color,
step_color=step_color,
action=action,
Expand All @@ -757,6 +792,7 @@ def stream(
channels=channels,
tags=tags,
metadata=metadata,
sound=sound,
)
return self._api.reconcile_live_activity_stream(
stream_key=stream_key,
Expand All @@ -783,6 +819,8 @@ def end_stream(
upper_limit: Any | None = None,
duration_seconds: Any | None = None,
counts_down: Any | None = None,
timer_start_at: Any | None = None,
timer_end_at: Any | None = None,
color: Any | None = None,
step_color: Any | None = None,
auto_dismiss_minutes: Any | None = None,
Expand All @@ -791,6 +829,7 @@ def end_stream(
alert: Any | None = None,
tags: list[str] | None = None,
metadata: dict[str, Any] | None = None,
sound: str | None = None,
):
request = _build_live_activity_request(
request,
Expand All @@ -809,6 +848,8 @@ def end_stream(
upper_limit=upper_limit,
duration_seconds=duration_seconds,
counts_down=counts_down,
timer_start_at=timer_start_at,
timer_end_at=timer_end_at,
color=color,
step_color=step_color,
auto_dismiss_minutes=auto_dismiss_minutes,
Expand All @@ -817,6 +858,7 @@ def end_stream(
alert=alert,
tags=tags,
metadata=metadata,
sound=sound,
)
return self._api.end_live_activity_stream(
stream_key=stream_key,
Expand Down
6 changes: 3 additions & 3 deletions activitysmith_openapi/api/live_activities_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,7 @@ def reconcile_live_activity_stream(
) -> LiveActivityStreamPutResponse:
"""Start a new Live Activity or update an existing one

Use a stable stream_key for each ongoing thing you want to show as a Live Activity. Send the latest content_state whenever it changes, and ActivitySmith will keep the Live Activity in sync. For timer streams, send duration_seconds to start or reset the timer; omit duration_seconds on later updates to preserve the existing timer window. Use secondary_action for a second button on alert, progress, segmented_progress, and value Live Activities. Optional tags to organize and filter notification history. On later stream updates, omit tags to keep the current tags, send tags again to replace them, or send an empty array to clear them.
Use a stable stream_key for each ongoing thing you want to show as a Live Activity. Send the latest content_state whenever it changes, and ActivitySmith will keep the Live Activity in sync. For timer streams, send duration_seconds to start or reset the timer, and timer_start_at when the timer started earlier, for example to show time already gone in the progress bar. Omit them on later updates to preserve the existing timer window. Use secondary_action for a second button on alert, progress, segmented_progress, and value Live Activities. Optional tags to organize and filter notification history. On later stream updates, omit tags to keep the current tags, send tags again to replace them, or send an empty array to clear them.

:param stream_key: Stable identifier for one ongoing thing. Allowed characters: letters, numbers, underscores, and hyphens. (required)
:type stream_key: str
Expand Down Expand Up @@ -718,7 +718,7 @@ def reconcile_live_activity_stream_with_http_info(
) -> ApiResponse[LiveActivityStreamPutResponse]:
"""Start a new Live Activity or update an existing one

Use a stable stream_key for each ongoing thing you want to show as a Live Activity. Send the latest content_state whenever it changes, and ActivitySmith will keep the Live Activity in sync. For timer streams, send duration_seconds to start or reset the timer; omit duration_seconds on later updates to preserve the existing timer window. Use secondary_action for a second button on alert, progress, segmented_progress, and value Live Activities. Optional tags to organize and filter notification history. On later stream updates, omit tags to keep the current tags, send tags again to replace them, or send an empty array to clear them.
Use a stable stream_key for each ongoing thing you want to show as a Live Activity. Send the latest content_state whenever it changes, and ActivitySmith will keep the Live Activity in sync. For timer streams, send duration_seconds to start or reset the timer, and timer_start_at when the timer started earlier, for example to show time already gone in the progress bar. Omit them on later updates to preserve the existing timer window. Use secondary_action for a second button on alert, progress, segmented_progress, and value Live Activities. Optional tags to organize and filter notification history. On later stream updates, omit tags to keep the current tags, send tags again to replace them, or send an empty array to clear them.

:param stream_key: Stable identifier for one ongoing thing. Allowed characters: letters, numbers, underscores, and hyphens. (required)
:type stream_key: str
Expand Down Expand Up @@ -794,7 +794,7 @@ def reconcile_live_activity_stream_without_preload_content(
) -> RESTResponseType:
"""Start a new Live Activity or update an existing one

Use a stable stream_key for each ongoing thing you want to show as a Live Activity. Send the latest content_state whenever it changes, and ActivitySmith will keep the Live Activity in sync. For timer streams, send duration_seconds to start or reset the timer; omit duration_seconds on later updates to preserve the existing timer window. Use secondary_action for a second button on alert, progress, segmented_progress, and value Live Activities. Optional tags to organize and filter notification history. On later stream updates, omit tags to keep the current tags, send tags again to replace them, or send an empty array to clear them.
Use a stable stream_key for each ongoing thing you want to show as a Live Activity. Send the latest content_state whenever it changes, and ActivitySmith will keep the Live Activity in sync. For timer streams, send duration_seconds to start or reset the timer, and timer_start_at when the timer started earlier, for example to show time already gone in the progress bar. Omit them on later updates to preserve the existing timer window. Use secondary_action for a second button on alert, progress, segmented_progress, and value Live Activities. Optional tags to organize and filter notification history. On later stream updates, omit tags to keep the current tags, send tags again to replace them, or send an empty array to clear them.

:param stream_key: Stable identifier for one ongoing thing. Allowed characters: letters, numbers, underscores, and hyphens. (required)
:type stream_key: str
Expand Down
Loading