react-native-live-widgets 1.0.0 → 1.1.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/CHANGELOG.md CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
  All notable changes to `react-native-live-widgets` will be documented in this file.
4
4
 
5
+ ## [1.1.0] - 2026-11-16
6
+ ### Added
7
+ - **Expo Config Plugin (`app.plugin.js`)**: Full Expo & EAS Build support (`npx expo prebuild` / `npx expo run:ios` / `npx expo run:android`). Automatically configures `NSSupportsLiveActivities` and `NSSupportsLiveActivitiesFrequentUpdates` in iOS `Info.plist`, App Groups entitlements, and Android notifications & foreground service permissions.
8
+
9
+ ### Fixed
10
+ - **TypeScript Module Resolution**: Fixed `error TS7016` when resolving React Native package exports by updating to `moduleResolution: bundler` and `module: ES2020`.
11
+ - **Global `__DEV__` Declaration**: Fixed `error TS2304: Cannot find name '__DEV__'` with safe typing and fallback checks.
12
+
5
13
  ## [1.0.0] - 2026-11-15
6
14
  ### Added
7
15
  - **Declarative UI Engine (`UI.*`)**: Build Home Screen Widgets (`small`, `medium`, `large`) and Live Activities (`lockScreen`, `dynamicIsland`) 100% in React Native using `UI.VStack`, `UI.HStack`, `UI.Text`, `UI.Timer`, `UI.Progress` (`bar`, `segmented`, `circular`), `UI.Image`, and `UI.Button`.
package/README.md CHANGED
@@ -2,27 +2,84 @@
2
2
 
3
3
  <div align="center">
4
4
 
5
- [![npm version](https://img.shields.io/badge/npm-v1.0.0-blue.svg?style=for-the-badge&logo=npm)](https://www.npmjs.com/package/react-native-live-widgets)
5
+ [![npm version](https://img.shields.io/npm/v/react-native-live-widgets.svg?style=for-the-badge&logo=npm&color=CB3837)](https://www.npmjs.com/package/react-native-live-widgets)
6
+ [![Expo Ready](https://img.shields.io/badge/Expo-Config%20Plugin-000020.svg?style=for-the-badge&logo=expo)](https://expo.dev)
6
7
  [![Platforms](https://img.shields.io/badge/Platforms-iOS%2016.1+%20|%20Android%2016-orange.svg?style=for-the-badge)](https://github.com/React-Native-Vu/react-native-live-widgets)
7
8
  [![TypeScript](https://img.shields.io/badge/TypeScript-100%25-3178C6.svg?style=for-the-badge&logo=typescript)](https://www.typescriptlang.org/)
8
9
  [![License](https://img.shields.io/badge/License-MIT-green.svg?style=for-the-badge)](LICENSE)
9
10
 
10
- **The Ultimate All-in-One Engine for Live Activities, Dynamic Island, and Interactive Home Screen Widgets in Bare React Native.**
11
+ **The Ultimate All-in-One Engine for Live Activities, Dynamic Island, and Interactive Home Screen Widgets in React Native & Expo.**
11
12
 
12
- *Write 100% Declarative TypeScript. Render dynamically to Native SwiftUI & Android 2D Canvas without touching Xcode or Android Studio.*
13
+ *Write 100% Declarative TypeScript. Render dynamically to Native SwiftUI (WidgetKit) & Android 2D Canvas without touching Xcode or Android Studio.*
13
14
 
14
- [📖 English Guide](docs/GUIDE-EN.md) • [🇻🇳 Hướng dẫn Tiếng Việt](docs/GUIDE-VI.md) • [✨ Features](#-key-features) • [⚡ Quick Start](#-quick-start)
15
+ [📖 English Guide](docs/GUIDE-EN.md) • [🇻🇳 Hướng dẫn Tiếng Việt](docs/GUIDE-VI.md) • [⚡ Expo Guide](docs/EXPO-GUIDE-VI.md) • [📱 Bare RN Demo](https://github.com/React-Native-Vu/LiveWidgetsExample) • [⚡ Expo Demo](https://github.com/React-Native-Vu/LiveWidgetsExampleExpo) • [✨ Tính năng](#-key-features) • [⚡ Cài đặt](#-quick-start) • [☕ Ủng hộ tác giả](#-sponsor--donate-ủng-hộ-tác-giả)
15
16
 
16
17
  ---
17
18
 
18
19
  </div>
19
20
 
21
+ ## 📱 Live Demo Example Apps
22
+
23
+ Full, ready-to-run demo applications are available on GitHub for both architectures:
24
+
25
+ | Platform | Repository | Description |
26
+ | :--- | :--- | :--- |
27
+ | **⚛️ Bare React Native CLI** | 👉 **[React-Native-Vu/LiveWidgetsExample](https://github.com/React-Native-Vu/LiveWidgetsExample)** | Full Xcode Widget Extension & Android Studio setup |
28
+ | **🚀 Expo (SDK 58 / CNG)** | 👉 **[React-Native-Vu/LiveWidgetsExampleExpo](https://github.com/React-Native-Vu/LiveWidgetsExampleExpo)** | Continuous Native Generation via Expo Config Plugin |
29
+
30
+ ### ✨ Highlights of Both Demos:
31
+ - 🚀 **100% Pre-configured**: Xcode App Groups, `WidgetExtension`, and Android `AppWidgetProvider` ready out of the box.
32
+ - 🎨 **5 Real-world Presets**:
33
+ 1. **Executive KPI Dashboard**: Live sales sync, circular progress ring, and weekly chart.
34
+ 2. **Coffee Delivery Tracker**: Dynamic Island countdown and delivery driver status.
35
+ 3. **Interactive Task Checklist**: Check off items right from your Home Screen without opening the app.
36
+ 4. **Music & Audio Player**: Dynamic Island equalizer animation and lock screen media style.
37
+ 5. **Flight Status**: Real-time gate, departure time, and airport progress bar.
38
+ - 🔄 **Bidirectional Real-Time Sync**: Instant state updates between Main App and WidgetKit.
39
+
40
+ #### 1. Clone & Run Bare React Native Demo:
41
+ ```bash
42
+ git clone https://github.com/React-Native-Vu/LiveWidgetsExample.git
43
+ cd LiveWidgetsExample && npm install
44
+ npx react-native run-ios # or npx react-native run-android
45
+ ```
46
+
47
+ #### 2. Clone & Run Expo Demo:
48
+ ```bash
49
+ git clone https://github.com/React-Native-Vu/LiveWidgetsExampleExpo.git
50
+ cd LiveWidgetsExampleExpo && npm install
51
+ npx expo prebuild
52
+ npx expo run:ios # or npx expo run:android
53
+ ```
54
+
55
+ ---
56
+
20
57
  ## 📸 Showcase & Demos
21
58
 
22
- | Dynamic Island (Expanded) | Interactive Home Screen Widget | Lock Screen Live Activity |
23
- |:-------------------------:|:------------------------------:|:-------------------------:|
24
- | <img src="assets/dynamic_island_expanded.png" width="260" alt="Dynamic Island Expanded" /> | <img src="assets/home_widget_interactive.png" width="260" alt="Interactive Widget" /> | <img src="assets/lock_screen_live_activity.png" width="260" alt="Lock Screen Live Activity" /> |
25
- | *Segmented Progress & Realtime Timer* | *Buttons & Bi-directional State Sync* | *Multi-card KPI & Status Dashboard* |
59
+ <div align="center">
60
+ <table>
61
+ <tr>
62
+ <td width="50%" align="center">
63
+ <b>🏝️ Dynamic Island Expanded & KPI Dashboard</b><br/><br/>
64
+ <img src="assets/dynamic_island_expanded.png" alt="Dynamic Island Expanded" width="380" />
65
+ </td>
66
+ <td width="50%" align="center">
67
+ <b>📱 Interactive Home Screen Widget (iOS)</b><br/><br/>
68
+ <img src="assets/home_widget_interactive.png" alt="Home Screen Widget Interactive" width="380" />
69
+ </td>
70
+ </tr>
71
+ <tr>
72
+ <td width="50%" align="center">
73
+ <b>🔒 Lock Screen Live Activity & Gauges</b><br/><br/>
74
+ <img src="assets/lock_screen_live_activity.png" alt="Lock Screen Live Activity" width="380" />
75
+ </td>
76
+ <td width="50%" align="center">
77
+ <b>🤖 100% Feature Parity (Android & iOS)</b><br/><br/>
78
+ <img src="assets/cross_platform_parity.png" alt="Cross Platform Parity" width="380" />
79
+ </td>
80
+ </tr>
81
+ </table>
82
+ </div>
26
83
 
27
84
  ---
28
85
 
@@ -32,7 +89,8 @@ Until now, adding **Live Activities** or **Home Screen Widgets** to a React Nati
32
89
 
33
90
  `react-native-live-widgets` solves this with a **Declarative TypeScript UI DSL**:
34
91
  - 🚫 **No SwiftUI / Kotlin coding required** for custom screens.
35
- - 🎨 **100% Declarative UI in React Native (`UI.VStack`, `UI.HStack`, `UI.Text`, `UI.Button`, `UI.Progress`)**.
92
+ - 🎨 **100% Declarative UI in React Native (`UI.VStack`, `UI.HStack`, `UI.Text`, `UI.Button`, `UI.Progress`, `UI.Image`)**.
93
+ - 🚀 **Full Expo & EAS Build Support** via automated Expo Config Plugin (`app.plugin.js`).
36
94
  - ⚡ **Interactive Buttons**: Tap buttons on the Home Screen Widget to run native Swift extensions or wake up TypeScript handlers.
37
95
  - 🔄 **Realtime Data Sync (`SharedStorage`)**: Single source of truth across Main App, Lock Screen, and Home Screen.
38
96
  - 🌐 **Silent Background Remote API Sync**: Automatically fetch REST APIs and update Widgets even when the App is **Force-Killed**.
@@ -56,8 +114,9 @@ Until now, adding **Live Activities** or **Home Screen Widgets** to a React Nati
56
114
  ### 3. ⚡ Bi-directional Action Dispatcher (TypeScript + Native)
57
115
  - Tap a widget button outside on the Home Screen to trigger a registered TypeScript function:
58
116
  ```ts
59
- LiveActivity.registerAction('action_checkin', async () => {
117
+ LiveActivity.registerAction('action_checkin', async (payload) => {
60
118
  // Runs inside React Native JS engine!
119
+ console.log('Action triggered from Home Screen Widget:', payload);
61
120
  });
62
121
  ```
63
122
  - **App-Killed Protection**: Native fallback ensures UI responds instantly and persists data even if the main app is terminated.
@@ -82,9 +141,6 @@ Until now, adding **Live Activities** or **Home Screen Widgets** to a React Nati
82
141
  // tokens.activityUpdateToken
83
142
  ```
84
143
 
85
- ### 6. 🎵 Background Audio & Media Notification
86
- - Integrated with `MPNowPlayingInfoCenter` on iOS and `MediaStyle` Notifications on Android for audio playback status.
87
-
88
144
  ---
89
145
 
90
146
  ## ⚡ Quick Start
@@ -92,12 +148,56 @@ Until now, adding **Live Activities** or **Home Screen Widgets** to a React Nati
92
148
  ### 1. Installation
93
149
 
94
150
  ```bash
151
+ # React Native CLI
95
152
  npm install react-native-live-widgets
96
- # or
97
- yarn add react-native-live-widgets
153
+
154
+ # Expo (Managed or Bare)
155
+ npx expo install react-native-live-widgets
98
156
  ```
99
157
 
100
- ### 2. Auto-Configuration CLI
158
+ ---
159
+
160
+ ### 2. Configuration
161
+
162
+ #### A. If using Expo (Config Plugin)
163
+
164
+ Add `react-native-live-widgets` to your `app.json` or `app.config.js`:
165
+
166
+ ```json
167
+ {
168
+ "expo": {
169
+ "name": "My Expo App",
170
+ "plugins": [
171
+ [
172
+ "react-native-live-widgets",
173
+ {
174
+ "appGroup": "group.com.yourcompany.app",
175
+ "enableLiveActivities": true,
176
+ "frequentUpdates": true
177
+ }
178
+ ]
179
+ ]
180
+ }
181
+ }
182
+ ```
183
+
184
+ Then generate native projects or run with Expo Dev Client:
185
+
186
+ ```bash
187
+ # 1. Generate native folders
188
+ npx expo prebuild
189
+
190
+ # 2. Automatically scaffold & link Xcode Widget Extension target
191
+ npx react-native-live-widgets init --group group.com.yourcompany.app
192
+
193
+ # 3. Run on iOS Simulator & Android Emulator:
194
+ npx expo run:ios
195
+ npx expo run:android
196
+ ```
197
+
198
+ > 📖 **Detailed Step-by-Step Expo Guide**: [English](docs/EXPO-GUIDE-EN.md) • [Tiếng Việt](docs/EXPO-GUIDE-VI.md)
199
+
200
+ #### B. If using Bare React Native CLI
101
201
 
102
202
  Run the automated scaffolding script in your React Native project root:
103
203
 
@@ -110,7 +210,7 @@ This will automatically:
110
210
  - Scaffold the `LiveWidgetsExtension` bundle in your `ios/` folder.
111
211
  - Configure `AndroidManifest.xml` with required notification permissions.
112
212
 
113
- ### 3. Install Pods
213
+ And install CocoaPods dependencies:
114
214
 
115
215
  ```bash
116
216
  cd ios && pod install
@@ -126,51 +226,79 @@ cd ios && pod install
126
226
  import { UI, LiveActivity } from 'react-native-live-widgets';
127
227
 
128
228
  await LiveActivity.start({
129
- activityId: 'order_1024',
229
+ activityId: 'kpi_q4_2026',
130
230
  dynamicIsland: {
131
- compactLeading: UI.Image({ systemName: 'bag.fill', tintColor: '#10B981' }),
132
- compactTrailing: UI.Text('15 phút', { color: '#10B981', fontWeight: 'bold' }),
133
- minimal: UI.Image({ systemName: 'bag.fill', tintColor: '#10B981' }),
231
+ compactLeading: UI.Text('KPI Q4', { color: '#38BDF8', fontWeight: 'bold' }),
232
+ compactTrailing: UI.Text('86%', { color: '#10B981', fontWeight: 'bold' }),
233
+ minimal: UI.Text('86%', { color: '#10B981' }),
134
234
  expanded: UI.VStack(
135
- { padding: 14, spacing: 8 },
235
+ { padding: 14, spacing: 8, backgroundColor: '#0F172A' },
136
236
  UI.HStack(
137
237
  { justifyContent: 'spaceBetween' },
138
- UI.Text('ĐƠN HÀNG #1024', { fontSize: 11, color: '#94A3B8' }),
139
- UI.Badge({ text: 'Đang giao', backgroundColor: '#064E3B', textColor: '#6EE7B7' })
238
+ UI.Text('BẢNG ĐIỀU HÀNH KPI', { fontSize: 11, color: '#94A3B8' }),
239
+ UI.Badge({ text: '86% Hoàn thành', backgroundColor: '#064E3B', textColor: '#6EE7B7' })
140
240
  ),
141
- UI.Text('Tài xế đang đến điểm giao', { fontSize: 15, fontWeight: 'bold', color: '#FFFFFF' }),
241
+ UI.Text('Mục tiêu Q4/2026', { fontSize: 16, fontWeight: 'bold', color: '#FFFFFF' }),
142
242
  UI.Progress({
143
243
  style: 'bar',
144
- value: 0.75,
244
+ value: 0.86,
145
245
  tintColor: '#10B981',
146
246
  trackColor: '#334155'
147
- })
247
+ }),
248
+ UI.Text('Doanh số 12.8 tỷ / 15 tỷ VNĐ • Tăng trưởng +22%', { fontSize: 12, color: '#94A3B8' })
148
249
  )
149
250
  },
150
251
  lockScreen: UI.VStack(
151
- { padding: 16, backgroundColor: '#0F172A' },
152
- UI.Text('GIAO HÀNG TIẾT KIỆM', { fontSize: 11, color: '#38BDF8' }),
153
- UI.Text('Dự kiến nhận lúc 11:30', { fontSize: 16, fontWeight: 'bold', color: '#FFFFFF' })
252
+ { padding: 16, backgroundColor: '#0F172A', cornerRadius: 16 },
253
+ UI.HStack(
254
+ { justifyContent: 'spaceBetween' },
255
+ UI.Text('KPI Quý 4: Đạt 86% mục tiêu', { fontSize: 14, fontWeight: 'bold', color: '#FFFFFF' }),
256
+ UI.Badge({ text: '+18%', backgroundColor: '#064E3B', textColor: '#6EE7B7' })
257
+ ),
258
+ UI.Progress({
259
+ style: 'segmented',
260
+ segments: 7,
261
+ currentSegment: 6,
262
+ tintColor: '#38BDF8',
263
+ trackColor: '#1E293B'
264
+ })
154
265
  )
155
266
  });
156
267
  ```
157
268
 
158
- ### 2. Update Home Screen Widgets
269
+ ### 2. Configure Home Screen Widget with Live Sync
159
270
 
160
271
  ```tsx
161
- import { UI, Widget } from 'react-native-live-widgets';
272
+ import { UI, Widget, SharedStorage } from 'react-native-live-widgets';
162
273
 
163
274
  const APP_GROUP = 'group.com.yourcompany.app';
164
275
 
276
+ // Set shared data
277
+ await SharedStorage.set('kpi_percent', '86', APP_GROUP);
278
+ await SharedStorage.set('revenue_month', '4.85 Tỷ đ', APP_GROUP);
279
+
280
+ // Build Declarative Layout
165
281
  await Widget.setLayout('main', {
166
- small: UI.VStack(
167
- { padding: 12, backgroundColor: '#0F172A' },
168
- UI.Text('CA LÀM VIỆC', { fontSize: 10, color: '#94A3B8' }),
169
- UI.Text('Ca sáng', { fontSize: 16, fontWeight: 'bold', color: '#FFFFFF' }),
282
+ large: UI.VStack(
283
+ { padding: 16, backgroundColor: '#0B132B', cornerRadius: 20 },
284
+ UI.HStack(
285
+ { justifyContent: 'spaceBetween' },
286
+ UI.Text('TỔNG QUAN ĐIỀU HÀNH (KPI & BIỂU ĐỒ)', { fontSize: 11, color: '#38BDF8', fontWeight: 'bold' }),
287
+ UI.Badge({ text: 'LIVE SYNC', backgroundColor: '#064E3B', textColor: '#6EE7B7' })
288
+ ),
289
+ UI.HStack(
290
+ { spacing: 12, marginTop: 10 },
291
+ UI.VStack(
292
+ { width: 90, alignItems: 'center' },
293
+ UI.Progress({ style: 'circular', value: 0.86, tintColor: '#38BDF8', trackColor: '#1E293B' }),
294
+ UI.Text('86%', { fontSize: 16, fontWeight: 'bold', color: '#FFFFFF' }),
295
+ UI.Text('KPI Quý', { fontSize: 10, color: '#94A3B8' })
296
+ )
297
+ ),
170
298
  UI.Spacer(),
171
- UI.Button('Chấm công', {
172
- actionId: 'action_checkin',
173
- backgroundColor: '#10B981',
299
+ UI.Button('Duyệt báo cáo doanh thu tuần', {
300
+ actionId: 'action_approve_report',
301
+ backgroundColor: '#1E293B',
174
302
  textColor: '#FFFFFF'
175
303
  })
176
304
  )
@@ -193,11 +321,35 @@ await Widget.reloadAll();
193
321
  | **SharedStorage Data Sync** | App Group UserDefaults | Context SharedPreferences |
194
322
  | **Remote API Silent Sync** | Background Timeline URLSession | WorkManager / Background Fetch |
195
323
  | **Push Remote Updates** | Apple APNs Activity Tokens | Firebase Cloud Messaging (FCM) |
324
+ | **Expo & EAS Build Ready** | ✅ Automated Config Plugin | ✅ Automated Config Plugin |
196
325
 
197
326
  ---
198
327
 
199
- ## 📚 Documentation
328
+ ## ☕ Sponsor & Donate (Ủng hộ tác giả)
329
+
330
+ `react-native-live-widgets` là dự án mã nguồn mở **hoàn toàn miễn phí (100% Free & MIT License)**, được phát triển và duy trì với tâm huyết mang lại giải pháp Live Activities & Widgets tốt nhất cho cộng đồng React Native Việt Nam và quốc tế.
200
331
 
332
+ Nếu thư viện này giúp ích cho dự án hoặc công ty của bạn, bạn có thể **mời tác giả một tách cà phê** để tiếp thêm động lực phát triển thêm nhiều tính năng mới nhé! ☕❤️
333
+
334
+ <div align="center">
335
+
336
+ <img src="assets/donate_qr.png" alt="Donate qua VietQR VPBank" width="300" style="border-radius: 16px; box-shadow: 0 4px 20px rgba(0,0,0,0.15);" />
337
+
338
+ ### 🏦 Thông tin chuyển khoản ủng hộ:
339
+ - **Ngân hàng**: VPBank (Ngân hàng TMCP Việt Nam Thịnh Vượng)
340
+ - **Số tài khoản / Số điện thoại**: `0906472426`
341
+ - **Chủ tài khoản**: `TRAN LE VU`
342
+ - **Nội dung**: `LiveWidgets Support` hoặc lời nhắn của bạn
343
+
344
+ *Chân thành cảm ơn sự đồng hành và ủng hộ quý báu của bạn!* 🙏✨
345
+
346
+ </div>
347
+
348
+ ---
349
+
350
+ ## 📚 Documentation & Guides
351
+
352
+ - 📱 **[LiveWidgetsExample Demo Project](https://github.com/React-Native-Vu/LiveWidgetsExample)**: Complete working sample app demonstrating all 5 presets with bidirectional sync on iOS & Android.
201
353
  - 🇬🇧 **[Full English Developer Guide](docs/GUIDE-EN.md)**: Architecture, DSL specs, push notification server configuration, and best practices.
202
354
  - 🇻🇳 **[Hướng dẫn Chi tiết bằng Tiếng Việt](docs/GUIDE-VI.md)**: Hướng dẫn tích hợp từng bước, thiết lập App Group, giải quyết lỗi thường gặp.
203
355
 
@@ -205,18 +357,12 @@ await Widget.reloadAll();
205
357
 
206
358
  ## 🤝 Contributing
207
359
 
208
- Contributions are welcome! Please feel free to submit a Pull Request or open an Issue.
209
-
210
- 1. Fork the Project.
211
- 2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`).
212
- 3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`).
213
- 4. Push to the Branch (`git push origin feature/AmazingFeature`).
214
- 5. Open a Pull Request.
360
+ Contributions are welcome! Please feel free to submit a Pull Request or open an Issue on [GitHub Repository](https://github.com/React-Native-Vu/react-native-live-widgets).
215
361
 
216
362
  ---
217
363
 
218
364
  ## 📄 License
219
365
 
220
- Distributed under the **MIT License**. See `LICENSE` for more information.
366
+ Distributed under the **MIT License**. See [LICENSE](LICENSE) for more information.
221
367
 
222
- Developed with ❤️ by **vu-tran** for high-performance React Native applications.
368
+ Developed with ❤️ by **vu-tran** for high-performance React Native & Expo applications.
@@ -12,6 +12,7 @@ import com.facebook.react.bridge.Promise
12
12
  import com.facebook.react.bridge.ReactApplicationContext
13
13
  import com.facebook.react.bridge.ReactContextBaseJavaModule
14
14
  import com.facebook.react.bridge.ReactMethod
15
+ import com.facebook.react.bridge.ReadableMap
15
16
  import com.facebook.react.modules.core.DeviceEventManagerModule
16
17
  import org.json.JSONObject
17
18
  import java.util.concurrent.Executors
@@ -121,7 +122,7 @@ class LiveActivityModule(private val reactContext: ReactApplicationContext) :
121
122
  val seconds = if (options?.hasKey("dismissalAfterSeconds") == true) options.getDouble("dismissalAfterSeconds").toLong() else 0L
122
123
 
123
124
  if (finalPayload != null) {
124
- LiveActivityNotifier.showOrUpdate(reactContext, activityId, finalPayload)
125
+ LiveActivityNotifier.update(reactContext, activityId, finalPayload)
125
126
  }
126
127
 
127
128
  if (seconds > 0) {
package/app.plugin.js ADDED
@@ -0,0 +1,114 @@
1
+ const path = require('path');
2
+ const fs = require('fs');
3
+
4
+ /**
5
+ * Expo Config Plugin for react-native-live-widgets
6
+ *
7
+ * Automatically configures:
8
+ * 1. iOS Info.plist: NSSupportsLiveActivities = YES, NSSupportsLiveActivitiesFrequentUpdates = YES
9
+ * 2. iOS Entitlements: com.apple.security.application-groups = [appGroup]
10
+ * 3. Android AndroidManifest.xml: POST_NOTIFICATIONS, FOREGROUND_SERVICE permissions
11
+ */
12
+
13
+ let withLiveWidgets;
14
+
15
+ try {
16
+ const {
17
+ withInfoPlist,
18
+ withEntitlementsPlist,
19
+ withAndroidManifest,
20
+ createRunOncePlugin,
21
+ } = require('@expo/config-plugins');
22
+
23
+ const pkg = require('./package.json');
24
+
25
+ /**
26
+ * Configures iOS Info.plist to enable Live Activities support
27
+ */
28
+ const withLiveWidgetsInfoPlist = (config, options = {}) => {
29
+ return withInfoPlist(config, (plistConfig) => {
30
+ const enableLiveActivities =
31
+ options.enableLiveActivities !== undefined ? options.enableLiveActivities : true;
32
+ const frequentUpdates =
33
+ options.frequentUpdates !== undefined ? options.frequentUpdates : true;
34
+
35
+ plistConfig.modResults.NSSupportsLiveActivities = enableLiveActivities;
36
+ if (frequentUpdates) {
37
+ plistConfig.modResults.NSSupportsLiveActivitiesFrequentUpdates = true;
38
+ }
39
+
40
+ return plistConfig;
41
+ });
42
+ };
43
+
44
+ /**
45
+ * Configures iOS Entitlements for App Groups shared storage
46
+ */
47
+ const withLiveWidgetsEntitlements = (config, options = {}) => {
48
+ return withEntitlementsPlist(config, (entitlementsConfig) => {
49
+ if (options.appGroup) {
50
+ const existingGroups =
51
+ entitlementsConfig.modResults['com.apple.security.application-groups'] || [];
52
+ const groups = Array.isArray(existingGroups) ? [...existingGroups] : [existingGroups];
53
+
54
+ if (!groups.includes(options.appGroup)) {
55
+ groups.push(options.appGroup);
56
+ }
57
+
58
+ entitlementsConfig.modResults['com.apple.security.application-groups'] = groups;
59
+ }
60
+ return entitlementsConfig;
61
+ });
62
+ };
63
+
64
+ /**
65
+ * Configures Android Manifest permissions for Notifications & Background Service
66
+ */
67
+ const withLiveWidgetsAndroidManifest = (config, _options = {}) => {
68
+ return withAndroidManifest(config, (manifestConfig) => {
69
+ const manifest = manifestConfig.modResults.manifest;
70
+
71
+ if (!manifest['uses-permission']) {
72
+ manifest['uses-permission'] = [];
73
+ }
74
+
75
+ const permissions = [
76
+ 'android.permission.INTERNET',
77
+ 'android.permission.POST_NOTIFICATIONS',
78
+ 'android.permission.FOREGROUND_SERVICE',
79
+ ];
80
+
81
+ for (const permission of permissions) {
82
+ const hasPermission = manifest['uses-permission'].some(
83
+ (p) => p.$?.['android:name'] === permission
84
+ );
85
+ if (!hasPermission) {
86
+ manifest['uses-permission'].push({
87
+ $: { 'android:name': permission },
88
+ });
89
+ }
90
+ }
91
+
92
+ return manifestConfig;
93
+ });
94
+ };
95
+
96
+ /**
97
+ * Main Expo Config Plugin composite function
98
+ */
99
+ const plugin = (config, options = {}) => {
100
+ config = withLiveWidgetsInfoPlist(config, options);
101
+ config = withLiveWidgetsEntitlements(config, options);
102
+ config = withLiveWidgetsAndroidManifest(config, options);
103
+ return config;
104
+ };
105
+
106
+ withLiveWidgets = createRunOncePlugin(plugin, pkg.name, pkg.version);
107
+ } catch (_error) {
108
+ // Fallback for non-Expo / bare React Native environments where @expo/config-plugins is absent
109
+ withLiveWidgets = function (config) {
110
+ return config;
111
+ };
112
+ }
113
+
114
+ module.exports = withLiveWidgets;
Binary file
Binary file
Binary file
Binary file