@idealyst/live-activity 1.2.114
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/android/build.gradle +39 -0
- package/android/src/main/AndroidManifest.xml +7 -0
- package/android/src/main/java/io/idealyst/liveactivity/IdealystLiveActivityModule.kt +299 -0
- package/android/src/main/java/io/idealyst/liveactivity/IdealystLiveActivityPackage.kt +16 -0
- package/android/src/main/java/io/idealyst/liveactivity/LiveUpdateNotification.kt +265 -0
- package/idealyst-live-activity.podspec +22 -0
- package/ios/IdealystLiveActivity-Bridging-Header.h +2 -0
- package/ios/IdealystLiveActivity.mm +55 -0
- package/ios/IdealystLiveActivity.swift +571 -0
- package/ios/Templates/ActivityAttributes.swift +66 -0
- package/ios/Templates/DeliveryActivityView.swift +143 -0
- package/ios/Templates/IdealystActivityBundle.swift +18 -0
- package/ios/Templates/MediaActivityView.swift +124 -0
- package/ios/Templates/ProgressActivityView.swift +164 -0
- package/ios/Templates/TimerActivityView.swift +110 -0
- package/package.json +80 -0
- package/src/NativeLiveActivitySpec.ts +49 -0
- package/src/activity/activity.native.ts +198 -0
- package/src/activity/activity.web.ts +78 -0
- package/src/activity/useLiveActivity.ts +267 -0
- package/src/constants.ts +39 -0
- package/src/errors.ts +57 -0
- package/src/index.native.ts +59 -0
- package/src/index.ts +61 -0
- package/src/index.web.ts +2 -0
- package/src/templates/presets.ts +91 -0
- package/src/templates/types.ts +14 -0
- package/src/types.ts +343 -0
package/src/index.ts
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// Default entry — re-exports web implementation.
|
|
2
|
+
// Platform-specific entry points (index.native.ts, index.web.ts) are resolved by bundlers.
|
|
3
|
+
export * from './types';
|
|
4
|
+
export {
|
|
5
|
+
TEMPLATE_IDS,
|
|
6
|
+
DEFAULT_CHANNEL_ID,
|
|
7
|
+
DEFAULT_CHANNEL_NAME,
|
|
8
|
+
DEFAULT_CHANNEL_DESCRIPTION,
|
|
9
|
+
DEFAULT_SMALL_ICON,
|
|
10
|
+
MAX_CONCURRENT_ACTIVITIES_IOS,
|
|
11
|
+
MAX_CONCURRENT_ACTIVITIES_ANDROID,
|
|
12
|
+
LIVE_ACTIVITY_EVENT,
|
|
13
|
+
} from './constants';
|
|
14
|
+
export { createLiveActivityError, normalizeLiveActivityError } from './errors';
|
|
15
|
+
|
|
16
|
+
// Template presets
|
|
17
|
+
export {
|
|
18
|
+
deliveryActivity,
|
|
19
|
+
timerActivity,
|
|
20
|
+
mediaActivity,
|
|
21
|
+
progressActivity,
|
|
22
|
+
} from './templates/presets';
|
|
23
|
+
|
|
24
|
+
// Activity functions — web stubs
|
|
25
|
+
export {
|
|
26
|
+
checkAvailability,
|
|
27
|
+
start,
|
|
28
|
+
update,
|
|
29
|
+
end,
|
|
30
|
+
endAll,
|
|
31
|
+
getActivity,
|
|
32
|
+
listActivities,
|
|
33
|
+
getPushToken,
|
|
34
|
+
addEventListener,
|
|
35
|
+
} from './activity/activity.web';
|
|
36
|
+
|
|
37
|
+
// Hook — bound to web implementations
|
|
38
|
+
import { createUseLiveActivityHook } from './activity/useLiveActivity';
|
|
39
|
+
import {
|
|
40
|
+
checkAvailability,
|
|
41
|
+
start,
|
|
42
|
+
update,
|
|
43
|
+
end,
|
|
44
|
+
endAll,
|
|
45
|
+
getActivity,
|
|
46
|
+
listActivities,
|
|
47
|
+
getPushToken,
|
|
48
|
+
addEventListener,
|
|
49
|
+
} from './activity/activity.web';
|
|
50
|
+
|
|
51
|
+
export const useLiveActivity = createUseLiveActivityHook({
|
|
52
|
+
checkAvailability,
|
|
53
|
+
start,
|
|
54
|
+
update,
|
|
55
|
+
end,
|
|
56
|
+
endAll,
|
|
57
|
+
getActivity,
|
|
58
|
+
listActivities,
|
|
59
|
+
getPushToken,
|
|
60
|
+
addEventListener,
|
|
61
|
+
});
|
package/src/index.web.ts
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
StartActivityOptions,
|
|
3
|
+
DeliveryAttributes,
|
|
4
|
+
DeliveryContentState,
|
|
5
|
+
TimerAttributes,
|
|
6
|
+
TimerContentState,
|
|
7
|
+
MediaAttributes,
|
|
8
|
+
MediaContentState,
|
|
9
|
+
ProgressAttributes,
|
|
10
|
+
ProgressContentState,
|
|
11
|
+
} from '../types';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Create a delivery/rideshare Live Activity with sensible defaults.
|
|
15
|
+
*/
|
|
16
|
+
export function deliveryActivity(
|
|
17
|
+
attributes: DeliveryAttributes,
|
|
18
|
+
contentState: DeliveryContentState,
|
|
19
|
+
options?: Partial<Omit<StartActivityOptions<'delivery'>, 'templateType' | 'attributes' | 'contentState'>>,
|
|
20
|
+
): StartActivityOptions<'delivery'> {
|
|
21
|
+
return {
|
|
22
|
+
templateType: 'delivery',
|
|
23
|
+
attributes: {
|
|
24
|
+
accentColor: '#FF5722',
|
|
25
|
+
...attributes,
|
|
26
|
+
},
|
|
27
|
+
contentState: {
|
|
28
|
+
...contentState,
|
|
29
|
+
progress: contentState.progress ?? 0,
|
|
30
|
+
},
|
|
31
|
+
...options,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Create a timer/countdown Live Activity with sensible defaults.
|
|
37
|
+
*/
|
|
38
|
+
export function timerActivity(
|
|
39
|
+
attributes: TimerAttributes,
|
|
40
|
+
contentState: TimerContentState,
|
|
41
|
+
options?: Partial<Omit<StartActivityOptions<'timer'>, 'templateType' | 'attributes' | 'contentState'>>,
|
|
42
|
+
): StartActivityOptions<'timer'> {
|
|
43
|
+
return {
|
|
44
|
+
templateType: 'timer',
|
|
45
|
+
attributes: {
|
|
46
|
+
showElapsed: false,
|
|
47
|
+
...attributes,
|
|
48
|
+
},
|
|
49
|
+
contentState,
|
|
50
|
+
...options,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Create a media playback Live Activity with sensible defaults.
|
|
56
|
+
*/
|
|
57
|
+
export function mediaActivity(
|
|
58
|
+
attributes: MediaAttributes,
|
|
59
|
+
contentState: MediaContentState,
|
|
60
|
+
options?: Partial<Omit<StartActivityOptions<'media'>, 'templateType' | 'attributes' | 'contentState'>>,
|
|
61
|
+
): StartActivityOptions<'media'> {
|
|
62
|
+
return {
|
|
63
|
+
templateType: 'media',
|
|
64
|
+
attributes,
|
|
65
|
+
contentState: {
|
|
66
|
+
...contentState,
|
|
67
|
+
isPlaying: contentState.isPlaying ?? false,
|
|
68
|
+
},
|
|
69
|
+
...options,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Create a generic progress Live Activity with sensible defaults.
|
|
75
|
+
*/
|
|
76
|
+
export function progressActivity(
|
|
77
|
+
attributes: ProgressAttributes,
|
|
78
|
+
contentState: ProgressContentState,
|
|
79
|
+
options?: Partial<Omit<StartActivityOptions<'progress'>, 'templateType' | 'attributes' | 'contentState'>>,
|
|
80
|
+
): StartActivityOptions<'progress'> {
|
|
81
|
+
return {
|
|
82
|
+
templateType: 'progress',
|
|
83
|
+
attributes,
|
|
84
|
+
contentState: {
|
|
85
|
+
...contentState,
|
|
86
|
+
progress: contentState.progress ?? 0,
|
|
87
|
+
indeterminate: contentState.indeterminate ?? false,
|
|
88
|
+
},
|
|
89
|
+
...options,
|
|
90
|
+
};
|
|
91
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// Re-export template-specific types for convenience.
|
|
2
|
+
export type {
|
|
3
|
+
TemplateType,
|
|
4
|
+
DeliveryAttributes,
|
|
5
|
+
DeliveryContentState,
|
|
6
|
+
TimerAttributes,
|
|
7
|
+
TimerContentState,
|
|
8
|
+
MediaAttributes,
|
|
9
|
+
MediaContentState,
|
|
10
|
+
ProgressAttributes,
|
|
11
|
+
ProgressContentState,
|
|
12
|
+
TemplateAttributesMap,
|
|
13
|
+
TemplateContentStateMap,
|
|
14
|
+
} from '../types';
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
// ============================================================================
|
|
2
|
+
// Core Types
|
|
3
|
+
// ============================================================================
|
|
4
|
+
|
|
5
|
+
export type LiveActivityState =
|
|
6
|
+
| 'idle'
|
|
7
|
+
| 'starting'
|
|
8
|
+
| 'active'
|
|
9
|
+
| 'updating'
|
|
10
|
+
| 'ending'
|
|
11
|
+
| 'ended'
|
|
12
|
+
| 'stale';
|
|
13
|
+
|
|
14
|
+
export type LiveActivityDismissalPolicy =
|
|
15
|
+
| 'immediate'
|
|
16
|
+
| 'default'
|
|
17
|
+
| 'afterDate';
|
|
18
|
+
|
|
19
|
+
export interface LiveActivityToken {
|
|
20
|
+
/** The push token for remote updates (base64 string). */
|
|
21
|
+
token: string;
|
|
22
|
+
/** Platform: 'ios' (APNs) or 'android' (FCM). */
|
|
23
|
+
platform: 'ios' | 'android';
|
|
24
|
+
/** Activity ID this token is associated with. */
|
|
25
|
+
activityId: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface LiveActivityInfo {
|
|
29
|
+
/** Unique activity identifier. */
|
|
30
|
+
id: string;
|
|
31
|
+
/** Current state. */
|
|
32
|
+
state: LiveActivityState;
|
|
33
|
+
/** Push token for remote updates (if available). */
|
|
34
|
+
pushToken?: LiveActivityToken;
|
|
35
|
+
/** Timestamp when activity was started (ms since epoch). */
|
|
36
|
+
startedAt: number;
|
|
37
|
+
/** Template type used. */
|
|
38
|
+
templateType: TemplateType;
|
|
39
|
+
/** Static attributes. */
|
|
40
|
+
attributes: Record<string, unknown>;
|
|
41
|
+
/** Current content state. */
|
|
42
|
+
contentState: Record<string, unknown>;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// ============================================================================
|
|
46
|
+
// Template Types
|
|
47
|
+
// ============================================================================
|
|
48
|
+
|
|
49
|
+
export type TemplateType =
|
|
50
|
+
| 'delivery'
|
|
51
|
+
| 'timer'
|
|
52
|
+
| 'media'
|
|
53
|
+
| 'progress'
|
|
54
|
+
| 'custom';
|
|
55
|
+
|
|
56
|
+
export interface DeliveryAttributes {
|
|
57
|
+
/** Starting point label. */
|
|
58
|
+
startLabel: string;
|
|
59
|
+
/** Ending point label. */
|
|
60
|
+
endLabel: string;
|
|
61
|
+
/** Icon name or asset URI. */
|
|
62
|
+
icon?: string;
|
|
63
|
+
/** Accent color (hex). */
|
|
64
|
+
accentColor?: string;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export interface DeliveryContentState {
|
|
68
|
+
/** Progress value 0-1. */
|
|
69
|
+
progress: number;
|
|
70
|
+
/** Current status text. */
|
|
71
|
+
status: string;
|
|
72
|
+
/** ETA timestamp (ms since epoch). */
|
|
73
|
+
eta?: number;
|
|
74
|
+
/** Driver/courier name. */
|
|
75
|
+
driverName?: string;
|
|
76
|
+
/** Additional info line. */
|
|
77
|
+
subtitle?: string;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export interface TimerAttributes {
|
|
81
|
+
/** Activity title. */
|
|
82
|
+
title: string;
|
|
83
|
+
/** Icon name or asset URI. */
|
|
84
|
+
icon?: string;
|
|
85
|
+
/** Accent color (hex). */
|
|
86
|
+
accentColor?: string;
|
|
87
|
+
/** Whether to show elapsed time instead of countdown. */
|
|
88
|
+
showElapsed?: boolean;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export interface TimerContentState {
|
|
92
|
+
/** Target end time (ms since epoch). */
|
|
93
|
+
endTime: number;
|
|
94
|
+
/** Whether timer is paused. */
|
|
95
|
+
isPaused?: boolean;
|
|
96
|
+
/** Subtitle text. */
|
|
97
|
+
subtitle?: string;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export interface MediaAttributes {
|
|
101
|
+
/** Album or playlist title. */
|
|
102
|
+
title: string;
|
|
103
|
+
/** Album art URI. */
|
|
104
|
+
artworkUri?: string;
|
|
105
|
+
/** Accent color (hex). */
|
|
106
|
+
accentColor?: string;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export interface MediaContentState {
|
|
110
|
+
/** Track title. */
|
|
111
|
+
trackTitle: string;
|
|
112
|
+
/** Artist name. */
|
|
113
|
+
artist?: string;
|
|
114
|
+
/** Is currently playing. */
|
|
115
|
+
isPlaying: boolean;
|
|
116
|
+
/** Progress 0-1. */
|
|
117
|
+
progress?: number;
|
|
118
|
+
/** Total duration in seconds. */
|
|
119
|
+
duration?: number;
|
|
120
|
+
/** Current position in seconds. */
|
|
121
|
+
position?: number;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export interface ProgressAttributes {
|
|
125
|
+
/** Activity title. */
|
|
126
|
+
title: string;
|
|
127
|
+
/** Icon name or asset URI. */
|
|
128
|
+
icon?: string;
|
|
129
|
+
/** Accent color (hex). */
|
|
130
|
+
accentColor?: string;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export interface ProgressContentState {
|
|
134
|
+
/** Progress value 0-1. */
|
|
135
|
+
progress: number;
|
|
136
|
+
/** Status text. */
|
|
137
|
+
status: string;
|
|
138
|
+
/** Subtitle text. */
|
|
139
|
+
subtitle?: string;
|
|
140
|
+
/** Whether progress is indeterminate. */
|
|
141
|
+
indeterminate?: boolean;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/** Maps template type to its static attributes interface. */
|
|
145
|
+
export interface TemplateAttributesMap {
|
|
146
|
+
delivery: DeliveryAttributes;
|
|
147
|
+
timer: TimerAttributes;
|
|
148
|
+
media: MediaAttributes;
|
|
149
|
+
progress: ProgressAttributes;
|
|
150
|
+
custom: Record<string, unknown>;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/** Maps template type to its content state interface. */
|
|
154
|
+
export interface TemplateContentStateMap {
|
|
155
|
+
delivery: DeliveryContentState;
|
|
156
|
+
timer: TimerContentState;
|
|
157
|
+
media: MediaContentState;
|
|
158
|
+
progress: ProgressContentState;
|
|
159
|
+
custom: Record<string, unknown>;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// ============================================================================
|
|
163
|
+
// Options Types
|
|
164
|
+
// ============================================================================
|
|
165
|
+
|
|
166
|
+
export interface StartActivityOptions<T extends TemplateType = TemplateType> {
|
|
167
|
+
/** Template type to use. */
|
|
168
|
+
templateType: T;
|
|
169
|
+
/** Static attributes (don't change during activity). */
|
|
170
|
+
attributes: TemplateAttributesMap[T];
|
|
171
|
+
/** Initial content state (can be updated). */
|
|
172
|
+
contentState: TemplateContentStateMap[T];
|
|
173
|
+
/** Enable push token generation for remote updates. */
|
|
174
|
+
enablePushUpdates?: boolean;
|
|
175
|
+
/** iOS-specific options. */
|
|
176
|
+
ios?: {
|
|
177
|
+
/** Relevance score 0-100 (affects Dynamic Island priority). */
|
|
178
|
+
relevanceScore?: number;
|
|
179
|
+
/** Stale date (ms since epoch) — system marks activity stale after this. */
|
|
180
|
+
staleDate?: number;
|
|
181
|
+
};
|
|
182
|
+
/** Android-specific options. */
|
|
183
|
+
android?: {
|
|
184
|
+
/** Notification channel ID. */
|
|
185
|
+
channelId?: string;
|
|
186
|
+
/** Notification ID (auto-generated if omitted). */
|
|
187
|
+
notificationId?: number;
|
|
188
|
+
/** Small icon resource name. */
|
|
189
|
+
smallIcon?: string;
|
|
190
|
+
/** Deep link URL when notification is tapped. */
|
|
191
|
+
deepLinkUrl?: string;
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
export interface UpdateActivityOptions<T extends TemplateType = TemplateType> {
|
|
196
|
+
/** New content state (partial — merged with existing). */
|
|
197
|
+
contentState: Partial<TemplateContentStateMap[T]>;
|
|
198
|
+
/** iOS: alert configuration for this update. */
|
|
199
|
+
alert?: {
|
|
200
|
+
title?: string;
|
|
201
|
+
body?: string;
|
|
202
|
+
sound?: boolean;
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
export interface EndActivityOptions {
|
|
207
|
+
/** Final content state to display before dismissal. */
|
|
208
|
+
finalContentState?: Record<string, unknown>;
|
|
209
|
+
/** Dismissal policy. Default: 'default'. */
|
|
210
|
+
dismissalPolicy?: LiveActivityDismissalPolicy;
|
|
211
|
+
/** For 'afterDate' policy: timestamp when to dismiss (ms since epoch). */
|
|
212
|
+
dismissAfter?: number;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
// ============================================================================
|
|
216
|
+
// Event Types
|
|
217
|
+
// ============================================================================
|
|
218
|
+
|
|
219
|
+
export type LiveActivityEventType =
|
|
220
|
+
| 'started'
|
|
221
|
+
| 'updated'
|
|
222
|
+
| 'ended'
|
|
223
|
+
| 'tokenUpdated'
|
|
224
|
+
| 'stale'
|
|
225
|
+
| 'error';
|
|
226
|
+
|
|
227
|
+
export interface LiveActivityEvent {
|
|
228
|
+
/** Event type. */
|
|
229
|
+
type: LiveActivityEventType;
|
|
230
|
+
/** Activity this event relates to. */
|
|
231
|
+
activityId: string;
|
|
232
|
+
/** Timestamp of the event (ms since epoch). */
|
|
233
|
+
timestamp: number;
|
|
234
|
+
/** Event-specific payload. */
|
|
235
|
+
payload?: {
|
|
236
|
+
state?: LiveActivityState;
|
|
237
|
+
token?: LiveActivityToken;
|
|
238
|
+
error?: LiveActivityError;
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
export type LiveActivityEventHandler = (event: LiveActivityEvent) => void;
|
|
243
|
+
|
|
244
|
+
// ============================================================================
|
|
245
|
+
// Error Types
|
|
246
|
+
// ============================================================================
|
|
247
|
+
|
|
248
|
+
export type LiveActivityErrorCode =
|
|
249
|
+
| 'not_available'
|
|
250
|
+
| 'not_supported'
|
|
251
|
+
| 'permission_denied'
|
|
252
|
+
| 'start_failed'
|
|
253
|
+
| 'update_failed'
|
|
254
|
+
| 'end_failed'
|
|
255
|
+
| 'activity_not_found'
|
|
256
|
+
| 'template_not_found'
|
|
257
|
+
| 'invalid_attributes'
|
|
258
|
+
| 'too_many_activities'
|
|
259
|
+
| 'unknown';
|
|
260
|
+
|
|
261
|
+
export interface LiveActivityError {
|
|
262
|
+
code: LiveActivityErrorCode;
|
|
263
|
+
message: string;
|
|
264
|
+
originalError?: unknown;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
// ============================================================================
|
|
268
|
+
// Hook Types
|
|
269
|
+
// ============================================================================
|
|
270
|
+
|
|
271
|
+
export interface UseLiveActivityOptions {
|
|
272
|
+
/** Auto-check availability on mount. */
|
|
273
|
+
autoCheckAvailability?: boolean;
|
|
274
|
+
/** Event handler for activity state changes. */
|
|
275
|
+
onEvent?: LiveActivityEventHandler;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
export interface UseLiveActivityResult {
|
|
279
|
+
/** Whether Live Activities are supported on this device. */
|
|
280
|
+
isSupported: boolean;
|
|
281
|
+
/** Whether Live Activities are enabled by the user (iOS settings). */
|
|
282
|
+
isEnabled: boolean | null;
|
|
283
|
+
/** Currently active activity info (most recent). */
|
|
284
|
+
currentActivity: LiveActivityInfo | null;
|
|
285
|
+
/** All active activities. */
|
|
286
|
+
activities: LiveActivityInfo[];
|
|
287
|
+
/** Loading state. */
|
|
288
|
+
isLoading: boolean;
|
|
289
|
+
/** Current error. */
|
|
290
|
+
error: LiveActivityError | null;
|
|
291
|
+
|
|
292
|
+
/** Check if Live Activities are available. */
|
|
293
|
+
checkAvailability: () => Promise<{ supported: boolean; enabled: boolean }>;
|
|
294
|
+
/** Start a new Live Activity. */
|
|
295
|
+
start: <T extends TemplateType>(options: StartActivityOptions<T>) => Promise<LiveActivityInfo>;
|
|
296
|
+
/** Update an existing activity. */
|
|
297
|
+
update: <T extends TemplateType>(activityId: string, options: UpdateActivityOptions<T>) => Promise<void>;
|
|
298
|
+
/** End an activity. */
|
|
299
|
+
end: (activityId: string, options?: EndActivityOptions) => Promise<void>;
|
|
300
|
+
/** End all activities. */
|
|
301
|
+
endAll: (options?: EndActivityOptions) => Promise<void>;
|
|
302
|
+
/** Get activity by ID. */
|
|
303
|
+
getActivity: (activityId: string) => Promise<LiveActivityInfo | null>;
|
|
304
|
+
/** List all current activities. */
|
|
305
|
+
listActivities: () => Promise<LiveActivityInfo[]>;
|
|
306
|
+
/** Get push token for an activity. */
|
|
307
|
+
getPushToken: (activityId: string) => Promise<LiveActivityToken | null>;
|
|
308
|
+
/** Clear error state. */
|
|
309
|
+
clearError: () => void;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
// ============================================================================
|
|
313
|
+
// Internal: Platform Implementation Dependencies
|
|
314
|
+
// ============================================================================
|
|
315
|
+
|
|
316
|
+
export interface LiveActivityDeps {
|
|
317
|
+
checkAvailability: () => Promise<{ supported: boolean; enabled: boolean }>;
|
|
318
|
+
start: (
|
|
319
|
+
templateType: string,
|
|
320
|
+
attributesJson: string,
|
|
321
|
+
contentStateJson: string,
|
|
322
|
+
optionsJson: string,
|
|
323
|
+
) => Promise<string>;
|
|
324
|
+
update: (
|
|
325
|
+
activityId: string,
|
|
326
|
+
contentStateJson: string,
|
|
327
|
+
alertConfigJson: string | null,
|
|
328
|
+
) => Promise<void>;
|
|
329
|
+
end: (
|
|
330
|
+
activityId: string,
|
|
331
|
+
finalContentStateJson: string | null,
|
|
332
|
+
dismissalPolicy: string,
|
|
333
|
+
dismissAfter: number | null,
|
|
334
|
+
) => Promise<void>;
|
|
335
|
+
endAll: (
|
|
336
|
+
dismissalPolicy: string,
|
|
337
|
+
dismissAfter: number | null,
|
|
338
|
+
) => Promise<void>;
|
|
339
|
+
getActivity: (activityId: string) => Promise<string | null>;
|
|
340
|
+
listActivities: () => Promise<string>;
|
|
341
|
+
getPushToken: (activityId: string) => Promise<string | null>;
|
|
342
|
+
addEventListener: (handler: LiveActivityEventHandler) => () => void;
|
|
343
|
+
}
|