expo-live-activity 0.2.0-alpha2 → 0.2.0-alpha4
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.md +65 -8
- package/build/index.d.ts +19 -10
- package/build/index.d.ts.map +1 -1
- package/build/index.js +12 -7
- package/build/index.js.map +1 -1
- package/ios/Data+download.swift +13 -0
- package/ios/ExpoLiveActivityModule.swift +168 -117
- package/ios/Helpers.swift +22 -0
- package/ios/LiveActivityAttributes.swift +5 -4
- package/ios-files/Color+hex.swift +29 -29
- package/ios-files/Date+toTimerInterval.swift +13 -0
- package/ios-files/Image+dynamic.swift +23 -0
- package/ios-files/LiveActivityView.swift +39 -45
- package/ios-files/{LiveActivityLiveActivity.swift → LiveActivityWidget.swift} +49 -35
- package/ios-files/LiveActivityWidgetBundle.swift +16 -0
- package/ios-files/View+applyIfPresent.swift +19 -0
- package/ios-files/View+applyWidgetURL.swift +15 -0
- package/ios-files/ViewHelpers.swift +13 -0
- package/package.json +6 -2
- package/plugin/build/index.d.ts +2 -2
- package/plugin/build/index.js +5 -1
- package/plugin/build/types.d.ts +6 -0
- package/plugin/build/types.js +2 -0
- package/plugin/build/withPushNotifications.d.ts +2 -0
- package/plugin/build/withPushNotifications.js +12 -0
- package/plugin/src/index.ts +9 -6
- package/plugin/src/types.ts +9 -0
- package/plugin/src/withPushNotifications.ts +17 -0
- package/plugin/tsconfig.tsbuildinfo +1 -1
- package/src/index.ts +28 -11
- package/ios-files/LiveActivityBundle.swift +0 -16
package/src/index.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import ExpoLiveActivityModule from "./ExpoLiveActivityModule";
|
|
2
2
|
import { Platform } from "react-native";
|
|
3
|
+
import { EventSubscription } from 'expo-modules-core';
|
|
3
4
|
|
|
4
5
|
export type DynamicIslandTimerType = 'circular' | 'digital'
|
|
5
6
|
|
|
@@ -11,34 +12,44 @@ export type LiveActivityState = {
|
|
|
11
12
|
dynamicIslandImageName?: string;
|
|
12
13
|
};
|
|
13
14
|
|
|
14
|
-
export type
|
|
15
|
+
export type LiveActivityConfig = {
|
|
15
16
|
backgroundColor?: string;
|
|
16
17
|
titleColor?: string;
|
|
17
18
|
subtitleColor?: string;
|
|
18
19
|
progressViewTint?: string;
|
|
19
20
|
progressViewLabelColor?: string;
|
|
20
|
-
|
|
21
|
+
deepLinkUrl?: string;
|
|
22
|
+
timerType?: DynamicIslandTimerType;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export type ActivityTokenReceivedEvent = {
|
|
26
|
+
activityID: string;
|
|
27
|
+
activityPushToken: string;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export type LiveActivityModuleEvents = {
|
|
31
|
+
onTokenReceived: (params: ActivityTokenReceivedEvent) => void;
|
|
21
32
|
};
|
|
22
33
|
|
|
23
34
|
/**
|
|
24
35
|
* @param {LiveActivityState} state The state for the live activity.
|
|
36
|
+
* @param {LiveActivityConfig} config Live activity config object.
|
|
25
37
|
* @returns {string} The identifier of the started activity.
|
|
26
|
-
* @throws {Error} When function is called on platform different
|
|
38
|
+
* @throws {Error} When function is called on a platform different from iOS.
|
|
27
39
|
*/
|
|
28
|
-
export function startActivity(state: LiveActivityState,
|
|
40
|
+
export function startActivity(state: LiveActivityState, config?: LiveActivityConfig): string {
|
|
29
41
|
if (Platform.OS !== "ios") {
|
|
30
42
|
throw new Error("startActivity is only available on iOS");
|
|
31
43
|
}
|
|
32
|
-
return ExpoLiveActivityModule.startActivity(state,
|
|
44
|
+
return ExpoLiveActivityModule.startActivity(state, config);
|
|
33
45
|
}
|
|
34
46
|
|
|
35
47
|
/**
|
|
36
48
|
* @param {string} id The identifier of the activity to stop.
|
|
37
49
|
* @param {LiveActivityState} state The updated state for the live activity.
|
|
38
|
-
* @
|
|
39
|
-
* @throws {Error} When function is called on platform different than iOS.
|
|
50
|
+
* @throws {Error} When function is called on a platform different from iOS.
|
|
40
51
|
*/
|
|
41
|
-
export function stopActivity(id: string, state: LiveActivityState)
|
|
52
|
+
export function stopActivity(id: string, state: LiveActivityState) {
|
|
42
53
|
if (Platform.OS !== "ios") {
|
|
43
54
|
throw new Error("stopActivity is only available on iOS");
|
|
44
55
|
}
|
|
@@ -48,12 +59,18 @@ export function stopActivity(id: string, state: LiveActivityState): string {
|
|
|
48
59
|
/**
|
|
49
60
|
* @param {string} id The identifier of the activity to update.
|
|
50
61
|
* @param {LiveActivityState} state The updated state for the live activity.
|
|
51
|
-
* @
|
|
52
|
-
* @throws {Error} When function is called on platform different than iOS.
|
|
62
|
+
* @throws {Error} When function is called on a platform different from iOS.
|
|
53
63
|
*/
|
|
54
|
-
export function updateActivity(id: string, state: LiveActivityState)
|
|
64
|
+
export function updateActivity(id: string, state: LiveActivityState) {
|
|
55
65
|
if (Platform.OS !== "ios") {
|
|
56
66
|
throw new Error("updateActivity is only available on iOS");
|
|
57
67
|
}
|
|
58
68
|
return ExpoLiveActivityModule.updateActivity(id, state);
|
|
59
69
|
}
|
|
70
|
+
|
|
71
|
+
export function addActivityTokenListener(listener: (event: ActivityTokenReceivedEvent) => void): EventSubscription {
|
|
72
|
+
if (Platform.OS !== "ios") {
|
|
73
|
+
throw new Error("updateActivity is only available on iOS");
|
|
74
|
+
}
|
|
75
|
+
return ExpoLiveActivityModule.addListener('onTokenReceived', listener);
|
|
76
|
+
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// LiveActivityBundle.swift
|
|
3
|
-
// LiveActivity
|
|
4
|
-
//
|
|
5
|
-
// Created by Anna Olak on 02/06/2025.
|
|
6
|
-
//
|
|
7
|
-
|
|
8
|
-
import WidgetKit
|
|
9
|
-
import SwiftUI
|
|
10
|
-
|
|
11
|
-
@main
|
|
12
|
-
struct LiveActivityBundle: WidgetBundle {
|
|
13
|
-
var body: some Widget {
|
|
14
|
-
LiveActivityLiveActivity()
|
|
15
|
-
}
|
|
16
|
-
}
|