tauri-plugin-live-activity 0.0.0-stage → 0.1.0-alpha.3
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/LICENSE +8 -0
- package/LICENSE-APACHE +201 -0
- package/LICENSE-MIT +21 -0
- package/README.ko.md +110 -0
- package/README.md +138 -2
- package/dist-js/index.d.ts +16 -0
- package/dist-js/index.js +29 -0
- package/dist-js/types.d.ts +106 -0
- package/dist-js/types.js +1 -0
- package/package.json +46 -4
package/LICENSE
ADDED
package/LICENSE-APACHE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/LICENSE-MIT
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 tauri-plugin-live-activity contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.ko.md
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
# tauri-plugin-live-activity
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/tauri-plugin-live-activity)
|
|
4
|
+
[](https://crates.io/crates/tauri-plugin-live-activity)
|
|
5
|
+
[](https://github.com/1eedaegon/tauri-plugin-live-activity/actions/workflows/ci.yml)
|
|
6
|
+
|
|
7
|
+
Tauri 2에서 iOS Live Activity와 Android 진행 알림을 표시하는 커뮤니티 플러그인입니다.
|
|
8
|
+
**초기 알파 버전입니다.** [English](https://github.com/1eedaegon/tauri-plugin-live-activity/blob/main/README.md)
|
|
9
|
+
|
|
10
|
+
| 플랫폼 | 표시 방식 |
|
|
11
|
+
| --- | --- |
|
|
12
|
+
| iOS 16.1+ / iPadOS 17+ | ActivityKit · 잠금 화면 / 지원 기기의 Dynamic Island |
|
|
13
|
+
| Android API 26+ | 진행 알림 · API 36+에서 조건 충족 시 Live Update 승격 |
|
|
14
|
+
| macOS / Windows / Linux | 미구현 |
|
|
15
|
+
|
|
16
|
+
<table>
|
|
17
|
+
<tr><th>Mochi 데모</th><th>iOS Live Activity</th><th>Android Live Update</th></tr>
|
|
18
|
+
<tr>
|
|
19
|
+
<td><img src="https://raw.githubusercontent.com/1eedaegon/tauri-plugin-live-activity/main/docs/images/mochi-demo.png" width="240" alt="고양이 Mochi의 간식 배달을 보여 주는 Tauri 데모 앱"></td>
|
|
20
|
+
<td><img src="https://raw.githubusercontent.com/1eedaegon/tauri-plugin-live-activity/main/docs/images/mochi-ios-live-activity.png" width="240" alt="iPhone 잠금 화면의 Mochi 간식 배달과 낮잠 타이머"></td>
|
|
21
|
+
<td><img src="https://raw.githubusercontent.com/1eedaegon/tauri-plugin-live-activity/main/docs/images/mochi-android-live-activity.png" width="240" alt="Mochi의 간식 배달 진행률을 표시한 Android 알림"></td>
|
|
22
|
+
</tr>
|
|
23
|
+
</table>
|
|
24
|
+
|
|
25
|
+
iOS 27.2 시뮬레이터와 Android API 37 에뮬레이터에서 직접 캡처했습니다.
|
|
26
|
+
예제 앱이 전달한 간식 배달 진행률과 낮잠 시간을 실제 네이티브 UI로 표시한 화면입니다.
|
|
27
|
+
[Dynamic Island 화면](https://raw.githubusercontent.com/1eedaegon/tauri-plugin-live-activity/main/docs/images/mochi-ios-dynamic-island.png)도 확인할 수 있습니다.
|
|
28
|
+
구형 Android에서는 같은 예제가 [일반 진행 알림](https://raw.githubusercontent.com/1eedaegon/tauri-plugin-live-activity/main/docs/images/mochi-android-notification-fallback.png)으로 표시됩니다.
|
|
29
|
+
|
|
30
|
+
## 설치
|
|
31
|
+
|
|
32
|
+
Tauri 2와 Rust 1.90 이상이 필요합니다.
|
|
33
|
+
Android는 API 26 이상과 업데이트된 WebView가 필요하며, 빌드에는 Android SDK 37을 사용합니다.
|
|
34
|
+
기능별 OS 조건과 도구 버전은 [호환성 정책](https://github.com/1eedaegon/tauri-plugin-live-activity/blob/main/docs/compatibility.md)에 정리했습니다.
|
|
35
|
+
|
|
36
|
+
```sh
|
|
37
|
+
npm install tauri-plugin-live-activity@next
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
`src-tauri/Cargo.toml`:
|
|
41
|
+
|
|
42
|
+
```toml
|
|
43
|
+
[dependencies]
|
|
44
|
+
tauri-plugin-live-activity = "=0.1.0-alpha.3"
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Tauri 빌더에 등록합니다.
|
|
48
|
+
|
|
49
|
+
```rust
|
|
50
|
+
tauri::Builder::default()
|
|
51
|
+
.plugin(tauri_plugin_live_activity::init())
|
|
52
|
+
// ...
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
앱 capability의 `permissions`에 추가합니다.
|
|
56
|
+
|
|
57
|
+
```json
|
|
58
|
+
[
|
|
59
|
+
"live-activity:default",
|
|
60
|
+
"live-activity:allow-request-permissions",
|
|
61
|
+
"live-activity:allow-start",
|
|
62
|
+
"live-activity:allow-update",
|
|
63
|
+
"live-activity:allow-end"
|
|
64
|
+
]
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
**iOS는 Widget Extension 설정이 필요합니다.**
|
|
68
|
+
[iOS 설정](https://github.com/1eedaegon/tauri-plugin-live-activity/blob/main/docs/ios-integration.md) ·
|
|
69
|
+
[Android 설정](https://github.com/1eedaegon/tauri-plugin-live-activity/blob/main/docs/android-integration.md)
|
|
70
|
+
|
|
71
|
+
## 사용 예시
|
|
72
|
+
|
|
73
|
+
```ts
|
|
74
|
+
import { start, update, end } from 'tauri-plugin-live-activity';
|
|
75
|
+
|
|
76
|
+
// 먼저 Android 알림 권한 또는 iOS Live Activity 설정을 확인합니다.
|
|
77
|
+
const snack = await start({
|
|
78
|
+
activityKey: 'mochi:snack',
|
|
79
|
+
schemaVersion: 1,
|
|
80
|
+
template: 'progress',
|
|
81
|
+
fallback: 'notification',
|
|
82
|
+
snapshot: {
|
|
83
|
+
revision: 0, title: 'Mochi의 간식 배달', status: '작은 간식을 포장하는 중', progress: 0.15,
|
|
84
|
+
},
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
await update({
|
|
88
|
+
id: snack.id,
|
|
89
|
+
snapshot: {
|
|
90
|
+
revision: 1, title: 'Mochi의 간식 배달', status: 'Mochi에게 가는 중', progress: 0.65,
|
|
91
|
+
},
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
await end({ id: snack.id, policy: { kind: 'immediate' } });
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
갱신할 때는 `revision`을 늘리고 전체 snapshot을 보냅니다.
|
|
98
|
+
재실행 후에는 `list()`로 상태를 다시 조회합니다. 타이머는 `template: 'timer'`와
|
|
99
|
+
`timer: { startedAt, endsAt }`을 사용하며, 시각 단위는 Unix 밀리초입니다.
|
|
100
|
+
|
|
101
|
+
플러그인은 상태를 표시합니다. 실제 작업과 백그라운드 실행은 호스트 앱이 담당합니다.
|
|
102
|
+
알림 표시와 승격 여부는 OS 설정에 따라 달라집니다.
|
|
103
|
+
|
|
104
|
+
[실행 가능한 예제](https://github.com/1eedaegon/tauri-plugin-live-activity/tree/main/examples/demo) ·
|
|
105
|
+
[검증 결과](https://github.com/1eedaegon/tauri-plugin-live-activity/blob/main/docs/validation.md) ·
|
|
106
|
+
[OS별 지원 범위](https://github.com/1eedaegon/tauri-plugin-live-activity/blob/main/docs/platform-coverage.md)
|
|
107
|
+
|
|
108
|
+
## 라이선스
|
|
109
|
+
|
|
110
|
+
[MIT](LICENSE-MIT) 또는 [Apache-2.0](LICENSE-APACHE).
|
package/README.md
CHANGED
|
@@ -1,3 +1,139 @@
|
|
|
1
|
-
#
|
|
1
|
+
# tauri-plugin-live-activity
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/tauri-plugin-live-activity)
|
|
4
|
+
[](https://crates.io/crates/tauri-plugin-live-activity)
|
|
5
|
+
[](https://github.com/1eedaegon/tauri-plugin-live-activity/actions/workflows/ci.yml)
|
|
6
|
+
[](LICENSE)
|
|
7
|
+
|
|
8
|
+
Live Activities on iPhone and iPad, and ongoing notifications on Android, for Tauri 2.
|
|
9
|
+
Community plugin. **Early alpha.** [한국어](https://github.com/1eedaegon/tauri-plugin-live-activity/blob/main/README.ko.md)
|
|
10
|
+
|
|
11
|
+
| Platform | Backend |
|
|
12
|
+
| --- | --- |
|
|
13
|
+
| iOS 16.1+ / iPadOS 17+ | ActivityKit · Lock Screen and Dynamic Island where available |
|
|
14
|
+
| Android API 26+ | Ongoing notifications · Live Update promotion on eligible API 36+ devices |
|
|
15
|
+
| macOS / Windows / Linux | Not implemented |
|
|
16
|
+
|
|
17
|
+
<table>
|
|
18
|
+
<tr><th>Mochi demo</th><th>iOS Live Activities</th><th>Android Live Update</th></tr>
|
|
19
|
+
<tr>
|
|
20
|
+
<td><img src="https://raw.githubusercontent.com/1eedaegon/tauri-plugin-live-activity/main/docs/images/mochi-demo.png" width="240" alt="Mochi's snack delivery in the Tauri demo app"></td>
|
|
21
|
+
<td><img src="https://raw.githubusercontent.com/1eedaegon/tauri-plugin-live-activity/main/docs/images/mochi-ios-live-activity.png" width="240" alt="Mochi's snack delivery and nap timer on the iPhone Lock Screen"></td>
|
|
22
|
+
<td><img src="https://raw.githubusercontent.com/1eedaegon/tauri-plugin-live-activity/main/docs/images/mochi-android-live-activity.png" width="240" alt="Mochi's snack delivery shown by Android's native notification UI"></td>
|
|
23
|
+
</tr>
|
|
24
|
+
</table>
|
|
25
|
+
|
|
26
|
+
Actual captures from iOS 27.2 Simulator and an Android API 37 emulator.
|
|
27
|
+
The demo follows a cat's snack delivery and nap timer, using state supplied by the app.
|
|
28
|
+
The iOS demo also includes an [expanded Dynamic Island view](https://raw.githubusercontent.com/1eedaegon/tauri-plugin-live-activity/main/docs/images/mochi-ios-dynamic-island.png).
|
|
29
|
+
On older Android versions, the same example uses an
|
|
30
|
+
[ongoing notification](https://raw.githubusercontent.com/1eedaegon/tauri-plugin-live-activity/main/docs/images/mochi-android-notification-fallback.png).
|
|
31
|
+
|
|
32
|
+
## Install
|
|
33
|
+
|
|
34
|
+
Requires Tauri 2 and Rust 1.90+.
|
|
35
|
+
Android requires API 26+, an updated WebView, and Android SDK 37 to build.
|
|
36
|
+
See the [version policy](https://github.com/1eedaegon/tauri-plugin-live-activity/blob/main/docs/compatibility.md) for feature and toolchain requirements.
|
|
37
|
+
|
|
38
|
+
```sh
|
|
39
|
+
npm install tauri-plugin-live-activity@next
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
`src-tauri/Cargo.toml`:
|
|
43
|
+
|
|
44
|
+
```toml
|
|
45
|
+
[dependencies]
|
|
46
|
+
tauri-plugin-live-activity = "=0.1.0-alpha.3"
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Register the plugin in `src-tauri/src/lib.rs`:
|
|
50
|
+
|
|
51
|
+
```rust
|
|
52
|
+
tauri::Builder::default()
|
|
53
|
+
.plugin(tauri_plugin_live_activity::init())
|
|
54
|
+
// ...
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Add these permissions to your capability file:
|
|
58
|
+
|
|
59
|
+
```json
|
|
60
|
+
"permissions": [
|
|
61
|
+
"live-activity:default",
|
|
62
|
+
"live-activity:allow-request-permissions",
|
|
63
|
+
"live-activity:allow-start",
|
|
64
|
+
"live-activity:allow-update",
|
|
65
|
+
"live-activity:allow-end"
|
|
66
|
+
]
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
**iOS needs a Widget Extension.** Follow the [iOS setup](https://github.com/1eedaegon/tauri-plugin-live-activity/blob/main/docs/ios-integration.md).
|
|
70
|
+
For Android permission and channel behavior, see [Android setup](https://github.com/1eedaegon/tauri-plugin-live-activity/blob/main/docs/android-integration.md).
|
|
71
|
+
|
|
72
|
+
## Example: snacks for Mochi
|
|
73
|
+
|
|
74
|
+
```ts
|
|
75
|
+
import {
|
|
76
|
+
getCapabilities, requestPermissions, start, update, end,
|
|
77
|
+
} from 'tauri-plugin-live-activity';
|
|
78
|
+
|
|
79
|
+
const { platform } = await getCapabilities();
|
|
80
|
+
await requestPermissions(platform === 'android' ? 'notifications' : 'liveActivities');
|
|
81
|
+
|
|
82
|
+
const snack = await start({
|
|
83
|
+
activityKey: 'mochi:snack',
|
|
84
|
+
schemaVersion: 1,
|
|
85
|
+
template: 'progress',
|
|
86
|
+
fallback: 'notification',
|
|
87
|
+
snapshot: {
|
|
88
|
+
revision: 0,
|
|
89
|
+
title: 'Mochi’s snack delivery',
|
|
90
|
+
status: 'Packing a tiny treat',
|
|
91
|
+
progress: 0.15,
|
|
92
|
+
},
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
await update({
|
|
96
|
+
id: snack.id,
|
|
97
|
+
snapshot: {
|
|
98
|
+
revision: 1,
|
|
99
|
+
title: 'Mochi’s snack delivery',
|
|
100
|
+
status: 'On the way to Mochi',
|
|
101
|
+
progress: 0.65,
|
|
102
|
+
},
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
// When the snacks arrive:
|
|
106
|
+
await end({ id: snack.id, policy: { kind: 'immediate' } });
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
Use increasing revisions and send a complete snapshot on each update. `list()`
|
|
110
|
+
reconciles activities after an app restart. A timer uses `template: 'timer'` and
|
|
111
|
+
`timer: { startedAt, endsAt }` instead of `progress`; times are Unix milliseconds.
|
|
112
|
+
|
|
113
|
+
The plugin displays state. Your app still owns the underlying task, background execution,
|
|
114
|
+
and update frequency. OS permissions, Focus settings and promotion policy control
|
|
115
|
+
where it appears. `fallback: 'none'` rejects an unavailable native backend; it cannot
|
|
116
|
+
force Android to promote a notification.
|
|
117
|
+
|
|
118
|
+
## Try it locally
|
|
119
|
+
|
|
120
|
+
The [demo](https://github.com/1eedaegon/tauri-plugin-live-activity/tree/main/examples/demo)
|
|
121
|
+
includes snack delivery, a nap timer and lifecycle checks through the real Tauri bridge.
|
|
122
|
+
|
|
123
|
+
```sh
|
|
124
|
+
npm ci
|
|
125
|
+
npm test
|
|
126
|
+
npm run build:demo
|
|
127
|
+
# With the mobile toolchain configured:
|
|
128
|
+
cd examples/demo
|
|
129
|
+
npm run tauri -- android dev
|
|
130
|
+
# or: npm run tauri -- ios dev
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
See [validation results](https://github.com/1eedaegon/tauri-plugin-live-activity/blob/main/docs/validation.md)
|
|
134
|
+
and [OS coverage](https://github.com/1eedaegon/tauri-plugin-live-activity/blob/main/docs/platform-coverage.md)
|
|
135
|
+
for tested versions and remaining device checks.
|
|
136
|
+
|
|
137
|
+
## License
|
|
138
|
+
|
|
139
|
+
[MIT](LICENSE-MIT) or [Apache-2.0](LICENSE-APACHE).
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ActivityRecord, Capabilities, EndInput, PermissionKind, Permissions, StartInput, UpdateInput } from './types.js';
|
|
2
|
+
export type * from './types.js';
|
|
3
|
+
/** Read backend features; this does not request OS permissions. */
|
|
4
|
+
export declare function getCapabilities(): Promise<Capabilities>;
|
|
5
|
+
/** Read current OS permission states without showing a permission prompt. */
|
|
6
|
+
export declare function checkPermissions(): Promise<Permissions>;
|
|
7
|
+
/** Request an OS permission where supported; settings-only controls report that state. */
|
|
8
|
+
export declare function requestPermissions(kind: PermissionKind): Promise<Permissions>;
|
|
9
|
+
/** Start an activity; repeated identical starts for an active key are idempotent. */
|
|
10
|
+
export declare function start(input: StartInput): Promise<ActivityRecord>;
|
|
11
|
+
/** Replace the entire snapshot with a newer revision. */
|
|
12
|
+
export declare function update(input: UpdateInput): Promise<ActivityRecord>;
|
|
13
|
+
/** End this generation. A late update cannot revive it. */
|
|
14
|
+
export declare function end(input: EndInput): Promise<ActivityRecord>;
|
|
15
|
+
/** Reconcile plugin-owned records with the OS; unknown is a valid observed state. */
|
|
16
|
+
export declare function list(): Promise<readonly ActivityRecord[]>;
|
package/dist-js/index.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { invoke } from '@tauri-apps/api/core';
|
|
2
|
+
/** Read backend features; this does not request OS permissions. */
|
|
3
|
+
export function getCapabilities() {
|
|
4
|
+
return invoke('plugin:live-activity|get_capabilities', {});
|
|
5
|
+
}
|
|
6
|
+
/** Read current OS permission states without showing a permission prompt. */
|
|
7
|
+
export function checkPermissions() {
|
|
8
|
+
return invoke('plugin:live-activity|check_permissions', {});
|
|
9
|
+
}
|
|
10
|
+
/** Request an OS permission where supported; settings-only controls report that state. */
|
|
11
|
+
export function requestPermissions(kind) {
|
|
12
|
+
return invoke('plugin:live-activity|request_permissions', { kind });
|
|
13
|
+
}
|
|
14
|
+
/** Start an activity; repeated identical starts for an active key are idempotent. */
|
|
15
|
+
export function start(input) {
|
|
16
|
+
return invoke('plugin:live-activity|start', { input });
|
|
17
|
+
}
|
|
18
|
+
/** Replace the entire snapshot with a newer revision. */
|
|
19
|
+
export function update(input) {
|
|
20
|
+
return invoke('plugin:live-activity|update', { input });
|
|
21
|
+
}
|
|
22
|
+
/** End this generation. A late update cannot revive it. */
|
|
23
|
+
export function end(input) {
|
|
24
|
+
return invoke('plugin:live-activity|end', { input });
|
|
25
|
+
}
|
|
26
|
+
/** Reconcile plugin-owned records with the OS; unknown is a valid observed state. */
|
|
27
|
+
export function list() {
|
|
28
|
+
return invoke('plugin:live-activity|list', {});
|
|
29
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/** OS capability, independent from the current permission or actual visibility. */
|
|
2
|
+
export type FeatureSupport = 'supported' | 'unsupported' | 'unknown';
|
|
3
|
+
export type Backend = 'activityKit' | 'androidNotification' | 'unsupported';
|
|
4
|
+
export type PermissionState = 'granted' | 'denied' | 'prompt' | 'settingsRequired' | 'notApplicable' | 'unknown';
|
|
5
|
+
export type PermissionKind = 'notifications' | 'liveActivities' | 'promotion';
|
|
6
|
+
export interface Capabilities {
|
|
7
|
+
readonly platform: string;
|
|
8
|
+
readonly backend: Backend;
|
|
9
|
+
readonly start: FeatureSupport;
|
|
10
|
+
readonly update: FeatureSupport;
|
|
11
|
+
readonly end: FeatureSupport;
|
|
12
|
+
readonly progress: FeatureSupport;
|
|
13
|
+
readonly timer: FeatureSupport;
|
|
14
|
+
readonly actions: FeatureSupport;
|
|
15
|
+
readonly stateObservation: FeatureSupport;
|
|
16
|
+
readonly silentUpdate: FeatureSupport;
|
|
17
|
+
readonly nativeLiveActivity: FeatureSupport;
|
|
18
|
+
readonly maxPayloadBytes: number;
|
|
19
|
+
}
|
|
20
|
+
export interface Permissions {
|
|
21
|
+
readonly notifications: PermissionState;
|
|
22
|
+
readonly liveActivities: PermissionState;
|
|
23
|
+
readonly promotion: PermissionState;
|
|
24
|
+
}
|
|
25
|
+
interface SnapshotFields {
|
|
26
|
+
/** Nonnegative JavaScript safe integer; strictly increases when content changes. */
|
|
27
|
+
readonly revision: number;
|
|
28
|
+
/** Between 1 and 120 Unicode code points, excluding whitespace-only text. */
|
|
29
|
+
readonly title: string;
|
|
30
|
+
/** Between 1 and 240 Unicode code points, excluding whitespace-only text. */
|
|
31
|
+
readonly status: string;
|
|
32
|
+
/** UTC Unix epoch milliseconds. */
|
|
33
|
+
readonly staleAt?: number;
|
|
34
|
+
}
|
|
35
|
+
export interface Timer {
|
|
36
|
+
/** UTC Unix epoch milliseconds. */
|
|
37
|
+
readonly startedAt: number;
|
|
38
|
+
/** UTC Unix epoch milliseconds, strictly greater than startedAt. */
|
|
39
|
+
readonly endsAt: number;
|
|
40
|
+
}
|
|
41
|
+
export interface ProgressSnapshot extends SnapshotFields {
|
|
42
|
+
/** Finite normalized progress from 0 to 1 inclusive. */
|
|
43
|
+
readonly progress: number;
|
|
44
|
+
readonly timer?: never;
|
|
45
|
+
}
|
|
46
|
+
export interface TimerSnapshot extends SnapshotFields {
|
|
47
|
+
readonly timer: Timer;
|
|
48
|
+
readonly progress?: never;
|
|
49
|
+
}
|
|
50
|
+
export type Snapshot = ProgressSnapshot | TimerSnapshot;
|
|
51
|
+
export type Fallback = 'none' | 'notification';
|
|
52
|
+
interface StartFields {
|
|
53
|
+
/** Stable app-owned key; do not put credentials or private data in this key. */
|
|
54
|
+
readonly activityKey: string;
|
|
55
|
+
readonly schemaVersion: 1;
|
|
56
|
+
/** Explicitly permits or forbids selection of the notification fallback. */
|
|
57
|
+
readonly fallback: Fallback;
|
|
58
|
+
}
|
|
59
|
+
export type StartInput = StartFields & ({
|
|
60
|
+
readonly template: 'progress';
|
|
61
|
+
readonly snapshot: ProgressSnapshot;
|
|
62
|
+
} | {
|
|
63
|
+
readonly template: 'timer';
|
|
64
|
+
readonly snapshot: TimerSnapshot;
|
|
65
|
+
});
|
|
66
|
+
export interface UpdateInput {
|
|
67
|
+
readonly id: string;
|
|
68
|
+
/** Complete replacement snapshot, not a partial update. */
|
|
69
|
+
readonly snapshot: Snapshot;
|
|
70
|
+
}
|
|
71
|
+
export type EndPolicy = {
|
|
72
|
+
readonly kind: 'immediate' | 'default';
|
|
73
|
+
} | {
|
|
74
|
+
readonly kind: 'after';
|
|
75
|
+
readonly at: number;
|
|
76
|
+
};
|
|
77
|
+
export interface EndInput {
|
|
78
|
+
readonly id: string;
|
|
79
|
+
/** Unsupported policies fail explicitly instead of being silently ignored. */
|
|
80
|
+
readonly policy: EndPolicy;
|
|
81
|
+
}
|
|
82
|
+
export type ActivityState = 'active' | 'stale' | 'ended' | 'dismissed' | 'unknown';
|
|
83
|
+
export type PromotionState = 'promoted' | 'notPromoted' | 'unknown' | 'notApplicable';
|
|
84
|
+
export interface ActivityRecord {
|
|
85
|
+
/** Opaque handle for this generation; a later start receives a new handle. */
|
|
86
|
+
readonly id: string;
|
|
87
|
+
readonly activityKey: string;
|
|
88
|
+
readonly schemaVersion: 1;
|
|
89
|
+
readonly template: 'progress' | 'timer';
|
|
90
|
+
readonly snapshot: Snapshot;
|
|
91
|
+
readonly backend: Backend;
|
|
92
|
+
/** Backend lifecycle state, not proof of visible UI. iOS stale transitions depend on ActivityKit observation; Android also uses the snapshot deadline. */
|
|
93
|
+
readonly state: ActivityState;
|
|
94
|
+
/** A successful OS call does not prove that the user can see the activity. */
|
|
95
|
+
readonly visibility: 'unknown';
|
|
96
|
+
readonly degradedFeatures: readonly string[];
|
|
97
|
+
readonly promotionRequested: boolean;
|
|
98
|
+
readonly promotionState: PromotionState;
|
|
99
|
+
}
|
|
100
|
+
export type ErrorCode = 'UNSUPPORTED_PLATFORM' | 'UNSUPPORTED_FEATURE' | 'PERMISSION_DENIED' | 'CONFIGURATION_REQUIRED' | 'INVALID_INPUT' | 'PAYLOAD_TOO_LARGE' | 'NOT_FOUND' | 'STALE_REVISION' | 'CONFLICT' | 'SYSTEM_LIMIT' | 'NATIVE_ERROR';
|
|
101
|
+
/** Native plugin rejections are structured objects, not JavaScript Error instances. */
|
|
102
|
+
export interface LiveActivityError {
|
|
103
|
+
readonly code: ErrorCode;
|
|
104
|
+
readonly message: string;
|
|
105
|
+
}
|
|
106
|
+
export {};
|
package/dist-js/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,48 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tauri-plugin-live-activity",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0-alpha.3",
|
|
4
|
+
"description": "Typed Tauri v2 API for iOS Live Activities and Android ongoing activity notifications",
|
|
5
|
+
"author": "1eedaegon",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"license": "Apache-2.0 OR MIT",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/1eedaegon/tauri-plugin-live-activity.git"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://github.com/1eedaegon/tauri-plugin-live-activity#readme",
|
|
13
|
+
"bugs": "https://github.com/1eedaegon/tauri-plugin-live-activity/issues",
|
|
14
|
+
"keywords": ["tauri", "plugin", "live-activity", "activitykit", "android"],
|
|
15
|
+
"sideEffects": false,
|
|
16
|
+
"types": "./dist-js/index.d.ts",
|
|
17
|
+
"main": "./dist-js/index.js",
|
|
18
|
+
"exports": {
|
|
19
|
+
".": { "types": "./dist-js/index.d.ts", "import": "./dist-js/index.js" },
|
|
20
|
+
"./package.json": "./package.json"
|
|
21
|
+
},
|
|
22
|
+
"files": ["dist-js", "README.md", "README.ko.md", "LICENSE", "LICENSE-APACHE", "LICENSE-MIT"],
|
|
23
|
+
"publishConfig": { "access": "public", "tag": "next" },
|
|
24
|
+
"engines": {
|
|
25
|
+
"node": ">=22.12.0"
|
|
26
|
+
},
|
|
27
|
+
"scripts": {
|
|
28
|
+
"build": "tsc -p tsconfig.json",
|
|
29
|
+
"typecheck": "tsc -p tsconfig.json --noEmit && tsc -p examples/demo/tsconfig.json",
|
|
30
|
+
"test": "npm run build && npm run test:contracts && npm run test:api && npm run test:demo",
|
|
31
|
+
"test:contracts": "node --test --experimental-test-coverage \"--test-coverage-include=tools/validate-request.mjs\" --test-coverage-lines=80 --test-coverage-branches=80 --test-coverage-functions=80 tests/requests.test.mjs",
|
|
32
|
+
"test:api": "node --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.mjs",
|
|
33
|
+
"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.mjs examples/demo/tests/ui-state.test.mjs",
|
|
34
|
+
"build:demo": "npm run build && node examples/demo/build.mjs",
|
|
35
|
+
"prepack": "npm run build",
|
|
36
|
+
"pack:check": "npm pack --dry-run"
|
|
37
|
+
},
|
|
38
|
+
"peerDependencies": {
|
|
39
|
+
"@tauri-apps/api": "^2.12.4"
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"@tauri-apps/cli": "2.12.4",
|
|
43
|
+
"@tauri-apps/api": "2.12.4",
|
|
44
|
+
"ajv": "8.20.0",
|
|
45
|
+
"esbuild": "0.28.2",
|
|
46
|
+
"typescript": "7.0.2"
|
|
47
|
+
}
|
|
48
|
+
}
|