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
|
@@ -1,37 +1,37 @@
|
|
|
1
1
|
import SwiftUI
|
|
2
2
|
|
|
3
3
|
extension Color {
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
init(hex: String) {
|
|
5
|
+
var cString: String = hex.trimmingCharacters(in: .whitespacesAndNewlines).uppercased()
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
if cString.hasPrefix("#") {
|
|
8
|
+
cString.remove(at: cString.startIndex)
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
if (cString.count) != 6 && (cString.count) != 8 {
|
|
12
|
+
self.init(.white)
|
|
13
|
+
return
|
|
14
|
+
}
|
|
10
15
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
return
|
|
14
|
-
}
|
|
16
|
+
var rgbValue: UInt64 = 0
|
|
17
|
+
Scanner(string: cString).scanHexInt64(&rgbValue)
|
|
15
18
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
blue: Double((rgbValue >> 0) & 0xff) / 255,
|
|
33
|
-
opacity: 1
|
|
34
|
-
)
|
|
35
|
-
}
|
|
19
|
+
if (cString.count) == 8 {
|
|
20
|
+
self.init(
|
|
21
|
+
.sRGB,
|
|
22
|
+
red: Double((rgbValue >> 24) & 0xff) / 255,
|
|
23
|
+
green: Double((rgbValue >> 16) & 0xff) / 255,
|
|
24
|
+
blue: Double((rgbValue >> 08) & 0xff) / 255,
|
|
25
|
+
opacity: Double((rgbValue >> 00) & 0xff) / 255,
|
|
26
|
+
)
|
|
27
|
+
} else {
|
|
28
|
+
self.init(
|
|
29
|
+
.sRGB,
|
|
30
|
+
red: Double((rgbValue >> 16) & 0xff) / 255,
|
|
31
|
+
green: Double((rgbValue >> 08) & 0xff) / 255,
|
|
32
|
+
blue: Double((rgbValue >> 00) & 0xff) / 255,
|
|
33
|
+
opacity: 1
|
|
34
|
+
)
|
|
36
35
|
}
|
|
36
|
+
}
|
|
37
37
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Date+toTimerInterval.swift
|
|
3
|
+
//
|
|
4
|
+
//
|
|
5
|
+
// Created by Artur Bilski on 04/08/2025.
|
|
6
|
+
//
|
|
7
|
+
import SwiftUI
|
|
8
|
+
|
|
9
|
+
extension Date {
|
|
10
|
+
static func toTimerInterval(miliseconds: Double) -> ClosedRange<Self> {
|
|
11
|
+
Self.now...max(Self.now, Date(timeIntervalSince1970: miliseconds / 1000))
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Image+dynamic.swift
|
|
3
|
+
//
|
|
4
|
+
//
|
|
5
|
+
// Created by Artur Bilski on 04/08/2025.
|
|
6
|
+
//
|
|
7
|
+
import SwiftUI
|
|
8
|
+
|
|
9
|
+
extension Image {
|
|
10
|
+
static func dynamic(assetNameOrPath: String) -> Self {
|
|
11
|
+
if let container = FileManager.default.containerURL(
|
|
12
|
+
forSecurityApplicationGroupIdentifier: "group.expoLiveActivity.sharedData"
|
|
13
|
+
) {
|
|
14
|
+
let contentsOfFile = container.appendingPathComponent(assetNameOrPath).path
|
|
15
|
+
|
|
16
|
+
if let uiImage = UIImage(contentsOfFile: contentsOfFile) {
|
|
17
|
+
return Image(uiImage: uiImage)
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return Image(assetNameOrPath)
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -10,64 +10,58 @@ import WidgetKit
|
|
|
10
10
|
|
|
11
11
|
#if canImport(ActivityKit)
|
|
12
12
|
|
|
13
|
-
struct
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
struct ConditionalForegroundViewModifier: ViewModifier {
|
|
14
|
+
let color: String?
|
|
15
|
+
|
|
16
|
+
func body(content: Content) -> some View {
|
|
17
|
+
if let color = color {
|
|
18
|
+
content.foregroundStyle(Color(hex: color))
|
|
19
|
+
} else {
|
|
20
|
+
content
|
|
21
|
+
}
|
|
22
|
+
}
|
|
19
23
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
24
|
+
|
|
25
|
+
struct LiveActivityView: View {
|
|
26
|
+
let contentState: LiveActivityAttributes.ContentState
|
|
27
|
+
let attributes: LiveActivityAttributes
|
|
28
|
+
|
|
29
|
+
var progressViewTint: Color? {
|
|
30
|
+
attributes.progressViewTint.map { Color(hex: $0) }
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
var body: some View {
|
|
34
|
+
VStack(alignment: .leading) {
|
|
35
|
+
HStack(alignment: .center) {
|
|
36
|
+
VStack(alignment: .leading, spacing: 2) {
|
|
31
37
|
Text(contentState.title)
|
|
32
38
|
.font(.title2)
|
|
33
39
|
.fontWeight(.semibold)
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
if let subtitleColor = attributes.subtitleColor {
|
|
38
|
-
Text(subtitle)
|
|
39
|
-
.font(.title3)
|
|
40
|
-
.foregroundStyle(Color(hex: subtitleColor))
|
|
41
|
-
} else {
|
|
40
|
+
.modifier(ConditionalForegroundViewModifier(color: attributes.titleColor))
|
|
41
|
+
|
|
42
|
+
if let subtitle = contentState.subtitle {
|
|
42
43
|
Text(subtitle)
|
|
43
44
|
.font(.title3)
|
|
45
|
+
.modifier(ConditionalForegroundViewModifier(color: attributes.subtitleColor))
|
|
44
46
|
}
|
|
45
47
|
}
|
|
48
|
+
|
|
49
|
+
Spacer()
|
|
50
|
+
|
|
51
|
+
if let imageName = contentState.imageName {
|
|
52
|
+
resizableImage(imageName: imageName)
|
|
53
|
+
.frame(maxHeight: 64)
|
|
54
|
+
}
|
|
46
55
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
if let imageName = contentState.imageName {
|
|
51
|
-
Image(imageName)
|
|
52
|
-
.resizable()
|
|
53
|
-
.scaledToFit()
|
|
54
|
-
.frame(maxHeight: 64)
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
if let date = contentState.date {
|
|
59
|
-
if let progressViewLabelColor = attributes.progressViewLabelColor {
|
|
60
|
-
ProgressView(timerInterval: Date.now...max(Date.now, date))
|
|
61
|
-
.tint(progressViewTint)
|
|
62
|
-
.foregroundStyle(Color(hex: progressViewLabelColor))
|
|
63
|
-
} else {
|
|
64
|
-
ProgressView(timerInterval: Date.now...max(Date.now, date))
|
|
56
|
+
|
|
57
|
+
if let date = contentState.date {
|
|
58
|
+
ProgressView(timerInterval: Date.toTimerInterval(miliseconds: date))
|
|
65
59
|
.tint(progressViewTint)
|
|
60
|
+
.modifier(ConditionalForegroundViewModifier(color: attributes.progressViewLabelColor))
|
|
66
61
|
}
|
|
67
62
|
}
|
|
63
|
+
.padding(24)
|
|
68
64
|
}
|
|
69
|
-
.padding(24)
|
|
70
65
|
}
|
|
71
|
-
}
|
|
72
66
|
|
|
73
67
|
#endif
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//
|
|
2
|
-
//
|
|
2
|
+
// LiveActivityWidget.swift
|
|
3
3
|
// LiveActivity
|
|
4
4
|
//
|
|
5
5
|
// Created by Anna Olak on 02/06/2025.
|
|
@@ -13,7 +13,7 @@ struct LiveActivityAttributes: ActivityAttributes {
|
|
|
13
13
|
public struct ContentState: Codable, Hashable {
|
|
14
14
|
var title: String
|
|
15
15
|
var subtitle: String?
|
|
16
|
-
var date:
|
|
16
|
+
var date: Double?
|
|
17
17
|
var imageName: String?
|
|
18
18
|
var dynamicIslandImageName: String?
|
|
19
19
|
}
|
|
@@ -24,70 +24,89 @@ struct LiveActivityAttributes: ActivityAttributes {
|
|
|
24
24
|
var subtitleColor: String?
|
|
25
25
|
var progressViewTint: String?
|
|
26
26
|
var progressViewLabelColor: String?
|
|
27
|
+
var deepLinkUrl: String?
|
|
27
28
|
var timerType: DynamicIslandTimerType
|
|
28
|
-
|
|
29
|
+
|
|
29
30
|
enum DynamicIslandTimerType: String, Codable {
|
|
30
|
-
|
|
31
|
-
|
|
31
|
+
case circular
|
|
32
|
+
case digital
|
|
32
33
|
}
|
|
33
34
|
}
|
|
34
35
|
|
|
35
|
-
struct
|
|
36
|
+
struct LiveActivityWidget: Widget {
|
|
36
37
|
var body: some WidgetConfiguration {
|
|
37
38
|
ActivityConfiguration(for: LiveActivityAttributes.self) { context in
|
|
38
39
|
LiveActivityView(contentState: context.state, attributes: context.attributes)
|
|
39
|
-
.activityBackgroundTint(
|
|
40
|
+
.activityBackgroundTint(
|
|
41
|
+
context.attributes.backgroundColor.map { Color(hex: $0) }
|
|
42
|
+
)
|
|
40
43
|
.activitySystemActionForegroundColor(Color.black)
|
|
41
|
-
|
|
44
|
+
.applyWidgetURL(from: context.attributes.deepLinkUrl)
|
|
42
45
|
} dynamicIsland: { context in
|
|
43
46
|
DynamicIsland {
|
|
44
47
|
DynamicIslandExpandedRegion(.leading, priority: 1) {
|
|
45
48
|
dynamicIslandExpandedLeading(title: context.state.title, subtitle: context.state.subtitle)
|
|
46
49
|
.dynamicIsland(verticalPlacement: .belowIfTooWide)
|
|
47
50
|
.padding(.leading, 5)
|
|
51
|
+
.applyWidgetURL(from: context.attributes.deepLinkUrl)
|
|
48
52
|
}
|
|
49
53
|
DynamicIslandExpandedRegion(.trailing) {
|
|
50
54
|
if let imageName = context.state.imageName {
|
|
51
55
|
dynamicIslandExpandedTrailing(imageName: imageName)
|
|
52
56
|
.padding(.trailing, 5)
|
|
57
|
+
.applyWidgetURL(from: context.attributes.deepLinkUrl)
|
|
53
58
|
}
|
|
54
59
|
}
|
|
55
60
|
DynamicIslandExpandedRegion(.bottom) {
|
|
56
61
|
if let date = context.state.date {
|
|
57
62
|
dynamicIslandExpandedBottom(endDate: date, progressViewTint: context.attributes.progressViewTint)
|
|
58
63
|
.padding(.horizontal, 5)
|
|
64
|
+
.applyWidgetURL(from: context.attributes.deepLinkUrl)
|
|
59
65
|
}
|
|
60
66
|
}
|
|
61
67
|
} compactLeading: {
|
|
62
68
|
if let dynamicIslandImageName = context.state.dynamicIslandImageName {
|
|
63
69
|
resizableImage(imageName: dynamicIslandImageName)
|
|
64
70
|
.frame(maxWidth: 23, maxHeight: 23)
|
|
71
|
+
.applyWidgetURL(from: context.attributes.deepLinkUrl)
|
|
65
72
|
}
|
|
66
73
|
} compactTrailing: {
|
|
67
74
|
if let date = context.state.date {
|
|
68
|
-
compactTimer(
|
|
75
|
+
compactTimer(
|
|
76
|
+
endDate: date,
|
|
77
|
+
timerType: context.attributes.timerType,
|
|
78
|
+
progressViewTint: context.attributes.progressViewTint
|
|
79
|
+
).applyWidgetURL(from: context.attributes.deepLinkUrl)
|
|
69
80
|
}
|
|
70
81
|
} minimal: {
|
|
71
82
|
if let date = context.state.date {
|
|
72
|
-
compactTimer(
|
|
83
|
+
compactTimer(
|
|
84
|
+
endDate: date,
|
|
85
|
+
timerType: context.attributes.timerType,
|
|
86
|
+
progressViewTint: context.attributes.progressViewTint
|
|
87
|
+
).applyWidgetURL(from: context.attributes.deepLinkUrl)
|
|
73
88
|
}
|
|
74
89
|
}
|
|
75
90
|
}
|
|
76
91
|
}
|
|
77
|
-
|
|
92
|
+
|
|
78
93
|
@ViewBuilder
|
|
79
|
-
private func compactTimer(
|
|
94
|
+
private func compactTimer(
|
|
95
|
+
endDate: Double,
|
|
96
|
+
timerType: LiveActivityAttributes.DynamicIslandTimerType,
|
|
97
|
+
progressViewTint: String?
|
|
98
|
+
) -> some View {
|
|
80
99
|
if timerType == .digital {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
100
|
+
Text(timerInterval: Date.toTimerInterval(miliseconds: endDate))
|
|
101
|
+
.font(.system(size: 15))
|
|
102
|
+
.minimumScaleFactor(0.8)
|
|
103
|
+
.fontWeight(.semibold)
|
|
104
|
+
.frame(maxWidth: 60)
|
|
105
|
+
.multilineTextAlignment(.trailing)
|
|
106
|
+
} else {
|
|
107
|
+
circularTimer(endDate: endDate)
|
|
108
|
+
.tint(progressViewTint.map { Color(hex: $0) })
|
|
109
|
+
}
|
|
91
110
|
}
|
|
92
111
|
|
|
93
112
|
private func dynamicIslandExpandedLeading(title: String, subtitle: String?) -> some View {
|
|
@@ -106,7 +125,7 @@ struct LiveActivityLiveActivity: Widget {
|
|
|
106
125
|
Spacer()
|
|
107
126
|
}
|
|
108
127
|
}
|
|
109
|
-
|
|
128
|
+
|
|
110
129
|
private func dynamicIslandExpandedTrailing(imageName: String) -> some View {
|
|
111
130
|
VStack {
|
|
112
131
|
Spacer()
|
|
@@ -115,17 +134,17 @@ struct LiveActivityLiveActivity: Widget {
|
|
|
115
134
|
Spacer()
|
|
116
135
|
}
|
|
117
136
|
}
|
|
118
|
-
|
|
119
|
-
private func dynamicIslandExpandedBottom(endDate:
|
|
120
|
-
ProgressView(timerInterval: Date.
|
|
137
|
+
|
|
138
|
+
private func dynamicIslandExpandedBottom(endDate: Double, progressViewTint: String?) -> some View {
|
|
139
|
+
ProgressView(timerInterval: Date.toTimerInterval(miliseconds: endDate))
|
|
121
140
|
.foregroundStyle(.white)
|
|
122
|
-
.tint(progressViewTint
|
|
141
|
+
.tint(progressViewTint.map { Color(hex: $0) })
|
|
123
142
|
.padding(.top, 5)
|
|
124
143
|
}
|
|
125
|
-
|
|
126
|
-
private func circularTimer(endDate:
|
|
144
|
+
|
|
145
|
+
private func circularTimer(endDate: Double) -> some View {
|
|
127
146
|
ProgressView(
|
|
128
|
-
timerInterval: Date.
|
|
147
|
+
timerInterval: Date.toTimerInterval(miliseconds: endDate),
|
|
129
148
|
countsDown: false,
|
|
130
149
|
label: { EmptyView() },
|
|
131
150
|
currentValueLabel: {
|
|
@@ -134,9 +153,4 @@ struct LiveActivityLiveActivity: Widget {
|
|
|
134
153
|
)
|
|
135
154
|
.progressViewStyle(.circular)
|
|
136
155
|
}
|
|
137
|
-
private func resizableImage(imageName: String) -> some View {
|
|
138
|
-
Image(imageName)
|
|
139
|
-
.resizable()
|
|
140
|
-
.scaledToFit()
|
|
141
|
-
}
|
|
142
156
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
//
|
|
2
|
+
// LiveActivityWidgetBundle.swift
|
|
3
|
+
// LiveActivity
|
|
4
|
+
//
|
|
5
|
+
// Created by Anna Olak on 02/06/2025.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
import SwiftUI
|
|
9
|
+
import WidgetKit
|
|
10
|
+
|
|
11
|
+
@main
|
|
12
|
+
struct LiveActivityWidgetBundle: WidgetBundle {
|
|
13
|
+
var body: some Widget {
|
|
14
|
+
LiveActivityWidget()
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
//
|
|
2
|
+
// View+applyIfPresent.swift
|
|
3
|
+
//
|
|
4
|
+
//
|
|
5
|
+
// Created by Artur Bilski on 05/08/2025.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
import SwiftUI
|
|
9
|
+
|
|
10
|
+
extension View {
|
|
11
|
+
@ViewBuilder
|
|
12
|
+
func applyIfPresent<T>(_ value: T?, transform: (Self, T) -> some View) -> some View {
|
|
13
|
+
if let value {
|
|
14
|
+
transform(self, value)
|
|
15
|
+
} else {
|
|
16
|
+
self
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
//
|
|
2
|
+
// View+applyWidgetURL.swift
|
|
3
|
+
//
|
|
4
|
+
//
|
|
5
|
+
// Created by Artur Bilski on 05/08/2025.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
import SwiftUI
|
|
9
|
+
|
|
10
|
+
extension View {
|
|
11
|
+
@ViewBuilder
|
|
12
|
+
func applyWidgetURL(from urlString: String?) -> some View {
|
|
13
|
+
applyIfPresent(urlString) { view, string in view.widgetURL(URL(string: string))}
|
|
14
|
+
}
|
|
15
|
+
}
|
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-live-activity",
|
|
3
|
-
"version": "0.2.0-
|
|
3
|
+
"version": "0.2.0-alpha4",
|
|
4
4
|
"description": "A module for adding Live Activity to a React Native app for iOS.",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"build": "expo-module build",
|
|
9
9
|
"clean": "expo-module clean",
|
|
10
|
+
"clean:plugin": "rm -rf plugin/build plugin/tsconfig.tsbuildinfo",
|
|
10
11
|
"lint": "expo-module lint",
|
|
11
12
|
"test": "expo-module test",
|
|
12
13
|
"prepare": "expo-module prepare",
|
|
@@ -22,7 +23,10 @@
|
|
|
22
23
|
"apple"
|
|
23
24
|
],
|
|
24
25
|
"author": "Kamil Owczarz <kamil.owczarz@swmansion.com> (https://github.com/kowczarz)",
|
|
25
|
-
"contributors": [
|
|
26
|
+
"contributors": [
|
|
27
|
+
"Anna Olak <anna.olak@swmansion.com> (https://github.com/anna1901)",
|
|
28
|
+
"Artur Bilski <artur.bilski@swmansion.com> (https://github.com/arthwood)"
|
|
29
|
+
],
|
|
26
30
|
"repository": "https://github.com/software-mansion-labs/expo-live-activity.git",
|
|
27
31
|
"bugs": {
|
|
28
32
|
"url": "https://github.com/software-mansion-labs/expo-live-activity/issues"
|
package/plugin/build/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
declare const withWidgetsAndLiveActivities:
|
|
1
|
+
import type { LiveActivityConfigPlugin } from "./types";
|
|
2
|
+
declare const withWidgetsAndLiveActivities: LiveActivityConfigPlugin;
|
|
3
3
|
export default withWidgetsAndLiveActivities;
|
package/plugin/build/index.js
CHANGED
|
@@ -5,7 +5,8 @@ const withConfig_1 = require("./withConfig");
|
|
|
5
5
|
const withPodfile_1 = require("./withPodfile");
|
|
6
6
|
const withXcode_1 = require("./withXcode");
|
|
7
7
|
const withWidgetExtensionEntitlements_1 = require("./withWidgetExtensionEntitlements");
|
|
8
|
-
const
|
|
8
|
+
const withPushNotifications_1 = require("./withPushNotifications");
|
|
9
|
+
const withWidgetsAndLiveActivities = (config, props) => {
|
|
9
10
|
const deploymentTarget = "16.2";
|
|
10
11
|
const targetName = `${config_plugins_1.IOSConfig.XcodeUtils.sanitizedName(config.name)}LiveActivity`;
|
|
11
12
|
const bundleIdentifier = `${config.ios?.bundleIdentifier}.${targetName}`;
|
|
@@ -30,6 +31,9 @@ const withWidgetsAndLiveActivities = (config) => {
|
|
|
30
31
|
[withPodfile_1.withPodfile, { targetName }],
|
|
31
32
|
[withConfig_1.withConfig, { targetName, bundleIdentifier }],
|
|
32
33
|
]);
|
|
34
|
+
if (props?.enablePushNotifications) {
|
|
35
|
+
config = (0, withPushNotifications_1.withPushNotifications)(config);
|
|
36
|
+
}
|
|
33
37
|
return config;
|
|
34
38
|
};
|
|
35
39
|
exports.default = withWidgetsAndLiveActivities;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.withPushNotifications = void 0;
|
|
4
|
+
const config_plugins_1 = require("@expo/config-plugins");
|
|
5
|
+
const withPushNotifications = (config) => (0, config_plugins_1.withInfoPlist)((0, config_plugins_1.withEntitlementsPlist)(config, (mod) => {
|
|
6
|
+
mod.modResults["aps-environment"] = "development";
|
|
7
|
+
return mod;
|
|
8
|
+
}), (mod) => {
|
|
9
|
+
mod.modResults["ExpoLiveActivity_EnablePushNotifications"] = true;
|
|
10
|
+
return mod;
|
|
11
|
+
});
|
|
12
|
+
exports.withPushNotifications = withPushNotifications;
|
package/plugin/src/index.ts
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IOSConfig, withPlugins } from "expo/config-plugins";
|
|
2
|
+
import type { LiveActivityConfigPlugin } from "./types";
|
|
2
3
|
import { withConfig } from "./withConfig";
|
|
3
4
|
import { withPodfile } from "./withPodfile";
|
|
4
|
-
|
|
5
5
|
import { withXcode } from "./withXcode";
|
|
6
6
|
import { withWidgetExtensionEntitlements } from "./withWidgetExtensionEntitlements";
|
|
7
|
+
import { withPushNotifications } from "./withPushNotifications";
|
|
7
8
|
|
|
8
|
-
const withWidgetsAndLiveActivities:
|
|
9
|
-
config
|
|
10
|
-
) => {
|
|
9
|
+
const withWidgetsAndLiveActivities: LiveActivityConfigPlugin = (config, props) => {
|
|
11
10
|
const deploymentTarget = "16.2";
|
|
12
11
|
const targetName = `${IOSConfig.XcodeUtils.sanitizedName(
|
|
13
|
-
config.name
|
|
12
|
+
config.name,
|
|
14
13
|
)}LiveActivity`;
|
|
15
14
|
const bundleIdentifier = `${config.ios?.bundleIdentifier}.${targetName}`;
|
|
16
15
|
|
|
@@ -37,6 +36,10 @@ const withWidgetsAndLiveActivities: ConfigPlugin = (
|
|
|
37
36
|
[withConfig, { targetName, bundleIdentifier }],
|
|
38
37
|
]);
|
|
39
38
|
|
|
39
|
+
if (props?.enablePushNotifications) {
|
|
40
|
+
config = withPushNotifications(config);
|
|
41
|
+
}
|
|
42
|
+
|
|
40
43
|
return config;
|
|
41
44
|
};
|
|
42
45
|
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ConfigPlugin,
|
|
3
|
+
withEntitlementsPlist,
|
|
4
|
+
withInfoPlist,
|
|
5
|
+
} from "@expo/config-plugins";
|
|
6
|
+
|
|
7
|
+
export const withPushNotifications: ConfigPlugin = (config) =>
|
|
8
|
+
withInfoPlist(
|
|
9
|
+
withEntitlementsPlist(config, (mod) => {
|
|
10
|
+
mod.modResults["aps-environment"] = "development";
|
|
11
|
+
return mod;
|
|
12
|
+
}),
|
|
13
|
+
(mod) => {
|
|
14
|
+
mod.modResults["ExpoLiveActivity_EnablePushNotifications"] = true;
|
|
15
|
+
return mod;
|
|
16
|
+
},
|
|
17
|
+
);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"root":["./src/index.ts","./src/withConfig.ts","./src/withPodfile.ts","./src/withWidgetExtensionEntitlements.ts","./src/withXcode.ts","./src/lib/getWidgetExtensionEntitlements.ts","./src/lib/getWidgetFiles.ts","./src/xcode/addBuildPhases.ts","./src/xcode/addPbxGroup.ts","./src/xcode/addProductFile.ts","./src/xcode/addTargetDependency.ts","./src/xcode/addToPbxNativeTargetSection.ts","./src/xcode/addToPbxProjectSection.ts","./src/xcode/addXCConfigurationList.ts"],"version":"5.8.3"}
|
|
1
|
+
{"root":["./src/index.ts","./src/types.ts","./src/withConfig.ts","./src/withPodfile.ts","./src/withPushNotifications.ts","./src/withWidgetExtensionEntitlements.ts","./src/withXcode.ts","./src/lib/getWidgetExtensionEntitlements.ts","./src/lib/getWidgetFiles.ts","./src/xcode/addBuildPhases.ts","./src/xcode/addPbxGroup.ts","./src/xcode/addProductFile.ts","./src/xcode/addTargetDependency.ts","./src/xcode/addToPbxNativeTargetSection.ts","./src/xcode/addToPbxProjectSection.ts","./src/xcode/addXCConfigurationList.ts"],"version":"5.8.3"}
|