tauri-plugin-live-activity 0.5.1 → 0.6.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
@@ -174,6 +174,19 @@ await onAction(async ({ actionId, activityId }) => {
174
174
 
175
175
  탭은 `onAction`으로, 앱이 열려 있지 않을 때는 Rust의 `on_action`으로 전달됩니다. iOS 17 이상이며, Android는 최대 세 개를 알림 버튼으로 보여 줍니다.
176
176
 
177
+ ### 푸시
178
+
179
+ ```ts
180
+ await onPushToken(({ activityId, token }) => sendToServer(activityId, token));
181
+ await onUpdated(({ record }) => show(record.snapshot.values));
182
+ await startLayout({ ...input, push: 'token' });
183
+ ```
184
+
185
+ iOS에서는 서버가 APNs로 액티비티를 갱신하고, 끝내고, 시작할 수 있습니다. 액티비티의 토큰은 `onPushToken`으로,
186
+ 앱의 push-to-start 토큰(iOS 17.2, 플러그인 설정의 `pushToStart`)은 `onPushToStartToken`으로, 푸시가 전달한
187
+ 내용은 `onUpdated`로 옵니다. 페이지가 구독할 때 플러그인이 이미 갖고 있던 토큰은 바로 전달됩니다(`pushTokens`).
188
+ 페이로드는 서버가 activitykit의 `push::Payload`로 만듭니다. [docs/usage.md](docs/usage.md#pushes)를 보세요.
189
+
177
190
  ### Dynamic Island
178
191
 
179
192
  <table>
@@ -300,7 +313,9 @@ Group을 Apple 계정에 한 번 등록해야 하는데, 자동 서명이 대신
300
313
  - 버튼을 누르면 Rust의 `on_action` 핸들러가 끝날 때까지 최대 4초 기다립니다. JavaScript 리스너는 기다리지 않습니다.
301
314
  - `app.live_activity()`의 Rust 메서드는 응답이 올 때까지 스레드를 멈추므로 메인 스레드가 아닌 곳에서 호출하세요. iOS에서
302
315
  메인 스레드에서 호출하면 바로 `NATIVE_ERROR`를 돌려줍니다. JavaScript의 명령은 멈추지 않습니다.
303
- - 푸시 갱신은 없습니다. Android는 진행 중 알림으로 보여 주고, 시스템이 허용하면 Live Update로 올립니다.
316
+ - 푸시는 iOS에서만 됩니다. 토큰, 채널, push-to-start는 플러그인이 다루고 페이로드는 서버가 activitykit의
317
+ `push::Payload`로 만듭니다. Android는 진행 중 알림으로 보여 주고, 시스템이 허용하면 Live Update로 올리며, 푸시는
318
+ 받지 않습니다.
304
319
 
305
320
  ## Samsung Now Bar
306
321
 
package/README.md CHANGED
@@ -174,6 +174,19 @@ await onAction(async ({ actionId, activityId }) => {
174
174
 
175
175
  A tap reaches `onAction`, or `on_action` in Rust, which also runs when the app was not open. iOS 17+; Android shows up to three as notification actions.
176
176
 
177
+ ### Pushes
178
+
179
+ ```ts
180
+ await onPushToken(({ activityId, token }) => sendToServer(activityId, token));
181
+ await onUpdated(({ record }) => show(record.snapshot.values));
182
+ await startLayout({ ...input, push: 'token' });
183
+ ```
184
+
185
+ On iOS a server updates, ends or starts activities through APNs: the activity's token comes to `onPushToken`, the
186
+ app's push-to-start token (iOS 17.2, `pushToStart` in the plugin configuration) to `onPushToStartToken`, and content a
187
+ push delivered to `onUpdated`. Tokens the plugin already holds when a page subscribes come at once (`pushTokens`).
188
+ The server builds the payloads with activitykit's `push::Payload`. See [docs/usage.md](docs/usage.md#pushes).
189
+
177
190
  ### Dynamic Island
178
191
 
179
192
  <table>
@@ -300,7 +313,9 @@ notification's large icon. Layout, styles and values still share 3584.
300
313
  - A button's tap waits for your Rust `on_action` handlers, at most 4 seconds; JavaScript listeners are not awaited.
301
314
  - The Rust methods of `app.live_activity()` block until the answer: call them off the main thread. On iOS a call on
302
315
  the main thread answers `NATIVE_ERROR` at once. The commands from JavaScript never block.
303
- - No push updates. Android shows an ongoing notification, promoted to a Live Update where the system allows it.
316
+ - Pushes on iOS only: tokens, channels and push-to-start through the plugin, the payloads from activitykit's
317
+ `push::Payload` on the server. Android shows an ongoing notification, promoted to a Live Update where the system
318
+ allows it, and takes no pushes.
304
319
 
305
320
  ## Samsung Now Bar
306
321
 
@@ -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, PermissionKind, Permissions, StartInput, UpdateInput } from './types.js';
2
+ import type { ActionEvent, ActivityRecord, Capabilities, EndInput, LayoutActivityRecord, LayoutEndInput, LayoutStartInput, LayoutUpdateInput, PermissionKind, Permissions, PushToStartTokenEvent, PushTokenEvent, PushTokens, StartInput, 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';
@@ -42,3 +42,30 @@ export declare function writeImage(name: string, png: Uint8Array | ArrayBuffer):
42
42
  * must not be lost.
43
43
  */
44
44
  export declare function onAction(handler: (event: ActionEvent) => void): Promise<UnlistenFn>;
45
+ /**
46
+ * The push tokens the plugin holds since launch (iOS): the newest token of each of the last 32 activities that got
47
+ * one, and the app's push-to-start token. The events report each token as it comes, but an event reaches only the
48
+ * listeners there are when it goes out, and a token may come before the page listens, at launch above all:
49
+ * `onPushToken` and `onPushToStartToken` read this right after subscribing. Empty where there are no pushes. The
50
+ * read is in the plugin's `default` permission.
51
+ */
52
+ export declare function pushTokens(): Promise<PushTokens>;
53
+ /**
54
+ * Receive the push token of each activity that asked for one (`push: 'token'`), when ActivityKit gives it and each
55
+ * time it changes (iOS), and first those the plugin already holds, each token once. Send it to the server, which
56
+ * pushes to it with activitykit's `push::Payload`. Rejects, subscribed to nothing, when the plugin cannot be asked
57
+ * for the tokens it holds.
58
+ */
59
+ export declare function onPushToken(handler: (event: PushTokenEvent) => void): Promise<UnlistenFn>;
60
+ /**
61
+ * Receive the app's push-to-start token, with `pushToStart: true` in the plugin configuration (iOS 17.2), when the
62
+ * system gives it and each time it changes, and first the one the plugin already holds, each token once. The server
63
+ * starts activities with it. Rejects, subscribed to nothing, when the plugin cannot be asked for the token it holds.
64
+ */
65
+ export declare function onPushToStartToken(handler: (event: PushToStartTokenEvent) => void): Promise<UnlistenFn>;
66
+ /**
67
+ * Receive the record of an activity whose content a push changed (iOS): content above every revision this app sent
68
+ * or accepted, so the app's own updates do not come this way. Content pushed before the page listened is in the
69
+ * activity's record, as `listLayout` gives it.
70
+ */
71
+ export declare function onUpdated(handler: (event: UpdatedEvent) => void): Promise<UnlistenFn>;
package/dist-js/index.js CHANGED
@@ -68,3 +68,72 @@ export function writeImage(name, png) {
68
68
  export function onAction(handler) {
69
69
  return listen('live-activity://action', event => handler(event.payload));
70
70
  }
71
+ /**
72
+ * The push tokens the plugin holds since launch (iOS): the newest token of each of the last 32 activities that got
73
+ * one, and the app's push-to-start token. The events report each token as it comes, but an event reaches only the
74
+ * listeners there are when it goes out, and a token may come before the page listens, at launch above all:
75
+ * `onPushToken` and `onPushToStartToken` read this right after subscribing. Empty where there are no pushes. The
76
+ * read is in the plugin's `default` permission.
77
+ */
78
+ export function pushTokens() {
79
+ return invoke('plugin:live-activity|push_tokens');
80
+ }
81
+ /**
82
+ * Receive the push token of each activity that asked for one (`push: 'token'`), when ActivityKit gives it and each
83
+ * time it changes (iOS), and first those the plugin already holds, each token once. Send it to the server, which
84
+ * pushes to it with activitykit's `push::Payload`. Rejects, subscribed to nothing, when the plugin cannot be asked
85
+ * for the tokens it holds.
86
+ */
87
+ export async function onPushToken(handler) {
88
+ const delivered = new Map();
89
+ const deliver = (event) => {
90
+ if (delivered.get(event.activityId) === event.token)
91
+ return;
92
+ delivered.set(event.activityId, event.token);
93
+ handler(event);
94
+ };
95
+ const unlisten = await listen('live-activity://push-token', event => deliver(event.payload));
96
+ const held = await heldTokens(unlisten);
97
+ // An event that came while the plugin was asked is newer than what it held for that activity.
98
+ for (const event of held.activities)
99
+ if (!delivered.has(event.activityId))
100
+ deliver(event);
101
+ return unlisten;
102
+ }
103
+ /**
104
+ * Receive the app's push-to-start token, with `pushToStart: true` in the plugin configuration (iOS 17.2), when the
105
+ * system gives it and each time it changes, and first the one the plugin already holds, each token once. The server
106
+ * starts activities with it. Rejects, subscribed to nothing, when the plugin cannot be asked for the token it holds.
107
+ */
108
+ export async function onPushToStartToken(handler) {
109
+ let last;
110
+ const deliver = (event) => {
111
+ if (event.token === last)
112
+ return;
113
+ last = event.token;
114
+ handler(event);
115
+ };
116
+ const unlisten = await listen('live-activity://push-to-start-token', event => deliver(event.payload));
117
+ const held = await heldTokens(unlisten);
118
+ if (last === undefined && held.pushToStart !== undefined)
119
+ deliver({ token: held.pushToStart });
120
+ return unlisten;
121
+ }
122
+ /** What the plugin holds, or the subscription given up and the failure passed on. */
123
+ async function heldTokens(unlisten) {
124
+ try {
125
+ return await pushTokens();
126
+ }
127
+ catch (error) {
128
+ unlisten();
129
+ throw error;
130
+ }
131
+ }
132
+ /**
133
+ * Receive the record of an activity whose content a push changed (iOS): content above every revision this app sent
134
+ * or accepted, so the app's own updates do not come this way. Content pushed before the page listened is in the
135
+ * activity's record, as `listLayout` gives it.
136
+ */
137
+ export function onUpdated(handler) {
138
+ return listen('live-activity://updated', event => handler(event.payload));
139
+ }
@@ -7,6 +7,7 @@ export interface UseLiveActivityOptions extends SessionOptions {
7
7
  }
8
8
  /**
9
9
  * Starts a layout activity on mount, sends `values` as an update whenever they change, and ends the activity on
10
- * unmount or when `enabled` turns false.
10
+ * unmount or when `enabled` turns false. The state carries the activity's push token and takes content a push
11
+ * delivered (iOS).
11
12
  */
12
13
  export declare function useLiveActivity(options: UseLiveActivityOptions): LiveActivityState;
@@ -1,11 +1,12 @@
1
1
  // `useLiveActivity`: one layout activity kept in step with a React component. Only this entry imports React.
2
2
  import { useEffect, useRef, useState } from 'react';
3
- import { endLayout, onAction, startLayout, updateLayout } from '../index.js';
3
+ import { endLayout, onAction, onPushToken, onUpdated, startLayout, updateLayout } from '../index.js';
4
4
  import { IDLE, Session } from './session.js';
5
5
  const commands = { startLayout, updateLayout, endLayout };
6
6
  /**
7
7
  * Starts a layout activity on mount, sends `values` as an update whenever they change, and ends the activity on
8
- * unmount or when `enabled` turns false.
8
+ * unmount or when `enabled` turns false. The state carries the activity's push token and takes content a push
9
+ * delivered (iOS).
9
10
  */
10
11
  export function useLiveActivity(options) {
11
12
  const [state, setState] = useState(IDLE);
@@ -15,6 +16,8 @@ export function useLiveActivity(options) {
15
16
  const handler = useRef(options.onAction);
16
17
  handler.current = options.onAction;
17
18
  const listening = options.onAction !== undefined;
19
+ // Read at start, as `push` is: an activity that asks for no push gets no token and no pushed content.
20
+ const pushing = options.push !== undefined;
18
21
  useEffect(() => {
19
22
  session.current?.sync(options);
20
23
  });
@@ -24,6 +27,25 @@ export function useLiveActivity(options) {
24
27
  current?.keep();
25
28
  return () => current?.release();
26
29
  }, []);
30
+ useEffect(() => {
31
+ if (!pushing)
32
+ return undefined;
33
+ let open = true;
34
+ const stops = [
35
+ onPushToken((event) => { if (open)
36
+ session.current?.token(event); }),
37
+ onUpdated((event) => { if (open)
38
+ session.current?.pushed(event); }),
39
+ ];
40
+ for (const stop of stops)
41
+ stop.catch((error) => { if (open)
42
+ session.current?.failed(error); });
43
+ return () => {
44
+ open = false;
45
+ for (const stop of stops)
46
+ stop.then((unlisten) => unlisten(), () => { });
47
+ };
48
+ }, [pushing]);
27
49
  useEffect(() => {
28
50
  if (!listening)
29
51
  return undefined;
@@ -33,6 +55,8 @@ export function useLiveActivity(options) {
33
55
  if (open && running !== undefined && event.activityId === running)
34
56
  handler.current?.(event);
35
57
  });
58
+ stop.catch((error) => { if (open)
59
+ session.current?.failed(error); });
36
60
  return () => {
37
61
  open = false;
38
62
  stop.then((unlisten) => unlisten(), () => { });
@@ -1,4 +1,4 @@
1
- import type { EndPolicy, Fallback, Layout, LayoutActivityRecord, LayoutAndroidOptions, LayoutEndInput, LayoutStartInput, LayoutStyle, LayoutUpdateInput, LayoutValues, LiveActivityError } from '../types.js';
1
+ import type { EndPolicy, Fallback, Layout, LayoutActivityRecord, LayoutAndroidOptions, LayoutEndInput, LayoutPush, LayoutStartInput, LayoutStyle, LayoutUpdateInput, LayoutValues, LiveActivityError, PushTokenEvent, UpdatedEvent } from '../types.js';
2
2
  export interface SessionOptions {
3
3
  /** The app's key of the activity; another key ends the running activity and starts one for it. */
4
4
  readonly activityKey: string;
@@ -14,6 +14,8 @@ export interface SessionOptions {
14
14
  readonly fallback?: Fallback;
15
15
  /** Read at start. */
16
16
  readonly android?: LayoutAndroidOptions;
17
+ /** Read at start: what the activity asks ActivityKit for, a push token or a channel (iOS). */
18
+ readonly push?: LayoutPush;
17
19
  /** False ends the activity, and true starts it again. Defaults to true. */
18
20
  readonly enabled?: boolean;
19
21
  /** How the activity ends on unmount or when `enabled` turns false. Defaults to `{ kind: 'immediate' }`. */
@@ -26,6 +28,8 @@ export interface LiveActivityState {
26
28
  readonly record: LayoutActivityRecord | undefined;
27
29
  /** The last refusal; an accepted request clears it. */
28
30
  readonly error: LiveActivityError | undefined;
31
+ /** The running activity's latest push token (iOS, with `push: 'token'`), until the activity ends. */
32
+ readonly pushToken: string | undefined;
29
33
  }
30
34
  /** The commands the session sends. */
31
35
  export interface SessionCommands {
@@ -46,11 +50,22 @@ export declare class Session {
46
50
  private refused;
47
51
  /** The key whose start was refused: not started again until `enabled` turns off or the key changes. */
48
52
  private failedKey;
53
+ /** The latest push token of each activity seen, by id: one may come before the start it belongs to has answered. */
54
+ private readonly tokens;
49
55
  private busy;
50
56
  private mounts;
51
57
  constructor(commands: SessionCommands, changed: (state: LiveActivityState) => void);
52
58
  /** The id of the running activity. */
53
59
  get activityId(): string | undefined;
60
+ /** A push token: the running activity's goes into the state; one that comes before its start answered waits. */
61
+ token(event: PushTokenEvent): void;
62
+ /**
63
+ * Content a push delivered: the running activity's record takes it. The component's values stand as last sent, so
64
+ * the pushed content stays until they change, and that change goes above the pushed revision.
65
+ */
66
+ pushed(event: UpdatedEvent): void;
67
+ /** A failure outside a request, as a subscription the plugin refused: it lands in `error`. */
68
+ failed(error: unknown): void;
54
69
  /** The options of a render. */
55
70
  sync(options: SessionOptions): void;
56
71
  /** The component is gone: the activity ends, now or once the request in flight has answered. */
@@ -1,4 +1,4 @@
1
- export const IDLE = Object.freeze({ status: 'idle', record: undefined, error: undefined });
1
+ export const IDLE = Object.freeze({ status: 'idle', record: undefined, error: undefined, pushToken: undefined });
2
2
  const IMMEDIATE = Object.freeze({ kind: 'immediate' });
3
3
  export class Session {
4
4
  constructor(commands, changed) {
@@ -6,6 +6,8 @@ export class Session {
6
6
  this.changed = changed;
7
7
  this.state = IDLE;
8
8
  this.endPolicy = IMMEDIATE;
9
+ /** The latest push token of each activity seen, by id: one may come before the start it belongs to has answered. */
10
+ this.tokens = new Map();
9
11
  this.busy = false;
10
12
  this.mounts = 0;
11
13
  }
@@ -13,6 +15,28 @@ export class Session {
13
15
  get activityId() {
14
16
  return this.running?.record.id;
15
17
  }
18
+ /** A push token: the running activity's goes into the state; one that comes before its start answered waits. */
19
+ token(event) {
20
+ this.tokens.set(event.activityId, event.token);
21
+ if (this.running?.record.id === event.activityId)
22
+ this.set({ ...this.state, pushToken: event.token });
23
+ }
24
+ /**
25
+ * Content a push delivered: the running activity's record takes it. The component's values stand as last sent, so
26
+ * the pushed content stays until they change, and that change goes above the pushed revision.
27
+ */
28
+ pushed(event) {
29
+ const { record } = event;
30
+ if (!this.running || record.id !== this.running.record.id)
31
+ return;
32
+ const revision = Math.max(this.running.revision, record.snapshot.revision);
33
+ this.running = { ...this.running, record, revision };
34
+ this.set({ ...this.state, record });
35
+ }
36
+ /** A failure outside a request, as a subscription the plugin refused: it lands in `error`. */
37
+ failed(error) {
38
+ this.set({ ...this.state, error: asError(error) });
39
+ }
16
40
  /** The options of a render. */
17
41
  sync(options) {
18
42
  this.endPolicy = options.endPolicy ?? IMMEDIATE;
@@ -71,18 +95,20 @@ export class Session {
71
95
  snapshot: { revision: 0, values },
72
96
  ...(options.styles === undefined ? {} : { styles: options.styles }),
73
97
  ...(options.android === undefined ? {} : { android: options.android }),
98
+ ...(options.push === undefined ? {} : { push: options.push }),
74
99
  };
75
100
  this.failedKey = undefined;
76
101
  this.refused = undefined;
77
- this.set({ status: 'starting', record: undefined, error: undefined });
102
+ this.set({ status: 'starting', record: undefined, error: undefined, pushToken: undefined });
78
103
  this.send(this.commands.startLayout(input), (record) => {
79
- this.running = { record, values, revision: 0 };
80
- this.set({ status: 'active', record, error: undefined });
104
+ // A repeated keyed start, after a relaunch, answers the running activity at its own revision.
105
+ this.running = { record, values, revision: record.snapshot.revision };
106
+ this.set({ status: 'active', record, error: undefined, pushToken: this.tokens.get(record.id) });
81
107
  }, (error) => {
82
108
  // Blocks only the key still wanted: `enabled` off meanwhile, or another key, starts again.
83
109
  if (this.wanted?.activityKey === options.activityKey)
84
110
  this.failedKey = options.activityKey;
85
- this.set({ status: 'failed', record: undefined, error });
111
+ this.set({ status: 'failed', record: undefined, error, pushToken: undefined });
86
112
  });
87
113
  }
88
114
  update(running, values) {
@@ -91,22 +117,25 @@ export class Session {
91
117
  this.running = { ...running, revision };
92
118
  this.send(this.commands.updateLayout({ id: running.record.id, snapshot: { revision, values } }), (record) => {
93
119
  this.refused = undefined;
94
- this.running = { record, values, revision };
95
- this.set({ status: 'active', record, error: undefined });
120
+ // A push may have moved the activity on meanwhile: the next change goes above it.
121
+ const taken = Math.max(revision, record.snapshot.revision, this.running?.revision ?? 0);
122
+ this.running = { record, values, revision: taken };
123
+ this.set({ status: 'active', record, error: undefined, pushToken: this.state.pushToken });
96
124
  }, (error) => {
97
125
  this.refused = values;
98
126
  this.set({ ...this.state, error });
99
127
  });
100
128
  }
101
129
  end(record) {
102
- this.set({ status: 'ending', record, error: this.state.error });
130
+ this.set({ status: 'ending', record, error: this.state.error, pushToken: this.state.pushToken });
131
+ this.tokens.delete(record.id);
103
132
  this.send(this.commands.endLayout({ id: record.id, policy: this.endPolicy }), (ended) => {
104
133
  this.running = undefined;
105
- this.set({ status: 'ended', record: ended, error: undefined });
134
+ this.set({ status: 'ended', record: ended, error: undefined, pushToken: undefined });
106
135
  }, (error) => {
107
136
  // Not tried again: the activity is left to the system.
108
137
  this.running = undefined;
109
- this.set({ status: 'failed', record, error });
138
+ this.set({ status: 'failed', record, error, pushToken: undefined });
110
139
  });
111
140
  }
112
141
  send(request, accepted, refused) {
@@ -17,12 +17,16 @@ export interface Capabilities {
17
17
  readonly nativeLiveActivity: FeatureSupport;
18
18
  /** Layout activities of request contract v2. */
19
19
  readonly layout: FeatureSupport;
20
+ /** Pushes: tokens, channels and push-to-start (iOS). */
21
+ readonly push: FeatureSupport;
20
22
  readonly maxPayloadBytes: number;
21
23
  }
22
24
  export interface Permissions {
23
25
  readonly notifications: PermissionState;
24
26
  readonly liveActivities: PermissionState;
25
27
  readonly promotion: PermissionState;
28
+ /** Frequent pushes, a switch in Settings on iOS (`granted` or `denied`); `notApplicable` where there are no pushes. */
29
+ readonly frequentPushes: PermissionState;
26
30
  }
27
31
  interface SnapshotFields {
28
32
  /** Nonnegative JavaScript safe integer; strictly increases when content changes. */
@@ -368,6 +372,13 @@ export interface LayoutAndroidOptions {
368
372
  /** Lock screen visibility of the notification. */
369
373
  readonly visibility: 'public' | 'private' | 'secret';
370
374
  }
375
+ /**
376
+ * What a layout activity asks ActivityKit for on iOS: a push token of its own, which `onPushToken` reports, or a
377
+ * broadcast channel the server made at APNs (iOS 18; `UNSUPPORTED_FEATURE` before). Android ignores it.
378
+ */
379
+ export type LayoutPush = 'token' | {
380
+ readonly channel: string;
381
+ };
371
382
  export interface LayoutStartInput {
372
383
  /** Stable app-owned key; do not put credentials or private data in this key. */
373
384
  readonly activityKey: string;
@@ -383,6 +394,8 @@ export interface LayoutStartInput {
383
394
  readonly snapshot: LayoutSnapshot;
384
395
  /** Ignored on iOS. */
385
396
  readonly android?: LayoutAndroidOptions;
397
+ /** Ignored on Android. */
398
+ readonly push?: LayoutPush;
386
399
  }
387
400
  export interface LayoutUpdateInput {
388
401
  readonly id: string;
@@ -412,6 +425,34 @@ export interface LayoutActivityRecord {
412
425
  readonly promotionRequested: boolean;
413
426
  readonly promotionState: PromotionState;
414
427
  }
428
+ /** A push token of an activity, new or changed: what the server sends to. */
429
+ export interface PushTokenEvent {
430
+ readonly activityId: string;
431
+ /** The key of that activity, when the plugin knows it. */
432
+ readonly activityKey?: string;
433
+ /** Lowercase hex, as APNs takes it. */
434
+ readonly token: string;
435
+ }
436
+ /** The app's push-to-start token, new or changed (`pushToStart` in the plugin configuration, iOS 17.2). */
437
+ export interface PushToStartTokenEvent {
438
+ readonly token: string;
439
+ }
440
+ /**
441
+ * Content a push delivered: the activity's record with it, above every revision the app sent or accepted. The record
442
+ * is the activity's state when the plugin reads the event: two pushes close together may both report the later one.
443
+ */
444
+ export interface UpdatedEvent {
445
+ readonly record: LayoutActivityRecord;
446
+ }
447
+ /**
448
+ * The push tokens the plugin holds since launch (iOS): the newest token of each of the last 32 activities that got
449
+ * one, and the app's push-to-start token. Empty where there are no pushes.
450
+ */
451
+ export interface PushTokens {
452
+ readonly pushToStart?: string;
453
+ /** In the order the activities' first tokens came. */
454
+ readonly activities: readonly PushTokenEvent[];
455
+ }
415
456
  /** A tap on a button node. */
416
457
  export interface ActionEvent {
417
458
  readonly actionId: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tauri-plugin-live-activity",
3
- "version": "0.5.1",
3
+ "version": "0.6.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",