tauri-plugin-live-activity 0.11.1 → 0.12.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,6 +33,11 @@ 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
42
  캡처했습니다. iOS 16.2 이상, Android 8 이상에서 동작하고, 데스크톱에서는 활동 명령이
38
43
  `UNSUPPORTED_PLATFORM`을 돌려줍니다. 플러그인은 [liveactivity](https://github.com/1eedaegon/liveactivity-rs)
@@ -132,7 +137,7 @@ prop입니다. [더 보기](https://github.com/1eedaegon/tauri-plugin-live-activ
132
137
  use std::collections::BTreeMap;
133
138
  use tauri::{AppHandle, Runtime};
134
139
  use tauri_plugin_live_activity::{
135
- Element, EndPolicy, Fallback, Layout, LayoutEndInput, LayoutSnapshot, LayoutStartInput,
140
+ AndroidOptions, AndroidVisibility, Element, Layout, LayoutEndInput, LayoutSnapshot, LayoutStartInput,
136
141
  LayoutUpdateInput, LiveActivityExt, Result, Value,
137
142
  };
138
143
 
@@ -142,30 +147,33 @@ fn snapshot(revision: u64, status: &str) -> LayoutSnapshot {
142
147
  }
143
148
 
144
149
  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 토큰을 요청
150
+ let 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,
160
153
  };
154
+ // Android와, Live Activity가 없는 iOS에서는 알림으로 보입니다.
155
+ let mut input = LayoutStartInput::new("mochi:snack", layout, snapshot(0, "On time"));
156
+ // Android 전용: 잠금 화면 표시 범위, 포그라운드 배치, 워치의 Ongoing Activity.
157
+ input.android = Some(AndroidOptions::new(AndroidVisibility::Public).with_wear_ongoing_activity(false));
158
+ // 그 밖에: `ios`(`IosOptions::new(transient)`, iOS 18), `scheduled`(`ScheduledStart::new(at, alert)`,
159
+ // iOS 26과 Android), `push`(`Some(LayoutPush::Token)`, iOS).
161
160
  let activity = app.live_activity().start_layout(input)?;
162
161
  // 갱신마다 모든 값을 다시, 더 높은 revision으로 보냅니다.
163
162
  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 })?;
163
+ app.live_activity().end_layout(LayoutEndInput::immediate(activity.id))?;
165
164
  Ok(())
166
165
  }
167
166
  ```
168
167
 
168
+ 요청은 생성자로 만들고, 열거형은 늘어날 수 있으니 `_` 가지로 매치하면 다음 버전에서도 컴파일됩니다. Android
169
+ 콘텐츠에 쓰는 liveupdate의 타입은 플러그인이 쓰는 크레이트째로 `tauri_plugin_live_activity::liveupdate`에
170
+ 있습니다:
171
+
172
+ ```rust
173
+ use tauri_plugin_live_activity::liveupdate::{Timer, TimerStyle};
174
+ let clock = TimerStyle::new(Timer::new(started_at, ends_at), true); // `ends_at`까지 거꾸로 셉니다
175
+ ```
176
+
169
177
  놓치면 안 되는 탭은 Rust에서 받습니다. 시스템이 탭 때문에 앱을 켤 때는 웹 뷰가 아직 없을 수 있고,
170
178
  JavaScript 리스너는 기다려 주지 않습니다. 만들어진 `App`에 `run` 전에 핸들러를 등록합니다:
171
179
 
@@ -173,8 +181,7 @@ JavaScript 리스너는 기다려 주지 않습니다. 만들어진 `App`에 `ru
173
181
  let handle = app.handle().clone();
174
182
  app.live_activity().on_action(move |event| {
175
183
  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);
184
+ let _ = handle.live_activity().end_layout(LayoutEndInput::immediate(event.activity_id));
178
185
  }
179
186
  });
180
187
  ```
@@ -200,7 +207,34 @@ await endLayout({ id: snack.id, policy: { kind: 'immediate' } });
200
207
 
201
208
  시작 요청에 `scheduled: { at, alert }`를 주면 나중에 시작하고(iOS 26과 Android. Android에서는 사용자가 정확한 알람을 허용해야 제시간에 시작하며, `openExactAlarmSettings()`가 그 설정 화면을 엽니다), `ios: { transient: true }`이면 일시적 액티비티가 됩니다(iOS 18). 레이아웃은 시작한 모습 그대로이고, 갱신마다 모든 값을 더 높은 revision으로 다시 보냅니다. 탭은
202
209
  `onAction`으로, 푸시 토큰과 푸시된 내용은 `onPushToken`, `onPushToStartToken`, `onUpdated`로, 앱이 호출하지 않은
203
- 액티비티의 변화는 `onState`, `onStarted`, `onOpened`(Android: 액티비티의 알림으로 앱을 연 일. 앱을 실행시킨 열림도 페이지가 구독할 때까지 보관됩니다), `onPermissions`, `onUnknown`(Android: 액티비티에 대해 저장되어 있지만 이 버전이 이름을 모르는 이벤트)으로 옵니다.
210
+ 액티비티의 변화는 `onState`, `onStarted`, `onOpened`(Android: 액티비티의 알림으로 앱을 연 일. 앱을 실행시킨 열림도 페이지가 구독할 때까지 보관됩니다), `onPermissions`, `onUnknown`(`live-activity://unknown`, Android: 액티비티에 대해 저장되어 있지만 이 버전이 이름을 모르는 이벤트), `onHandled`(Android: 앱의 서비스나 리시버가 직접 받은 탭, 아래)로 옵니다. 탭은 자기가 어떤 탭인지 말합니다. `tap.id`는 몇 번 전달돼도 같고, iOS에서 앱이 곧바로 받지 못한 탭(탭이 앱을 띄운 경우)은 나중에 `tap.late`로 오므로, id마다 한 번만 처리합니다:
211
+
212
+ ```ts
213
+ await onAction(({ actionId, tap }) => {
214
+ if (tap?.id && handled.has(tap.id)) return; // `handled`: 앱이 실행 사이에 보관하는 id 집합
215
+ if (tap?.id) handled.add(tap.id);
216
+ // actionId 처리
217
+ });
218
+ ```
219
+
220
+ iOS에서는 `getCapabilities().ios`가 아이폰이 실행하는 기능(`pushToStart`, `pushChannels`, `transient`,
221
+ `scheduledStart`, `smallFamily`)을 알려 주므로 요청을 시도해 보지 않아도 됩니다.
222
+
223
+ Android에서는 시작에 `android: { visibility, publicVersion, placement, wearOngoingActivity, targets }`를 줍니다:
224
+
225
+ ```ts
226
+ android: {
227
+ visibility: 'public', // 잠긴 기기에 보이는 정도: 'public', 'private', 'secret'
228
+ placement: 'foreground', // 앱의 포그라운드 서비스가 쥐는 알림(`foregroundPlacement`)
229
+ wearOngoingActivity: false, // 워치 화면에서 뺌(Wear OS 3~6, Tauri 앱은 워치에서 돌지 않음)
230
+ // 버튼 `record`의 탭이 화면 없이 앱의 서비스를 바로 실행(`actionTargets`).
231
+ targets: { record: { kind: 'foregroundService', component: 'com.example.RecorderService', action: 'com.example.RECORD' } },
232
+ }
233
+ ```
234
+
235
+ 서비스는 `LiveUpdateForeground.attach(service, type)`(활동이 생기기 전까지 자기 알림을 띄우려면 `attachOr`)로 이 알림을
236
+ 쥐고, 탭은 `LiveUpdateActions.take(context, intent)`로 먼저 받습니다. 그 탭은 `onAction`이 아니라 `onHandled`로 옵니다.
237
+ [더 보기](https://github.com/1eedaegon/tauri-plugin-live-activity/blob/main/docs/android-integration.md#a-tap-that-runs-your-own-code)
204
238
 
205
239
  스냅샷에는 `relevance`(앱의 여러 액티비티 중 Dynamic Island가 무엇을 보일지 정하는 점수)와 `android`
206
240
  콘텐츠(레이아웃 투영 대신 Android 방식 그대로 쓰는 알림: 구간이 있는 진행 막대, 지표, 칩 텍스트)를 넣을 수
@@ -248,6 +282,10 @@ iOS에서는 페어링된 Apple Watch(iOS 18)와 CarPlay(iOS 26)가 아일랜드
248
282
  Android에서는 폰의 ongoing 알림이 페어링된 워치로 전달되지 않고 Live Update만 일부 워치에 전달되며, Android
249
283
  Auto에는 이를 보여 줄 자리가 없습니다. Android는 `small`을 `degradedFeatures`에 적습니다. [더 보기](https://github.com/1eedaegon/tauri-plugin-live-activity/blob/main/docs/usage.md#a-watch-and-a-car)
250
284
 
285
+ 잠금 화면의 카드에는 여백이 없고, 더 좁은 레이아웃은 가운데에 놓입니다. 루트에 padding을 주고, 가장자리에 붙일
286
+ 노드에는 `frame: { maxWidth: 'infinity', alignment: 'leading' }`인 스타일을 줍니다.
287
+ [더 보기](https://github.com/1eedaegon/tauri-plugin-live-activity/blob/main/docs/usage.md#placement-on-the-lock-screen)
288
+
251
289
  ## 푸시 (iOS)
252
290
 
253
291
  서버가 APNs로 액티비티를 갱신하고 끝내고 시작합니다. `push: 'token'`(iOS 18에서는 `{ channel }`도)으로
@@ -267,14 +305,16 @@ Auto에는 이를 보여 줄 자리가 없습니다. Android는 `small`을 `degr
267
305
 
268
306
  ## 제약
269
307
 
270
- - iOS: iOS 16.2의 iPhone 또는 iPadOS 17의 iPad, 버튼은 iOS 17.2부터. 액티비티는 앱이 전면일 때만 시작되고
308
+ - iOS: iOS 16.2의 iPhone 또는 iPadOS 17의 iPad, 버튼과 토글은 iOS 17.2부터. 액티비티는 앱이 전면일 때만 시작되고
271
309
  (아니면 `NOT_FOREGROUND`), 시스템이 8시간 뒤 끝냅니다.
272
310
  - iOS는 각 액티비티의 마지막 값을 앱의 Application Support에 평문으로 둡니다. 플러그인 설정에
273
311
  `"receipts": "redacted"`를 주면 가립니다.
274
312
  - 버튼 탭은 Rust `on_action` 핸들러를 최대 4초 기다립니다. JavaScript 리스너는 기다리지 않습니다.
275
313
  - 푸시는 iOS만. Android는 진행 중 알림을 보여 주고, 시스템이 허용하는 곳에서는 Live Update로 올립니다.
276
- - Android 16은 시각이 두 주보다 지난 알림을 보여 주지 않으며, 앱에도 알리지 않습니다. 타이머의 시작이나 끝이 게시보다
277
- 그만큼 앞선 경우입니다.
314
+ - Android 15부터 시계가 14일보다 오래된 타이머는 `INVALID_INPUT`으로 거절됩니다. Android는 그런 알림을 보여 주지
315
+ 않고 앱에도 알리지 않습니다.
316
+ - `SYSTEM_LIMIT`은 플랫폼의 한도입니다. Android에서는 살아 있는 액티비티 32개, 1,000,000바이트 저장소가 꽉 찬 경우,
317
+ 두 번째 포그라운드 배치이고, iOS에서는 ActivityKit의 한도입니다.
278
318
  - npm 패키지와 크레이트는 같은 마이너 버전으로 맞춥니다.
279
319
 
280
320
  ## Samsung Now Bar
package/README.md CHANGED
@@ -33,6 +33,11 @@ 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
42
  which follows a cat named Mochi. iOS 16.2+ 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)
@@ -133,7 +138,7 @@ call them off the main thread (on iOS a call on the main thread answers `NATIVE_
133
138
  use std::collections::BTreeMap;
134
139
  use tauri::{AppHandle, Runtime};
135
140
  use tauri_plugin_live_activity::{
136
- Element, EndPolicy, Fallback, Layout, LayoutEndInput, LayoutSnapshot, LayoutStartInput,
141
+ AndroidOptions, AndroidVisibility, Element, Layout, LayoutEndInput, LayoutSnapshot, LayoutStartInput,
137
142
  LayoutUpdateInput, LiveActivityExt, Result, Value,
138
143
  };
139
144
 
@@ -143,30 +148,33 @@ fn snapshot(revision: u64, status: &str) -> LayoutSnapshot {
143
148
  }
144
149
 
145
150
  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
151
+ let 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,
161
154
  };
155
+ // Android, and iOS without Live Activities, show it as a notification.
156
+ let mut input = LayoutStartInput::new("mochi:snack", layout, snapshot(0, "On time"));
157
+ // Android only: the lock screen, the foreground placement, a watch's Ongoing Activity.
158
+ input.android = Some(AndroidOptions::new(AndroidVisibility::Public).with_wear_ongoing_activity(false));
159
+ // Also: `ios` (`IosOptions::new(transient)`, iOS 18), `scheduled` (`ScheduledStart::new(at, alert)`, iOS 26 and
160
+ // Android), `push` (`Some(LayoutPush::Token)`, iOS).
162
161
  let activity = app.live_activity().start_layout(input)?;
163
162
  // Every update sends all values again, with a higher revision.
164
163
  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 })?;
164
+ app.live_activity().end_layout(LayoutEndInput::immediate(activity.id))?;
166
165
  Ok(())
167
166
  }
168
167
  ```
169
168
 
169
+ Requests are built on their constructors, and the enums may grow: match them with a `_` arm, and the code compiles
170
+ against the next version. liveupdate's types for an Android content come with the crate the plugin builds with,
171
+ `tauri_plugin_live_activity::liveupdate`:
172
+
173
+ ```rust
174
+ use tauri_plugin_live_activity::liveupdate::{Timer, TimerStyle};
175
+ let clock = TimerStyle::new(Timer::new(started_at, ends_at), true); // counts down to `ends_at`
176
+ ```
177
+
170
178
  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
179
  JavaScript listeners are not awaited. Register the handler on the built `App` before `run`:
172
180
 
@@ -174,8 +182,7 @@ JavaScript listeners are not awaited. Register the handler on the built `App` be
174
182
  let handle = app.handle().clone();
175
183
  app.live_activity().on_action(move |event| {
176
184
  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);
185
+ let _ = handle.live_activity().end_layout(LayoutEndInput::immediate(event.activity_id));
179
186
  }
180
187
  });
181
188
  ```
@@ -204,8 +211,39 @@ person allows exact alarms, where `openExactAlarmSettings()` takes them), and `i
204
211
  activity (iOS 18). The layout stays as it started; each update sends every value again, with a higher revision. Taps come to
205
212
  `onAction`, push tokens and pushed content to `onPushToken`, `onPushToStartToken` and `onUpdated`, and what happens
206
213
  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).
214
+ activity's notification; the opening that launched the app waits for the page), `onPermissions`, `onUnknown`
215
+ (`live-activity://unknown`; Android: something stored for an activity that this version has no event for) and
216
+ `onHandled` (Android: a tap that the app's own service or receiver took, below). A tap says which it is: `tap.id`
217
+ is the same however often it comes, and on iOS a tap the app did not take at once (it launched the app) comes
218
+ later with `tap.late`, so act on each id once:
219
+
220
+ ```ts
221
+ await onAction(({ actionId, tap }) => {
222
+ if (tap?.id && handled.has(tap.id)) return; // `handled`: the app's own set of ids, kept across launches
223
+ if (tap?.id) handled.add(tap.id);
224
+ // act on actionId
225
+ });
226
+ ```
227
+
228
+ On iOS `getCapabilities().ios` says what the iPhone runs (`pushToStart`, `pushChannels`, `transient`,
229
+ `scheduledStart`, `smallFamily`), so a request need not be tried to learn it.
230
+
231
+ On Android a start takes `android: { visibility, publicVersion, placement, wearOngoingActivity, targets }`:
232
+
233
+ ```ts
234
+ android: {
235
+ visibility: 'public', // what a locked device shows: 'public', 'private' or 'secret'
236
+ placement: 'foreground', // the notification that the app's foreground service holds (`foregroundPlacement`)
237
+ wearOngoingActivity: false, // off the face of a watch (Wear OS 3 to 6; a Tauri app does not run there)
238
+ // The button `record` runs the app's own service at once, with no screen (`actionTargets`).
239
+ targets: { record: { kind: 'foregroundService', component: 'com.example.RecorderService', action: 'com.example.RECORD' } },
240
+ }
241
+ ```
242
+
243
+ The service attaches the notification with `LiveUpdateForeground.attach(service, type)` (or `attachOr`, with a
244
+ notification of its own until an activity holds the placement), and takes a tap first with
245
+ `LiveUpdateActions.take(context, intent)`; the tap then comes to `onHandled`, not `onAction`.
246
+ [More](https://github.com/1eedaegon/tauri-plugin-live-activity/blob/main/docs/android-integration.md#a-tap-that-runs-your-own-code)
209
247
 
210
248
  A snapshot may also carry a `relevance`, which decides which of the app's activities the Dynamic Island shows, and
211
249
  an `android` content, the notification in Android's own terms (a segmented progress, metrics, the chip text) in
@@ -254,6 +292,10 @@ tree of their own, at most 12 nodes without buttons, links or toggles, once the
254
292
  notification is not bridged to a paired watch, and a Live Update only to some; Android Auto has no place for one.
255
293
  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
294
 
295
+ On the Lock Screen the card has no margin and shows a narrower layout in its middle: give the root a padding, and a
296
+ node that should reach an edge a style with `frame: { maxWidth: 'infinity', alignment: 'leading' }`.
297
+ [More](https://github.com/1eedaegon/tauri-plugin-live-activity/blob/main/docs/usage.md#placement-on-the-lock-screen)
298
+
257
299
  ## Pushes (iOS)
258
300
 
259
301
  A server updates, ends or starts activities through APNs. Start with `push: 'token'` (or `{ channel }` on iOS 18)
@@ -273,7 +315,7 @@ at most 1 MiB and 1224 × 480 pixels. [More](https://github.com/1eedaegon/tauri-
273
315
 
274
316
  ## Limits
275
317
 
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
318
+ - iOS: an iPhone with iOS 16.2 or an iPad with iPadOS 17; buttons and toggles need iOS 17.2. An activity starts only while the
277
319
  app is in the foreground (`NOT_FOREGROUND` otherwise), and the system ends it after 8 hours.
278
320
  - iOS keeps each activity's last values in plain text in the app's Application Support, unless the plugin
279
321
  configuration sets `"receipts": "redacted"`.
@@ -281,6 +323,8 @@ at most 1 MiB and 1224 × 480 pixels. [More](https://github.com/1eedaegon/tauri-
281
323
  - Pushes are iOS only. Android shows an ongoing notification, promoted to a Live Update where the system allows it.
282
324
  - From Android 15 a timer whose clock is more than 14 days old is refused with `INVALID_INPUT`: Android would show
283
325
  nothing of such a notification and tell the app nothing.
326
+ - `SYSTEM_LIMIT` is the platform's limit: on Android 32 live activities, or no room left in the store of 1,000,000
327
+ bytes, or a second foreground placement; on iOS ActivityKit's.
284
328
  - Keep the npm package and the crate on the same minor version.
285
329
 
286
330
  ## Samsung Now Bar
@@ -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,6 +79,25 @@ 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;
@@ -323,6 +347,21 @@ export interface AndroidAction {
323
347
  * no tap: `onOpened` reports the opening with the action's `id`.
324
348
  */
325
349
  readonly openUrl?: string;
350
+ /** What runs the tap at once, with no screen: a service or a receiver of the app (`actionTargets`). Not beside `openUrl`. */
351
+ readonly target?: ActionTarget;
352
+ }
353
+ /**
354
+ * A service, a foreground service or a receiver of the app that runs a tap at once, with no screen, from the lock
355
+ * screen and while no process of the app runs, as a Live Activity runs an App Intent. The component is declared in
356
+ * the app's manifest, not exported, in the app's process, and takes the tap first with `LiveUpdateActions.take`;
357
+ * the tap then comes to `onHandled`, not to `onAction`.
358
+ */
359
+ export interface ActionTarget {
360
+ readonly kind: 'service' | 'foregroundService' | 'broadcast';
361
+ /** A class of the app's package: two or more Java identifiers joined by dots, 256 characters at most. */
362
+ readonly component: string;
363
+ /** The intent's action: printable ASCII without spaces, 256 characters at most. */
364
+ readonly action?: string;
326
365
  }
327
366
  /**
328
367
  * Android 16 draws the segments, the points and the icons; Android 17 also their semantic styles. Below Android 16
@@ -760,8 +799,9 @@ export interface Layout {
760
799
  * What the activity shows in the Smart Stack of a paired Apple Watch (iOS 18) and in CarPlay (iOS 26): at most 12
761
800
  * nodes and no button, link or toggle. iOS draws it when the widget extension's Info.plist sets
762
801
  * `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.
802
+ * the island there, and the record names `layout.small` in `degradedFeatures`. So does Android, which has no place
803
+ * for it: a phone's ongoing notification is not bridged to a paired watch (a Live Update only to some), and Android
804
+ * Auto shows only messaging apps' notifications.
765
805
  */
766
806
  readonly small?: LayoutNode;
767
807
  }
@@ -790,6 +830,14 @@ export interface LayoutAndroidOptions {
790
830
  * platform.
791
831
  */
792
832
  readonly wearOngoingActivity?: boolean;
833
+ /**
834
+ * What runs the tap of a button or a toggle of the lock screen tree, by its `actionId`: a service or a receiver
835
+ * of the app (`actionTargets`). Each key names a control of the tree, else `INVALID_INPUT` on every platform. iOS
836
+ * ignores it.
837
+ */
838
+ readonly targets?: {
839
+ readonly [actionId: string]: ActionTarget;
840
+ };
793
841
  }
794
842
  /**
795
843
  * What a layout activity asks ActivityKit for on iOS: a push token of its own, which `onPushToken` reports, or a
@@ -936,6 +984,38 @@ export interface ActionEvent {
936
984
  * content.
937
985
  */
938
986
  readonly on?: boolean;
987
+ /** Which tap it is and when it was made; absent when nothing of it is known. */
988
+ readonly tap?: Tap;
989
+ }
990
+ /** What a tap says of itself. Each member is absent when it is not known. */
991
+ export interface Tap {
992
+ /**
993
+ * The same however often the tap is handed on, also in a later launch: keep the ids you handled to act on each
994
+ * once. On Android the sequence of the stored tap.
995
+ */
996
+ readonly id?: string;
997
+ /** When the person tapped, UTC Unix epoch milliseconds. On Android when the tap was stored. */
998
+ readonly at?: number;
999
+ /** The revision of the content the activity showed (iOS). */
1000
+ readonly revision?: number;
1001
+ /**
1002
+ * iOS: the app did not take the tap at once (the tap launched it, or its process ended first), so it was kept
1003
+ * and comes later, in this launch or the next, at most 12 hours later. The activity may have ended since.
1004
+ */
1005
+ readonly late?: boolean;
1006
+ }
1007
+ /**
1008
+ * A tap that the target of its action ran, and that the app's own component took with `LiveUpdateActions.take`
1009
+ * (Android). The component acted on it: this is no tap for `onAction`.
1010
+ */
1011
+ export interface HandledEvent {
1012
+ readonly activityId: string;
1013
+ /** The key of that activity, when the plugin knows it. */
1014
+ readonly activityKey?: string;
1015
+ /** The action whose target took the tap. */
1016
+ readonly actionId: string;
1017
+ /** The stored tap's sequence and time. */
1018
+ readonly tap?: Tap;
939
1019
  }
940
1020
  /**
941
1021
  * 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.12.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
  }