tauri-plugin-live-activity 0.11.1 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.ko.md CHANGED
@@ -33,8 +33,13 @@ Tauri 2 앱이 하고 있는 일을 iPhone 잠금 화면과 Dynamic Island에, A
33
33
  </tr>
34
34
  </table>
35
35
 
36
+ 데모가 도는 동안 카드의 TSX를 고치는 모습입니다. 값을 바꾸면 활동이 그 자리에서 갱신되고, 레이아웃이나 스타일을
37
+ 바꾸면 활동이 다시 시작됩니다([실시간 편집](https://github.com/1eedaegon/tauri-plugin-live-activity/blob/main/docs/live-editing.md)):
38
+
39
+ <img src="https://raw.githubusercontent.com/1eedaegon/tauri-plugin-live-activity/main/docs/images/live-editing.gif" width="800" alt="왼쪽은 iPhone 17 Pro 시뮬레이터의 화면 녹화로, 데모 위로 끌어내린 잠금 화면과 Mochi의 카드입니다. 오른쪽은 저장 기록으로 그린 편집기 화면의 card.tsx입니다. 값을 저장하면 상태 문구, 남은 시간, 진행률 막대가 그 자리에서 바뀌고, 발바닥을 자전거로 바꾸거나 제목을 키워 저장하면 카드가 사라졌다가 바뀐 모습으로 다시 뜹니다.">
40
+
36
41
  모두 고양이 Mochi를 따라가는 [데모 앱](https://github.com/1eedaegon/tauri-plugin-live-activity/tree/main/examples/demo)에서
37
- 캡처했습니다. iOS 16.2 이상, Android 8 이상에서 동작하고, 데스크톱에서는 활동 명령이
42
+ 캡처했습니다. iOS 16.1 이상, Android 8 이상에서 동작하고, 데스크톱에서는 활동 명령이
38
43
  `UNSUPPORTED_PLATFORM`을 돌려줍니다. 플러그인은 [liveactivity](https://github.com/1eedaegon/liveactivity-rs)
39
44
  크레이트의 어댑터이고, 이 크레이트가 iOS는 [activitykit](https://github.com/1eedaegon/activitykit-rs), Android는
40
45
  [liveupdate](https://github.com/1eedaegon/liveupdate-rs) 위에서 돌립니다. 그래서 플러그인 자체의 Swift 코드가 없고
@@ -72,7 +77,7 @@ JSX이므로 레이아웃은 별도 파일에 둡니다.
72
77
  import { Button, HStack, Progress, SFSymbol, Text, VStack } from 'tauri-plugin-live-activity/jsx';
73
78
 
74
79
  // iOS: 잠금 화면이 이 트리를 그대로 그리고, 펼친 Dynamic Island에도 같은 트리가 보입니다
75
- // (iOS 16.2 이상, Button은 iOS 17.2 이상).
80
+ // (iOS 16.1 이상, Button은 iOS 17.2 이상).
76
81
  // Android: 알림이 처음 두 Text를 제목과 본문으로, 첫 Progress를 진행률 막대로, Button을 최대 세 개까지
77
82
  // 동작으로 가져가고, 심볼과 스타일은 그리지 않습니다.
78
83
  export const lockScreen = (
@@ -131,8 +136,9 @@ prop입니다. [더 보기](https://github.com/1eedaegon/tauri-plugin-live-activ
131
136
  ```rust
132
137
  use std::collections::BTreeMap;
133
138
  use tauri::{AppHandle, Runtime};
139
+ use tauri_plugin_live_activity::activitykit::layout::text;
134
140
  use tauri_plugin_live_activity::{
135
- Element, EndPolicy, Fallback, Layout, LayoutEndInput, LayoutSnapshot, LayoutStartInput,
141
+ AndroidOptions, AndroidVisibility, Bound, Layout, LayoutEndInput, LayoutSnapshot, LayoutStartInput,
136
142
  LayoutUpdateInput, LiveActivityExt, Result, Value,
137
143
  };
138
144
 
@@ -142,30 +148,30 @@ fn snapshot(revision: u64, status: &str) -> LayoutSnapshot {
142
148
  }
143
149
 
144
150
  fn deliver<R: Runtime>(app: &AppHandle<R>) -> Result<()> {
145
- let input = LayoutStartInput {
146
- activity_key: "mochi:snack".into(),
147
- schema_version: 2,
148
- // Android와, Live Activity가 없는 iOS에서는 알림으로 보입니다.
149
- fallback: Fallback::Notification,
150
- layout: Layout {
151
- lock_screen: Element::Text { value: None, bind: Some("status".into()) }.into(),
152
- island: None, background: None, keyline: None, url: None, small: None,
153
- },
154
- styles: None,
155
- snapshot: snapshot(0, "On time"),
156
- android: None, // Android 전용: 잠금 화면 표시 범위는 `AndroidOptions::new(visibility)`
157
- ios: None, // iOS 전용: `IosOptions::new(transient)`이면 일시적 액티비티(iOS 18)
158
- scheduled: None, // iOS 26과 Android: `ScheduledStart::new(at, alert)`이면 나중에 시작
159
- push: None, // iOS 전용: `Some(LayoutPush::Token)`이면 액티비티의 APNs 토큰을 요청
160
- };
151
+ let layout = Layout::new(text(Bound::key("status")));
152
+ // Android와, Live Activity가 없는 iOS에서는 알림으로 보입니다.
153
+ let mut input = LayoutStartInput::new("mochi:snack", layout, snapshot(0, "On time"));
154
+ // Android 전용: 잠금 화면 표시 범위, 포그라운드 배치, 워치의 Ongoing Activity.
155
+ input.android = Some(AndroidOptions::new(AndroidVisibility::Public).with_wear_ongoing_activity(false));
156
+ // 그 밖에: `ios`(`IosOptions::new(transient)`, iOS 18), `scheduled`(`ScheduledStart::new(at, alert)`,
157
+ // iOS 26과 Android), `push`(`Some(LayoutPush::Token)`, iOS).
161
158
  let activity = app.live_activity().start_layout(input)?;
162
159
  // 갱신마다 모든 값을 다시, 더 높은 revision으로 보냅니다.
163
160
  app.live_activity().update_layout(LayoutUpdateInput::new(activity.id.clone(), snapshot(1, "At the door")))?;
164
- app.live_activity().end_layout(LayoutEndInput { id: activity.id, policy: EndPolicy::Immediate {}, snapshot: None })?;
161
+ app.live_activity().end_layout(LayoutEndInput::immediate(activity.id))?;
165
162
  Ok(())
166
163
  }
167
164
  ```
168
165
 
166
+ 요청은 생성자로 만들고, 열거형은 늘어날 수 있으니 `_` 가지로 매치하면 다음 버전에서도 컴파일됩니다. Android
167
+ 콘텐츠에 쓰는 liveupdate의 타입은 플러그인이 쓰는 크레이트째로 `tauri_plugin_live_activity::liveupdate`에
168
+ 있습니다:
169
+
170
+ ```rust
171
+ use tauri_plugin_live_activity::liveupdate::{Timer, TimerStyle};
172
+ let clock = TimerStyle::new(Timer::new(started_at, ends_at), true); // `ends_at`까지 거꾸로 셉니다
173
+ ```
174
+
169
175
  놓치면 안 되는 탭은 Rust에서 받습니다. 시스템이 탭 때문에 앱을 켤 때는 웹 뷰가 아직 없을 수 있고,
170
176
  JavaScript 리스너는 기다려 주지 않습니다. 만들어진 `App`에 `run` 전에 핸들러를 등록합니다:
171
177
 
@@ -173,8 +179,7 @@ JavaScript 리스너는 기다려 주지 않습니다. 만들어진 `App`에 `ru
173
179
  let handle = app.handle().clone();
174
180
  app.live_activity().on_action(move |event| {
175
181
  if event.action_id == "done" {
176
- let input = LayoutEndInput { id: event.activity_id, policy: EndPolicy::Immediate {}, snapshot: None };
177
- let _ = handle.live_activity().end_layout(input);
182
+ let _ = handle.live_activity().end_layout(LayoutEndInput::immediate(event.activity_id));
178
183
  }
179
184
  });
180
185
  ```
@@ -200,7 +205,34 @@ await endLayout({ id: snack.id, policy: { kind: 'immediate' } });
200
205
 
201
206
  시작 요청에 `scheduled: { at, alert }`를 주면 나중에 시작하고(iOS 26과 Android. Android에서는 사용자가 정확한 알람을 허용해야 제시간에 시작하며, `openExactAlarmSettings()`가 그 설정 화면을 엽니다), `ios: { transient: true }`이면 일시적 액티비티가 됩니다(iOS 18). 레이아웃은 시작한 모습 그대로이고, 갱신마다 모든 값을 더 높은 revision으로 다시 보냅니다. 탭은
202
207
  `onAction`으로, 푸시 토큰과 푸시된 내용은 `onPushToken`, `onPushToStartToken`, `onUpdated`로, 앱이 호출하지 않은
203
- 액티비티의 변화는 `onState`, `onStarted`, `onOpened`(Android: 액티비티의 알림으로 앱을 연 일. 앱을 실행시킨 열림도 페이지가 구독할 때까지 보관됩니다), `onPermissions`, `onUnknown`(Android: 액티비티에 대해 저장되어 있지만 이 버전이 이름을 모르는 이벤트)으로 옵니다.
208
+ 액티비티의 변화는 `onState`, `onStarted`, `onOpened`(Android: 액티비티의 알림으로 앱을 연 일. 앱을 실행시킨 열림도 페이지가 구독할 때까지 보관됩니다), `onPermissions`, `onUnknown`(`live-activity://unknown`, Android: 액티비티에 대해 저장되어 있지만 이 버전이 이름을 모르는 이벤트), `onHandled`(Android: 앱의 서비스나 리시버가 직접 받은 탭, 아래)로 옵니다. 탭은 자기가 어떤 탭인지 말합니다. `tap.id`는 몇 번 전달돼도 같고, iOS에서 앱이 곧바로 받지 못한 탭(탭이 앱을 띄운 경우)은 나중에 `tap.late`로 오므로, id마다 한 번만 처리합니다:
209
+
210
+ ```ts
211
+ await onAction(({ actionId, tap }) => {
212
+ if (tap?.id && handled.has(tap.id)) return; // `handled`: 앱이 실행 사이에 보관하는 id 집합
213
+ if (tap?.id) handled.add(tap.id);
214
+ // actionId 처리
215
+ });
216
+ ```
217
+
218
+ iOS에서는 `getCapabilities().ios`가 아이폰이 실행하는 기능(`pushToStart`, `pushChannels`, `transient`,
219
+ `scheduledStart`, `smallFamily`)을 알려 주므로 요청을 시도해 보지 않아도 됩니다.
220
+
221
+ Android에서는 시작에 `android: { visibility, publicVersion, placement, wearOngoingActivity, targets }`를 줍니다:
222
+
223
+ ```ts
224
+ android: {
225
+ visibility: 'public', // 잠긴 기기에 보이는 정도: 'public', 'private', 'secret'
226
+ placement: 'foreground', // 앱의 포그라운드 서비스가 쥐는 알림(`foregroundPlacement`)
227
+ wearOngoingActivity: false, // 워치 화면에서 뺌(Wear OS 3~6, Tauri 앱은 워치에서 돌지 않음)
228
+ // 버튼 `record`의 탭이 화면 없이 앱의 서비스를 바로 실행(`actionTargets`).
229
+ targets: { record: { kind: 'foregroundService', component: 'com.example.RecorderService', action: 'com.example.RECORD' } },
230
+ }
231
+ ```
232
+
233
+ 서비스는 `LiveUpdateForeground.attach(service, type)`(활동이 생기기 전까지 자기 알림을 띄우려면 `attachOr`)로 이 알림을
234
+ 쥐고, 탭은 `LiveUpdateActions.take(context, intent)`로 먼저 받습니다. 그 탭은 `onAction`이 아니라 `onHandled`로 옵니다.
235
+ [더 보기](https://github.com/1eedaegon/tauri-plugin-live-activity/blob/main/docs/android-integration.md#a-tap-that-runs-your-own-code)
204
236
 
205
237
  스냅샷에는 `relevance`(앱의 여러 액티비티 중 Dynamic Island가 무엇을 보일지 정하는 점수)와 `android`
206
238
  콘텐츠(레이아웃 투영 대신 Android 방식 그대로 쓰는 알림: 구간이 있는 진행 막대, 지표, 칩 텍스트)를 넣을 수
@@ -248,6 +280,10 @@ iOS에서는 페어링된 Apple Watch(iOS 18)와 CarPlay(iOS 26)가 아일랜드
248
280
  Android에서는 폰의 ongoing 알림이 페어링된 워치로 전달되지 않고 Live Update만 일부 워치에 전달되며, Android
249
281
  Auto에는 이를 보여 줄 자리가 없습니다. Android는 `small`을 `degradedFeatures`에 적습니다. [더 보기](https://github.com/1eedaegon/tauri-plugin-live-activity/blob/main/docs/usage.md#a-watch-and-a-car)
250
282
 
283
+ 잠금 화면의 카드에는 여백이 없고, 더 좁은 레이아웃은 가운데에 놓입니다. 루트에 padding을 주고, 가장자리에 붙일
284
+ 노드에는 `frame: { maxWidth: 'infinity', alignment: 'leading' }`인 스타일을 줍니다.
285
+ [더 보기](https://github.com/1eedaegon/tauri-plugin-live-activity/blob/main/docs/usage.md#placement-on-the-lock-screen)
286
+
251
287
  ## 푸시 (iOS)
252
288
 
253
289
  서버가 APNs로 액티비티를 갱신하고 끝내고 시작합니다. `push: 'token'`(iOS 18에서는 `{ channel }`도)으로
@@ -267,14 +303,17 @@ Auto에는 이를 보여 줄 자리가 없습니다. Android는 `small`을 `degr
267
303
 
268
304
  ## 제약
269
305
 
270
- - iOS: iOS 16.2의 iPhone 또는 iPadOS 17의 iPad, 버튼은 iOS 17.2부터. 액티비티는 앱이 전면일 때만 시작되고
271
- (아니면 `NOT_FOREGROUND`), 시스템이 8시간 뒤 끝냅니다.
306
+ - iOS: iOS 16.1의 iPhone 또는 iPadOS 17의 iPad, 버튼과 토글은 iOS 17.2부터. iOS 16.1에는 stale 날짜와 relevance 점수가
307
+ 없고, `frequentPushes`는 `denied`입니다. 액티비티는 앱이 전면일 때만 시작되고 (아니면 `NOT_FOREGROUND`), 시스템이
308
+ 8시간 뒤 끝냅니다.
272
309
  - iOS는 각 액티비티의 마지막 값을 앱의 Application Support에 평문으로 둡니다. 플러그인 설정에
273
310
  `"receipts": "redacted"`를 주면 가립니다.
274
311
  - 버튼 탭은 Rust `on_action` 핸들러를 최대 4초 기다립니다. JavaScript 리스너는 기다리지 않습니다.
275
312
  - 푸시는 iOS만. Android는 진행 중 알림을 보여 주고, 시스템이 허용하는 곳에서는 Live Update로 올립니다.
276
- - Android 16은 시각이 두 주보다 지난 알림을 보여 주지 않으며, 앱에도 알리지 않습니다. 타이머의 시작이나 끝이 게시보다
277
- 그만큼 앞선 경우입니다.
313
+ - Android 15부터 시계가 14일보다 오래된 타이머는 `INVALID_INPUT`으로 거절됩니다. Android는 그런 알림을 보여 주지
314
+ 않고 앱에도 알리지 않습니다.
315
+ - `SYSTEM_LIMIT`은 플랫폼의 한도입니다. Android에서는 살아 있는 액티비티 32개, 1,000,000바이트 저장소가 꽉 찬 경우,
316
+ 두 번째 포그라운드 배치이고, iOS에서는 ActivityKit의 한도입니다.
278
317
  - npm 패키지와 크레이트는 같은 마이너 버전으로 맞춥니다.
279
318
 
280
319
  ## Samsung Now Bar
package/README.md CHANGED
@@ -33,8 +33,13 @@ The demo running, recorded on the iPhone 17 Pro simulator and an Android 16 emul
33
33
  </tr>
34
34
  </table>
35
35
 
36
+ The card's TSX edited while the demo runs: new values update the activity in place, and a new layout or new styles
37
+ start it again ([live editing](https://github.com/1eedaegon/tauri-plugin-live-activity/blob/main/docs/live-editing.md)):
38
+
39
+ <img src="https://raw.githubusercontent.com/1eedaegon/tauri-plugin-live-activity/main/docs/images/live-editing.gif" width="800" alt="Left, the screen recording of the iPhone 17 Pro simulator: its Lock Screen pulled down over the demo, with Mochi's card. Right, card.tsx as an editor shows it, drawn from the log of the saves. Saves of values change the status, the time and the meter in place; a save that swaps the paw for a bicycle, and one that makes the title larger, each make the card go and come back changed.">
40
+
36
41
  All of them come from the [demo app](https://github.com/1eedaegon/tauri-plugin-live-activity/tree/main/examples/demo),
37
- which follows a cat named Mochi. iOS 16.2+ and Android 8+; on desktop the activity commands answer
42
+ which follows a cat named Mochi. iOS 16.1+ and Android 8+; on desktop the activity commands answer
38
43
  `UNSUPPORTED_PLATFORM`. The plugin is an adapter of the [liveactivity](https://github.com/1eedaegon/liveactivity-rs)
39
44
  crate, which runs iOS on [activitykit](https://github.com/1eedaegon/activitykit-rs) and Android on
40
45
  [liveupdate](https://github.com/1eedaegon/liveupdate-rs): the plugin has no Swift of its own, and its Kotlin answers
@@ -72,7 +77,7 @@ since this JSX has no HTML elements.
72
77
  import { Button, HStack, Progress, SFSymbol, Text, VStack } from 'tauri-plugin-live-activity/jsx';
73
78
 
74
79
  // iOS: the Lock Screen draws this tree as it is, and the expanded Dynamic Island shows it too
75
- // (iOS 16.2+; the Button needs iOS 17.2).
80
+ // (iOS 16.1+; the Button needs iOS 17.2).
76
81
  // Android: the notification takes the first two Texts as title and body, the first Progress as its
77
82
  // bar and up to three Buttons as actions; symbols and styles are left out.
78
83
  export const lockScreen = (
@@ -132,8 +137,9 @@ call them off the main thread (on iOS a call on the main thread answers `NATIVE_
132
137
  ```rust
133
138
  use std::collections::BTreeMap;
134
139
  use tauri::{AppHandle, Runtime};
140
+ use tauri_plugin_live_activity::activitykit::layout::text;
135
141
  use tauri_plugin_live_activity::{
136
- Element, EndPolicy, Fallback, Layout, LayoutEndInput, LayoutSnapshot, LayoutStartInput,
142
+ AndroidOptions, AndroidVisibility, Bound, Layout, LayoutEndInput, LayoutSnapshot, LayoutStartInput,
137
143
  LayoutUpdateInput, LiveActivityExt, Result, Value,
138
144
  };
139
145
 
@@ -143,30 +149,30 @@ fn snapshot(revision: u64, status: &str) -> LayoutSnapshot {
143
149
  }
144
150
 
145
151
  fn deliver<R: Runtime>(app: &AppHandle<R>) -> Result<()> {
146
- let input = LayoutStartInput {
147
- activity_key: "mochi:snack".into(),
148
- schema_version: 2,
149
- // Android, and iOS without Live Activities: shown as a notification.
150
- fallback: Fallback::Notification,
151
- layout: Layout {
152
- lock_screen: Element::Text { value: None, bind: Some("status".into()) }.into(),
153
- island: None, background: None, keyline: None, url: None, small: None,
154
- },
155
- styles: None,
156
- snapshot: snapshot(0, "On time"),
157
- android: None, // Android only: `AndroidOptions::new(visibility)` for the lock screen
158
- ios: None, // iOS only: `IosOptions::new(transient)` for a transient activity (iOS 18)
159
- scheduled: None, // iOS 26 and Android: `ScheduledStart::new(at, alert)` starts it later
160
- push: None, // iOS only: `Some(LayoutPush::Token)` asks for the activity's APNs token
161
- };
152
+ let layout = Layout::new(text(Bound::key("status")));
153
+ // Android, and iOS without Live Activities, show it as a notification.
154
+ let mut input = LayoutStartInput::new("mochi:snack", layout, snapshot(0, "On time"));
155
+ // Android only: the lock screen, the foreground placement, a watch's Ongoing Activity.
156
+ input.android = Some(AndroidOptions::new(AndroidVisibility::Public).with_wear_ongoing_activity(false));
157
+ // Also: `ios` (`IosOptions::new(transient)`, iOS 18), `scheduled` (`ScheduledStart::new(at, alert)`, iOS 26 and
158
+ // Android), `push` (`Some(LayoutPush::Token)`, iOS).
162
159
  let activity = app.live_activity().start_layout(input)?;
163
160
  // Every update sends all values again, with a higher revision.
164
161
  app.live_activity().update_layout(LayoutUpdateInput::new(activity.id.clone(), snapshot(1, "At the door")))?;
165
- app.live_activity().end_layout(LayoutEndInput { id: activity.id, policy: EndPolicy::Immediate {}, snapshot: None })?;
162
+ app.live_activity().end_layout(LayoutEndInput::immediate(activity.id))?;
166
163
  Ok(())
167
164
  }
168
165
  ```
169
166
 
167
+ Requests are built on their constructors, and the enums may grow: match them with a `_` arm, and the code compiles
168
+ against the next version. liveupdate's types for an Android content come with the crate the plugin builds with,
169
+ `tauri_plugin_live_activity::liveupdate`:
170
+
171
+ ```rust
172
+ use tauri_plugin_live_activity::liveupdate::{Timer, TimerStyle};
173
+ let clock = TimerStyle::new(Timer::new(started_at, ends_at), true); // counts down to `ends_at`
174
+ ```
175
+
170
176
  A tap that must not be lost belongs in Rust: the system can launch the app for it with no web view yet, and
171
177
  JavaScript listeners are not awaited. Register the handler on the built `App` before `run`:
172
178
 
@@ -174,8 +180,7 @@ JavaScript listeners are not awaited. Register the handler on the built `App` be
174
180
  let handle = app.handle().clone();
175
181
  app.live_activity().on_action(move |event| {
176
182
  if event.action_id == "done" {
177
- let input = LayoutEndInput { id: event.activity_id, policy: EndPolicy::Immediate {}, snapshot: None };
178
- let _ = handle.live_activity().end_layout(input);
183
+ let _ = handle.live_activity().end_layout(LayoutEndInput::immediate(event.activity_id));
179
184
  }
180
185
  });
181
186
  ```
@@ -204,8 +209,39 @@ person allows exact alarms, where `openExactAlarmSettings()` takes them), and `i
204
209
  activity (iOS 18). The layout stays as it started; each update sends every value again, with a higher revision. Taps come to
205
210
  `onAction`, push tokens and pushed content to `onPushToken`, `onPushToStartToken` and `onUpdated`, and what happens
206
211
  to an activity outside the app's calls to `onState`, `onStarted`, `onOpened` (Android: the person opened the app from an
207
- activity's notification; the opening that launched the app waits for the page), `onPermissions` and `onUnknown`
208
- (Android: something stored for an activity that this version has no event for).
212
+ activity's notification; the opening that launched the app waits for the page), `onPermissions`, `onUnknown`
213
+ (`live-activity://unknown`; Android: something stored for an activity that this version has no event for) and
214
+ `onHandled` (Android: a tap that the app's own service or receiver took, below). A tap says which it is: `tap.id`
215
+ is the same however often it comes, and on iOS a tap the app did not take at once (it launched the app) comes
216
+ later with `tap.late`, so act on each id once:
217
+
218
+ ```ts
219
+ await onAction(({ actionId, tap }) => {
220
+ if (tap?.id && handled.has(tap.id)) return; // `handled`: the app's own set of ids, kept across launches
221
+ if (tap?.id) handled.add(tap.id);
222
+ // act on actionId
223
+ });
224
+ ```
225
+
226
+ On iOS `getCapabilities().ios` says what the iPhone runs (`pushToStart`, `pushChannels`, `transient`,
227
+ `scheduledStart`, `smallFamily`), so a request need not be tried to learn it.
228
+
229
+ On Android a start takes `android: { visibility, publicVersion, placement, wearOngoingActivity, targets }`:
230
+
231
+ ```ts
232
+ android: {
233
+ visibility: 'public', // what a locked device shows: 'public', 'private' or 'secret'
234
+ placement: 'foreground', // the notification that the app's foreground service holds (`foregroundPlacement`)
235
+ wearOngoingActivity: false, // off the face of a watch (Wear OS 3 to 6; a Tauri app does not run there)
236
+ // The button `record` runs the app's own service at once, with no screen (`actionTargets`).
237
+ targets: { record: { kind: 'foregroundService', component: 'com.example.RecorderService', action: 'com.example.RECORD' } },
238
+ }
239
+ ```
240
+
241
+ The service attaches the notification with `LiveUpdateForeground.attach(service, type)` (or `attachOr`, with a
242
+ notification of its own until an activity holds the placement), and takes a tap first with
243
+ `LiveUpdateActions.take(context, intent)`; the tap then comes to `onHandled`, not `onAction`.
244
+ [More](https://github.com/1eedaegon/tauri-plugin-live-activity/blob/main/docs/android-integration.md#a-tap-that-runs-your-own-code)
209
245
 
210
246
  A snapshot may also carry a `relevance`, which decides which of the app's activities the Dynamic Island shows, and
211
247
  an `android` content, the notification in Android's own terms (a segmented progress, metrics, the chip text) in
@@ -254,6 +290,10 @@ tree of their own, at most 12 nodes without buttons, links or toggles, once the
254
290
  notification is not bridged to a paired watch, and a Live Update only to some; Android Auto has no place for one.
255
291
  Android names `small` in `degradedFeatures`. [More](https://github.com/1eedaegon/tauri-plugin-live-activity/blob/main/docs/usage.md#a-watch-and-a-car)
256
292
 
293
+ On the Lock Screen the card has no margin and shows a narrower layout in its middle: give the root a padding, and a
294
+ node that should reach an edge a style with `frame: { maxWidth: 'infinity', alignment: 'leading' }`.
295
+ [More](https://github.com/1eedaegon/tauri-plugin-live-activity/blob/main/docs/usage.md#placement-on-the-lock-screen)
296
+
257
297
  ## Pushes (iOS)
258
298
 
259
299
  A server updates, ends or starts activities through APNs. Start with `push: 'token'` (or `{ channel }` on iOS 18)
@@ -273,14 +313,17 @@ at most 1 MiB and 1224 × 480 pixels. [More](https://github.com/1eedaegon/tauri-
273
313
 
274
314
  ## Limits
275
315
 
276
- - iOS: an iPhone with iOS 16.2 or an iPad with iPadOS 17; buttons need iOS 17.2. An activity starts only while the
277
- app is in the foreground (`NOT_FOREGROUND` otherwise), and the system ends it after 8 hours.
316
+ - iOS: an iPhone with iOS 16.1 or an iPad with iPadOS 17; buttons and toggles need iOS 17.2. iOS 16.1 has no stale date and no
317
+ relevance score, and `frequentPushes` is `denied` there. An activity starts only while the app is in the foreground
318
+ (`NOT_FOREGROUND` otherwise), and the system ends it after 8 hours.
278
319
  - iOS keeps each activity's last values in plain text in the app's Application Support, unless the plugin
279
320
  configuration sets `"receipts": "redacted"`.
280
321
  - A button's tap waits for the Rust `on_action` handlers, at most 4 seconds; JavaScript listeners are not awaited.
281
322
  - Pushes are iOS only. Android shows an ongoing notification, promoted to a Live Update where the system allows it.
282
323
  - From Android 15 a timer whose clock is more than 14 days old is refused with `INVALID_INPUT`: Android would show
283
324
  nothing of such a notification and tell the app nothing.
325
+ - `SYSTEM_LIMIT` is the platform's limit: on Android 32 live activities, or no room left in the store of 1,000,000
326
+ bytes, or a second foreground placement; on iOS ActivityKit's.
284
327
  - Keep the npm package and the crate on the same minor version.
285
328
 
286
329
  ## Samsung Now Bar
package/cli/xcodegen.mjs CHANGED
@@ -166,7 +166,7 @@ export function widgetSpec({ pluginVersion, packagePath, appTarget, bundleId, ap
166
166
  ` ${WIDGET}:`,
167
167
  ' type: app-extension',
168
168
  ' platform: iOS',
169
- ' deploymentTarget: "16.2"',
169
+ ' deploymentTarget: "16.1"',
170
170
  ` sources: [${WIDGET}]`,
171
171
  ' dependencies:',
172
172
  ...product('ActivityKitWidget'),
@@ -1,5 +1,5 @@
1
1
  import { type UnlistenFn } from '@tauri-apps/api/event';
2
- import type { ActionEvent, ActivityRecord, Capabilities, EndInput, LayoutActivityRecord, LayoutEndInput, LayoutStartInput, LayoutUpdateInput, OpenedEvent, PermissionKind, Permissions, PushToStartTokenEvent, PushTokenEvent, PushTokens, StartInput, StartedEvent, StateEvent, UnknownEvent, UpdateInput, UpdatedEvent } from './types.js';
2
+ import type { ActionEvent, ActivityRecord, Capabilities, EndInput, LayoutActivityRecord, LayoutEndInput, LayoutStartInput, LayoutUpdateInput, OpenedEvent, PermissionKind, Permissions, PushToStartTokenEvent, PushTokenEvent, PushTokens, HandledEvent, StartInput, StartedEvent, StateEvent, UnknownEvent, UpdateInput, UpdatedEvent } from './types.js';
3
3
  export type * from './types.js';
4
4
  /** Builders for the nodes of a layout tree. */
5
5
  export * as layout from './layout.js';
@@ -126,3 +126,9 @@ export declare function onPermissions(handler: (permissions: Permissions) => voi
126
126
  * earlier version. Earlier versions of the plugin dropped such an event.
127
127
  */
128
128
  export declare function onUnknown(handler: (event: UnknownEvent) => void): Promise<UnlistenFn>;
129
+ /**
130
+ * Receive a tap that the target of its action ran, and that the app's own component (a service or a receiver) took
131
+ * with `LiveUpdateActions.take` (Android). The component acted on it, so it is no tap for `onAction`: this says
132
+ * that it happened, with the action's `id` and the stored tap's sequence and time.
133
+ */
134
+ export declare function onHandled(handler: (event: HandledEvent) => void): Promise<UnlistenFn>;
package/dist-js/index.js CHANGED
@@ -297,3 +297,11 @@ export function onPermissions(handler) {
297
297
  export function onUnknown(handler) {
298
298
  return listen('live-activity://unknown', event => handler(event.payload));
299
299
  }
300
+ /**
301
+ * Receive a tap that the target of its action ran, and that the app's own component (a service or a receiver) took
302
+ * with `LiveUpdateActions.take` (Android). The component acted on it, so it is no tap for `onAction`: this says
303
+ * that it happened, with the action's `id` and the stored tap's sequence and time.
304
+ */
305
+ export function onHandled(handler) {
306
+ return listen('live-activity://handled', event => handler(event.payload));
307
+ }
@@ -26,6 +26,11 @@ export interface Capabilities {
26
26
  * only.
27
27
  */
28
28
  readonly androidPresentation?: AndroidPresentationSupport;
29
+ /**
30
+ * What the iPhone runs of the features after the first Live Activities, so that a request need not be tried to
31
+ * learn it. Each is false on a device without Live Activities. iOS only.
32
+ */
33
+ readonly ios?: IosSupport;
29
34
  }
30
35
  /**
31
36
  * The notification styles an Android device draws, and what it offers beside them. A member that the Android side
@@ -74,12 +79,34 @@ export interface AndroidPresentationSupport {
74
79
  * does not offer, so this is false wherever the plugin runs today.
75
80
  */
76
81
  readonly wearOngoingActivity: boolean;
82
+ /**
83
+ * Whether an action may run a service, a foreground service or a receiver of the app at once (a start's
84
+ * `android.targets`, an Android content action's `target`). Where it is false such a start or update answers
85
+ * `UNSUPPORTED_FEATURE` and posts nothing.
86
+ */
87
+ readonly actionTargets: boolean;
88
+ }
89
+ /** What an iPhone runs of the features after the first Live Activities. */
90
+ export interface IosSupport {
91
+ /** A push-to-start token (`onPushToStartToken`): iOS 17.2. */
92
+ readonly pushToStart: boolean;
93
+ /** A start that subscribes to a broadcast channel (`push: { channel }`): iOS 18. */
94
+ readonly pushChannels: boolean;
95
+ /** A transient start (`ios: { transient: true }`): iOS 18. */
96
+ readonly transient: boolean;
97
+ /** A scheduled start (`scheduled`): iOS 26, in an app built with the iOS 26 SDK. */
98
+ readonly scheduledStart: boolean;
99
+ /** A layout's `small` region on a paired Apple Watch and in CarPlay: iOS 18, with `setup --small-family`. */
100
+ readonly smallFamily: boolean;
77
101
  }
78
102
  export interface Permissions {
79
103
  readonly notifications: PermissionState;
80
104
  readonly liveActivities: PermissionState;
81
105
  readonly promotion: PermissionState;
82
- /** Frequent pushes, a switch in Settings on iOS (`granted` or `denied`); `notApplicable` where there are no pushes. */
106
+ /**
107
+ * Frequent pushes, a switch in Settings on iOS (`granted` or `denied`); `denied` on iOS 16.1, which has no such
108
+ * switch; `notApplicable` where there are no pushes.
109
+ */
83
110
  readonly frequentPushes: PermissionState;
84
111
  }
85
112
  interface SnapshotFields {
@@ -175,7 +202,7 @@ export interface LayoutSnapshot {
175
202
  readonly revision: number;
176
203
  /** The complete map. An update keeps the keys and the value types accepted at start. */
177
204
  readonly values: LayoutValues;
178
- /** UTC Unix epoch milliseconds. */
205
+ /** UTC Unix epoch milliseconds. iOS 16.1 has no stale date: the record keeps it, and the content never goes stale. */
179
206
  readonly staleAt?: number;
180
207
  /**
181
208
  * When the content was made, UTC Unix epoch milliseconds. ActivityKit (iOS 17.2) drops content older than what it
@@ -184,7 +211,7 @@ export interface LayoutSnapshot {
184
211
  readonly timestamp?: number;
185
212
  /**
186
213
  * Which of the app's activities the Dynamic Island shows first: the highest score wins. Without it the activity
187
- * keeps its score, 0 at first. Android ignores it, and an Android record does not repeat it.
214
+ * keeps its score, 0 at first. Android and iOS 16.1 ignore it, and their records do not repeat it.
188
215
  */
189
216
  readonly relevance?: number;
190
217
  /**
@@ -323,6 +350,21 @@ export interface AndroidAction {
323
350
  * no tap: `onOpened` reports the opening with the action's `id`.
324
351
  */
325
352
  readonly openUrl?: string;
353
+ /** What runs the tap at once, with no screen: a service or a receiver of the app (`actionTargets`). Not beside `openUrl`. */
354
+ readonly target?: ActionTarget;
355
+ }
356
+ /**
357
+ * A service, a foreground service or a receiver of the app that runs a tap at once, with no screen, from the lock
358
+ * screen and while no process of the app runs, as a Live Activity runs an App Intent. The component is declared in
359
+ * the app's manifest, not exported, in the app's process, and takes the tap first with `LiveUpdateActions.take`;
360
+ * the tap then comes to `onHandled`, not to `onAction`.
361
+ */
362
+ export interface ActionTarget {
363
+ readonly kind: 'service' | 'foregroundService' | 'broadcast';
364
+ /** A class of the app's package: two or more Java identifiers joined by dots, 256 characters at most. */
365
+ readonly component: string;
366
+ /** The intent's action: printable ASCII without spaces, 256 characters at most. */
367
+ readonly action?: string;
326
368
  }
327
369
  /**
328
370
  * Android 16 draws the segments, the points and the icons; Android 17 also their semantic styles. Below Android 16
@@ -760,8 +802,9 @@ export interface Layout {
760
802
  * What the activity shows in the Smart Stack of a paired Apple Watch (iOS 18) and in CarPlay (iOS 26): at most 12
761
803
  * nodes and no button, link or toggle. iOS draws it when the widget extension's Info.plist sets
762
804
  * `ActivityKitSmallFamily` to true (`setup --small-family`); without the key the system shows the compact parts of
763
- * the island there, and the record names `layout.small` in `degradedFeatures`. So does Android, where a watch and a
764
- * car show the notification.
805
+ * the island there, and the record names `layout.small` in `degradedFeatures`. So does Android, which has no place
806
+ * for it: a phone's ongoing notification is not bridged to a paired watch (a Live Update only to some), and Android
807
+ * Auto shows only messaging apps' notifications.
765
808
  */
766
809
  readonly small?: LayoutNode;
767
810
  }
@@ -790,6 +833,14 @@ export interface LayoutAndroidOptions {
790
833
  * platform.
791
834
  */
792
835
  readonly wearOngoingActivity?: boolean;
836
+ /**
837
+ * What runs the tap of a button or a toggle of the lock screen tree, by its `actionId`: a service or a receiver
838
+ * of the app (`actionTargets`). Each key names a control of the tree, else `INVALID_INPUT` on every platform. iOS
839
+ * ignores it.
840
+ */
841
+ readonly targets?: {
842
+ readonly [actionId: string]: ActionTarget;
843
+ };
793
844
  }
794
845
  /**
795
846
  * What a layout activity asks ActivityKit for on iOS: a push token of its own, which `onPushToken` reports, or a
@@ -936,6 +987,38 @@ export interface ActionEvent {
936
987
  * content.
937
988
  */
938
989
  readonly on?: boolean;
990
+ /** Which tap it is and when it was made; absent when nothing of it is known. */
991
+ readonly tap?: Tap;
992
+ }
993
+ /** What a tap says of itself. Each member is absent when it is not known. */
994
+ export interface Tap {
995
+ /**
996
+ * The same however often the tap is handed on, also in a later launch: keep the ids you handled to act on each
997
+ * once. On Android the sequence of the stored tap.
998
+ */
999
+ readonly id?: string;
1000
+ /** When the person tapped, UTC Unix epoch milliseconds. On Android when the tap was stored. */
1001
+ readonly at?: number;
1002
+ /** The revision of the content the activity showed (iOS). */
1003
+ readonly revision?: number;
1004
+ /**
1005
+ * iOS: the app did not take the tap at once (the tap launched it, or its process ended first), so it was kept
1006
+ * and comes later, in this launch or the next, at most 12 hours later. The activity may have ended since.
1007
+ */
1008
+ readonly late?: boolean;
1009
+ }
1010
+ /**
1011
+ * A tap that the target of its action ran, and that the app's own component took with `LiveUpdateActions.take`
1012
+ * (Android). The component acted on it: this is no tap for `onAction`.
1013
+ */
1014
+ export interface HandledEvent {
1015
+ readonly activityId: string;
1016
+ /** The key of that activity, when the plugin knows it. */
1017
+ readonly activityKey?: string;
1018
+ /** The action whose target took the tap. */
1019
+ readonly actionId: string;
1020
+ /** The stored tap's sequence and time. */
1021
+ readonly tap?: Tap;
939
1022
  }
940
1023
  /**
941
1024
  * Something that Android stored for an activity and this version has no event for (Android): liveupdate read what
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tauri-plugin-live-activity",
3
- "version": "0.11.1",
3
+ "version": "0.13.0",
4
4
  "description": "Tauri 2 plugin for iOS Live Activities (ActivityKit and Dynamic Island) and Android Live Updates with ongoing notification fallback",
5
5
  "author": "1eedaegon",
6
6
  "type": "module",
@@ -31,15 +31,15 @@
31
31
  },
32
32
  "scripts": {
33
33
  "build": "tsc -p tsconfig.json && tsc -p cli && node -e \"require('node:fs').chmodSync('cli/bin.mjs', 0o755)\"",
34
- "typecheck": "npm run build && tsc -p tools && tsc -p tests && tsc -p examples/demo/tsconfig.json && tsc -p examples/demo/tsconfig.node.json",
34
+ "typecheck": "npm run build && tsc -p tools && tsc -p tests && tsc -p examples/demo/tsconfig.json && tsc -p examples/demo/tsconfig.node.json && tsc -p examples/demo/tsconfig.live.json",
35
35
  "test": "npm run build && npm run test:contracts && npm run test:api && npm run test:jsx && npm run test:react && npm run test:demo && npm run test:setup",
36
36
  "test:contracts": "node --experimental-strip-types --test --experimental-test-coverage \"--test-coverage-include=tools/activitykit.ts\" \"--test-coverage-include=tools/sync-liveupdate.ts\" \"--test-coverage-include=tools/cargo.ts\" --test-coverage-lines=80 --test-coverage-branches=80 --test-coverage-functions=80 tests/contract-files.test.ts tests/typescript-requests.test.ts tests/android-liveupdate.test.ts tests/android-contents.test.ts tests/ci.test.ts tests/ci-cache.test.ts tests/ios-run.test.ts tests/spec-coverage.test.ts tests/docs.test.ts",
37
37
  "test:api": "node --experimental-strip-types --test --experimental-test-coverage \"--test-coverage-include=dist-js/*.js\" --test-coverage-lines=80 --test-coverage-branches=80 --test-coverage-functions=80 tests/api.test.ts tests/api-reload.test.ts",
38
38
  "test:jsx": "node --experimental-strip-types --test --experimental-test-coverage \"--test-coverage-include=dist-js/jsx/*.js\" --test-coverage-lines=80 --test-coverage-branches=80 --test-coverage-functions=80 tests/jsx.test.ts",
39
39
  "test:react": "node --experimental-strip-types --test --experimental-test-coverage \"--test-coverage-include=dist-js/react/*.js\" --test-coverage-lines=80 --test-coverage-branches=80 --test-coverage-functions=80 tests/react.test.ts",
40
- "test:demo": "node --experimental-strip-types --test --experimental-test-coverage \"--test-coverage-include=examples/demo/src/*.ts\" \"--test-coverage-exclude=examples/demo/tests/**\" --test-coverage-lines=80 --test-coverage-branches=80 --test-coverage-functions=80 examples/demo/tests/self-test.test.ts examples/demo/tests/ui-state.test.ts examples/demo/tests/layouts.test.ts examples/demo/tests/setup.test.ts",
40
+ "test:demo": "node --experimental-strip-types --test --experimental-test-coverage \"--test-coverage-include=examples/demo/src/*.ts\" \"--test-coverage-exclude=examples/demo/tests/**\" --test-coverage-lines=80 --test-coverage-branches=80 --test-coverage-functions=80 examples/demo/tests/self-test.test.ts examples/demo/tests/ui-state.test.ts examples/demo/tests/layouts.test.ts examples/demo/tests/setup.test.ts examples/demo/tests/live-page.test.ts examples/demo/tests/live-card.test.ts",
41
41
  "test:setup": "node --experimental-strip-types --test --experimental-test-coverage \"--test-coverage-include=cli/*.mjs\" --test-coverage-lines=80 --test-coverage-branches=80 --test-coverage-functions=80 tests/setup.test.ts",
42
- "write:requests": "npm run build && node --experimental-strip-types --test --test-update-snapshots tests/jsx.test.ts tests/react.test.ts examples/demo/tests/layouts.test.ts examples/demo/tests/self-test.test.ts examples/demo/tests/ui-state.test.ts",
42
+ "write:requests": "npm run build && node --experimental-strip-types --test --test-update-snapshots tests/jsx.test.ts tests/react.test.ts examples/demo/tests/layouts.test.ts examples/demo/tests/self-test.test.ts examples/demo/tests/ui-state.test.ts examples/demo/tests/live-card.test.ts",
43
43
  "build:demo": "npm run build && node --experimental-strip-types examples/demo/build.ts",
44
44
  "prepack": "npm run build",
45
45
  "pack:check": "npm pack --dry-run"
@@ -56,10 +56,14 @@
56
56
  "@tauri-apps/api": "2.12.4",
57
57
  "@types/node": "22.20.5",
58
58
  "@types/react": "19.3.0",
59
+ "@types/react-dom": "19.3.0",
59
60
  "@types/react-test-renderer": "19.3.1",
61
+ "@vitejs/plugin-react": "6.3.0",
60
62
  "esbuild": "0.28.2",
61
63
  "react": "19.3.1",
64
+ "react-dom": "19.3.1",
62
65
  "react-test-renderer": "19.3.1",
63
- "typescript": "7.0.2"
66
+ "typescript": "7.0.2",
67
+ "vite": "8.3.8"
64
68
  }
65
69
  }