@loyalytics/swan-react-native-sdk 2.0.1
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 +55 -0
- package/README.md +67 -0
- package/docs/IOS_NOTIFICATION_EXTENSION_SETUP.md +335 -0
- package/ios/README.md +64 -0
- package/ios/SwanNotificationServiceExtension/Info.plist +31 -0
- package/ios/SwanNotificationServiceExtension/NotificationService.swift +337 -0
- package/ios/SwanNotificationServiceExtension/SwanNotificationServiceExtension.entitlements +10 -0
- package/lib/commonjs/components/FooterView.js +125 -0
- package/lib/commonjs/components/FooterView.js.map +1 -0
- package/lib/commonjs/components/FullScreenView.js +172 -0
- package/lib/commonjs/components/FullScreenView.js.map +1 -0
- package/lib/commonjs/components/HeaderView.js +205 -0
- package/lib/commonjs/components/HeaderView.js.map +1 -0
- package/lib/commonjs/components/PopUpView.js +186 -0
- package/lib/commonjs/components/PopUpView.js.map +1 -0
- package/lib/commonjs/config/BatchConfig.js +53 -0
- package/lib/commonjs/config/BatchConfig.js.map +1 -0
- package/lib/commonjs/constants/ApiUrls.js +56 -0
- package/lib/commonjs/constants/ApiUrls.js.map +1 -0
- package/lib/commonjs/core/EventQueueManager.js +345 -0
- package/lib/commonjs/core/EventQueueManager.js.map +1 -0
- package/lib/commonjs/core/FlushManager.js +245 -0
- package/lib/commonjs/core/FlushManager.js.map +1 -0
- package/lib/commonjs/core/NetworkMonitor.js +97 -0
- package/lib/commonjs/core/NetworkMonitor.js.map +1 -0
- package/lib/commonjs/index.js +3506 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/providers/FirebasePushProvider.js +130 -0
- package/lib/commonjs/providers/FirebasePushProvider.js.map +1 -0
- package/lib/commonjs/providers/NullPushProvider.js +59 -0
- package/lib/commonjs/providers/NullPushProvider.js.map +1 -0
- package/lib/commonjs/providers/PushNotificationProvider.js +30 -0
- package/lib/commonjs/providers/PushNotificationProvider.js.map +1 -0
- package/lib/commonjs/services/DeviceRegistrationService.js +248 -0
- package/lib/commonjs/services/DeviceRegistrationService.js.map +1 -0
- package/lib/commonjs/services/PushTokenService.js +284 -0
- package/lib/commonjs/services/PushTokenService.js.map +1 -0
- package/lib/commonjs/state/AuthStateMachine.js +161 -0
- package/lib/commonjs/state/AuthStateMachine.js.map +1 -0
- package/lib/commonjs/state/DeviceStateMachine.js +104 -0
- package/lib/commonjs/state/DeviceStateMachine.js.map +1 -0
- package/lib/commonjs/state/PushStateMachine.js +129 -0
- package/lib/commonjs/state/PushStateMachine.js.map +1 -0
- package/lib/commonjs/types/EventQueue.js +50 -0
- package/lib/commonjs/types/EventQueue.js.map +1 -0
- package/lib/commonjs/types/SDK.js +2 -0
- package/lib/commonjs/types/SDK.js.map +1 -0
- package/lib/commonjs/utils/FirebaseNotificationManager.js +492 -0
- package/lib/commonjs/utils/FirebaseNotificationManager.js.map +1 -0
- package/lib/commonjs/utils/Logger.js +56 -0
- package/lib/commonjs/utils/Logger.js.map +1 -0
- package/lib/commonjs/utils/SharedCredentialsManager.js +146 -0
- package/lib/commonjs/utils/SharedCredentialsManager.js.map +1 -0
- package/lib/commonjs/version.js +12 -0
- package/lib/commonjs/version.js.map +1 -0
- package/lib/module/components/FooterView.js +121 -0
- package/lib/module/components/FooterView.js.map +1 -0
- package/lib/module/components/FullScreenView.js +167 -0
- package/lib/module/components/FullScreenView.js.map +1 -0
- package/lib/module/components/HeaderView.js +199 -0
- package/lib/module/components/HeaderView.js.map +1 -0
- package/lib/module/components/PopUpView.js +181 -0
- package/lib/module/components/PopUpView.js.map +1 -0
- package/lib/module/config/BatchConfig.js +49 -0
- package/lib/module/config/BatchConfig.js.map +1 -0
- package/lib/module/constants/ApiUrls.js +52 -0
- package/lib/module/constants/ApiUrls.js.map +1 -0
- package/lib/module/core/EventQueueManager.js +340 -0
- package/lib/module/core/EventQueueManager.js.map +1 -0
- package/lib/module/core/FlushManager.js +240 -0
- package/lib/module/core/FlushManager.js.map +1 -0
- package/lib/module/core/NetworkMonitor.js +92 -0
- package/lib/module/core/NetworkMonitor.js.map +1 -0
- package/lib/module/index.js +3494 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/providers/FirebasePushProvider.js +124 -0
- package/lib/module/providers/FirebasePushProvider.js.map +1 -0
- package/lib/module/providers/NullPushProvider.js +53 -0
- package/lib/module/providers/NullPushProvider.js.map +1 -0
- package/lib/module/providers/PushNotificationProvider.js +26 -0
- package/lib/module/providers/PushNotificationProvider.js.map +1 -0
- package/lib/module/services/DeviceRegistrationService.js +243 -0
- package/lib/module/services/DeviceRegistrationService.js.map +1 -0
- package/lib/module/services/PushTokenService.js +278 -0
- package/lib/module/services/PushTokenService.js.map +1 -0
- package/lib/module/state/AuthStateMachine.js +155 -0
- package/lib/module/state/AuthStateMachine.js.map +1 -0
- package/lib/module/state/DeviceStateMachine.js +98 -0
- package/lib/module/state/DeviceStateMachine.js.map +1 -0
- package/lib/module/state/PushStateMachine.js +123 -0
- package/lib/module/state/PushStateMachine.js.map +1 -0
- package/lib/module/types/EventQueue.js +46 -0
- package/lib/module/types/EventQueue.js.map +1 -0
- package/lib/module/types/SDK.js +2 -0
- package/lib/module/types/SDK.js.map +1 -0
- package/lib/module/utils/FirebaseNotificationManager.js +486 -0
- package/lib/module/utils/FirebaseNotificationManager.js.map +1 -0
- package/lib/module/utils/Logger.js +52 -0
- package/lib/module/utils/Logger.js.map +1 -0
- package/lib/module/utils/SharedCredentialsManager.js +140 -0
- package/lib/module/utils/SharedCredentialsManager.js.map +1 -0
- package/lib/module/version.js +8 -0
- package/lib/module/version.js.map +1 -0
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/commonjs/src/components/FooterView.d.ts +3 -0
- package/lib/typescript/commonjs/src/components/FooterView.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/components/FullScreenView.d.ts +3 -0
- package/lib/typescript/commonjs/src/components/FullScreenView.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/components/HeaderView.d.ts +3 -0
- package/lib/typescript/commonjs/src/components/HeaderView.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/components/PopUpView.d.ts +3 -0
- package/lib/typescript/commonjs/src/components/PopUpView.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/config/BatchConfig.d.ts +7 -0
- package/lib/typescript/commonjs/src/config/BatchConfig.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/constants/ApiUrls.d.ts +56 -0
- package/lib/typescript/commonjs/src/constants/ApiUrls.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/core/EventQueueManager.d.ts +63 -0
- package/lib/typescript/commonjs/src/core/EventQueueManager.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/core/FlushManager.d.ts +63 -0
- package/lib/typescript/commonjs/src/core/FlushManager.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/core/NetworkMonitor.d.ts +38 -0
- package/lib/typescript/commonjs/src/core/NetworkMonitor.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/index.d.ts +663 -0
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/providers/FirebasePushProvider.d.ts +28 -0
- package/lib/typescript/commonjs/src/providers/FirebasePushProvider.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/providers/NullPushProvider.d.ts +25 -0
- package/lib/typescript/commonjs/src/providers/NullPushProvider.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/providers/PushNotificationProvider.d.ts +105 -0
- package/lib/typescript/commonjs/src/providers/PushNotificationProvider.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/services/DeviceRegistrationService.d.ts +60 -0
- package/lib/typescript/commonjs/src/services/DeviceRegistrationService.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/services/PushTokenService.d.ts +82 -0
- package/lib/typescript/commonjs/src/services/PushTokenService.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/state/AuthStateMachine.d.ts +61 -0
- package/lib/typescript/commonjs/src/state/AuthStateMachine.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/state/DeviceStateMachine.d.ts +51 -0
- package/lib/typescript/commonjs/src/state/DeviceStateMachine.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/state/PushStateMachine.d.ts +61 -0
- package/lib/typescript/commonjs/src/state/PushStateMachine.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/types/EventQueue.d.ts +85 -0
- package/lib/typescript/commonjs/src/types/EventQueue.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/types/SDK.d.ts +54 -0
- package/lib/typescript/commonjs/src/types/SDK.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/utils/FirebaseNotificationManager.d.ts +169 -0
- package/lib/typescript/commonjs/src/utils/FirebaseNotificationManager.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/utils/Logger.d.ts +32 -0
- package/lib/typescript/commonjs/src/utils/Logger.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/utils/SharedCredentialsManager.d.ts +54 -0
- package/lib/typescript/commonjs/src/utils/SharedCredentialsManager.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/version.d.ts +2 -0
- package/lib/typescript/commonjs/src/version.d.ts.map +1 -0
- package/lib/typescript/module/package.json +1 -0
- package/lib/typescript/module/src/components/FooterView.d.ts +3 -0
- package/lib/typescript/module/src/components/FooterView.d.ts.map +1 -0
- package/lib/typescript/module/src/components/FullScreenView.d.ts +3 -0
- package/lib/typescript/module/src/components/FullScreenView.d.ts.map +1 -0
- package/lib/typescript/module/src/components/HeaderView.d.ts +3 -0
- package/lib/typescript/module/src/components/HeaderView.d.ts.map +1 -0
- package/lib/typescript/module/src/components/PopUpView.d.ts +3 -0
- package/lib/typescript/module/src/components/PopUpView.d.ts.map +1 -0
- package/lib/typescript/module/src/config/BatchConfig.d.ts +7 -0
- package/lib/typescript/module/src/config/BatchConfig.d.ts.map +1 -0
- package/lib/typescript/module/src/constants/ApiUrls.d.ts +56 -0
- package/lib/typescript/module/src/constants/ApiUrls.d.ts.map +1 -0
- package/lib/typescript/module/src/core/EventQueueManager.d.ts +63 -0
- package/lib/typescript/module/src/core/EventQueueManager.d.ts.map +1 -0
- package/lib/typescript/module/src/core/FlushManager.d.ts +63 -0
- package/lib/typescript/module/src/core/FlushManager.d.ts.map +1 -0
- package/lib/typescript/module/src/core/NetworkMonitor.d.ts +38 -0
- package/lib/typescript/module/src/core/NetworkMonitor.d.ts.map +1 -0
- package/lib/typescript/module/src/index.d.ts +663 -0
- package/lib/typescript/module/src/index.d.ts.map +1 -0
- package/lib/typescript/module/src/providers/FirebasePushProvider.d.ts +28 -0
- package/lib/typescript/module/src/providers/FirebasePushProvider.d.ts.map +1 -0
- package/lib/typescript/module/src/providers/NullPushProvider.d.ts +25 -0
- package/lib/typescript/module/src/providers/NullPushProvider.d.ts.map +1 -0
- package/lib/typescript/module/src/providers/PushNotificationProvider.d.ts +105 -0
- package/lib/typescript/module/src/providers/PushNotificationProvider.d.ts.map +1 -0
- package/lib/typescript/module/src/services/DeviceRegistrationService.d.ts +60 -0
- package/lib/typescript/module/src/services/DeviceRegistrationService.d.ts.map +1 -0
- package/lib/typescript/module/src/services/PushTokenService.d.ts +82 -0
- package/lib/typescript/module/src/services/PushTokenService.d.ts.map +1 -0
- package/lib/typescript/module/src/state/AuthStateMachine.d.ts +61 -0
- package/lib/typescript/module/src/state/AuthStateMachine.d.ts.map +1 -0
- package/lib/typescript/module/src/state/DeviceStateMachine.d.ts +51 -0
- package/lib/typescript/module/src/state/DeviceStateMachine.d.ts.map +1 -0
- package/lib/typescript/module/src/state/PushStateMachine.d.ts +61 -0
- package/lib/typescript/module/src/state/PushStateMachine.d.ts.map +1 -0
- package/lib/typescript/module/src/types/EventQueue.d.ts +85 -0
- package/lib/typescript/module/src/types/EventQueue.d.ts.map +1 -0
- package/lib/typescript/module/src/types/SDK.d.ts +54 -0
- package/lib/typescript/module/src/types/SDK.d.ts.map +1 -0
- package/lib/typescript/module/src/utils/FirebaseNotificationManager.d.ts +169 -0
- package/lib/typescript/module/src/utils/FirebaseNotificationManager.d.ts.map +1 -0
- package/lib/typescript/module/src/utils/Logger.d.ts +32 -0
- package/lib/typescript/module/src/utils/Logger.d.ts.map +1 -0
- package/lib/typescript/module/src/utils/SharedCredentialsManager.d.ts +54 -0
- package/lib/typescript/module/src/utils/SharedCredentialsManager.d.ts.map +1 -0
- package/lib/typescript/module/src/version.d.ts +2 -0
- package/lib/typescript/module/src/version.d.ts.map +1 -0
- package/package.json +230 -0
- package/scripts/generate-version.js +25 -0
- package/scripts/setup-ios-extension.js +275 -0
|
@@ -0,0 +1,337 @@
|
|
|
1
|
+
//
|
|
2
|
+
// NotificationService.swift
|
|
3
|
+
// SwanNotificationServiceExtension
|
|
4
|
+
//
|
|
5
|
+
// Swan SDK Notification Service Extension
|
|
6
|
+
// Handles delivery ACKs and rich media for iOS push notifications
|
|
7
|
+
//
|
|
8
|
+
|
|
9
|
+
import UserNotifications
|
|
10
|
+
|
|
11
|
+
class NotificationService: UNNotificationServiceExtension {
|
|
12
|
+
|
|
13
|
+
var contentHandler: ((UNNotificationContent) -> Void)?
|
|
14
|
+
var bestAttemptContent: UNMutableNotificationContent?
|
|
15
|
+
|
|
16
|
+
override func didReceive(
|
|
17
|
+
_ request: UNNotificationRequest,
|
|
18
|
+
withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void
|
|
19
|
+
) {
|
|
20
|
+
self.contentHandler = contentHandler
|
|
21
|
+
bestAttemptContent = (request.content.mutableCopy() as? UNMutableNotificationContent)
|
|
22
|
+
|
|
23
|
+
if let bestAttemptContent = bestAttemptContent {
|
|
24
|
+
// Log extension triggered
|
|
25
|
+
NSLog("[SwanSDK Extension] Notification Service Extension triggered")
|
|
26
|
+
NSLog("[SwanSDK Extension] Request identifier: \(request.identifier)")
|
|
27
|
+
|
|
28
|
+
// Mark that Notification Service Extension is active
|
|
29
|
+
// This flag is checked by React Native to skip delivery ACKs (since NES handles them)
|
|
30
|
+
markExtensionActive()
|
|
31
|
+
|
|
32
|
+
// Extract FCM messageId from userInfo
|
|
33
|
+
let userInfo = request.content.userInfo
|
|
34
|
+
NSLog("[SwanSDK Extension] UserInfo: \(userInfo)")
|
|
35
|
+
|
|
36
|
+
// Check if this is a silent push notification
|
|
37
|
+
let isSilent =
|
|
38
|
+
userInfo["silent"] as? String == "true" || userInfo["silent"] as? Bool == true
|
|
39
|
+
NSLog("[SwanSDK Extension] Is silent push: \(isSilent)")
|
|
40
|
+
|
|
41
|
+
// Handle silent push notifications
|
|
42
|
+
if isSilent {
|
|
43
|
+
NSLog("[SwanSDK Extension] Silent push received, no notification displayed")
|
|
44
|
+
return
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Send delivery ACK asynchronously
|
|
48
|
+
if let messageId = userInfo["gcm.message_id"] as? String {
|
|
49
|
+
NSLog("[SwanSDK Extension] Sending delivery ACK for messageId: \(messageId)")
|
|
50
|
+
sendDeliveryACK(messageId: messageId)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Handle rich media (images)
|
|
54
|
+
if let fcmOptions = userInfo["fcm_options"] as? [String: Any],
|
|
55
|
+
let imageURLString = fcmOptions["image"] as? String,
|
|
56
|
+
let imageURL = URL(string: imageURLString)
|
|
57
|
+
{
|
|
58
|
+
NSLog("[SwanSDK Extension] Downloading notification image: \(imageURLString)")
|
|
59
|
+
downloadImage(from: imageURL) { attachment in
|
|
60
|
+
if let attachment = attachment {
|
|
61
|
+
NSLog("[SwanSDK Extension] ✅ Image downloaded successfully")
|
|
62
|
+
bestAttemptContent.attachments.append(attachment)
|
|
63
|
+
} else {
|
|
64
|
+
NSLog("[SwanSDK Extension] ❌ Failed to download image")
|
|
65
|
+
}
|
|
66
|
+
contentHandler(bestAttemptContent)
|
|
67
|
+
}
|
|
68
|
+
} else {
|
|
69
|
+
// No image to download, deliver notification immediately
|
|
70
|
+
NSLog("[SwanSDK Extension] No image to download, delivering notification")
|
|
71
|
+
contentHandler(bestAttemptContent)
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
override func serviceExtensionTimeWillExpire() {
|
|
77
|
+
// Called just before the extension will be terminated by the system.
|
|
78
|
+
// Use this as an opportunity to deliver your "best attempt" at modified content.
|
|
79
|
+
NSLog("[SwanSDK Extension] Service extension time will expire")
|
|
80
|
+
if let contentHandler = contentHandler, let bestAttemptContent = bestAttemptContent {
|
|
81
|
+
contentHandler(bestAttemptContent)
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// MARK: - Delivery ACK
|
|
86
|
+
|
|
87
|
+
private func sendDeliveryACK(messageId: String) {
|
|
88
|
+
// Read credentials from shared App Group
|
|
89
|
+
guard let credentials = readCredentials() else {
|
|
90
|
+
NSLog("[SwanSDK Extension] ❌ Failed to read credentials from App Group")
|
|
91
|
+
return
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
NSLog("[SwanSDK Extension] Credentials loaded - appId: \(credentials.appId)")
|
|
95
|
+
|
|
96
|
+
// Construct ACK payload
|
|
97
|
+
let payload: [String: Any] = [
|
|
98
|
+
"commId": messageId,
|
|
99
|
+
"appId": credentials.appId,
|
|
100
|
+
"deviceId": credentials.deviceId,
|
|
101
|
+
"event": "delivered",
|
|
102
|
+
]
|
|
103
|
+
|
|
104
|
+
// Add CDID if available (user logged in)
|
|
105
|
+
var finalPayload = payload
|
|
106
|
+
if let cdid = credentials.cdid, !cdid.isEmpty {
|
|
107
|
+
finalPayload["CDID"] = cdid
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
NSLog("[SwanSDK Extension] ACK payload: \(finalPayload)")
|
|
111
|
+
|
|
112
|
+
// Send ACK to backend
|
|
113
|
+
guard let url = URL(string: credentials.ackUrl) else {
|
|
114
|
+
NSLog("[SwanSDK Extension] ❌ Invalid ACK URL")
|
|
115
|
+
return
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
var request = URLRequest(url: url)
|
|
119
|
+
request.httpMethod = "POST"
|
|
120
|
+
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
|
|
121
|
+
request.setValue(credentials.deviceId, forHTTPHeaderField: "X-Swan-Device-Id")
|
|
122
|
+
|
|
123
|
+
do {
|
|
124
|
+
request.httpBody = try JSONSerialization.data(withJSONObject: finalPayload)
|
|
125
|
+
} catch {
|
|
126
|
+
NSLog("[SwanSDK Extension] ❌ Failed to serialize ACK payload: \(error)")
|
|
127
|
+
return
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// Send request
|
|
131
|
+
let task = URLSession.shared.dataTask(with: request) { data, response, error in
|
|
132
|
+
if let error = error {
|
|
133
|
+
NSLog("[SwanSDK Extension] ❌ ACK request failed: \(error.localizedDescription)")
|
|
134
|
+
return
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
if let httpResponse = response as? HTTPURLResponse {
|
|
138
|
+
NSLog("[SwanSDK Extension] ACK response status: \(httpResponse.statusCode)")
|
|
139
|
+
if httpResponse.statusCode == 200 {
|
|
140
|
+
NSLog("[SwanSDK Extension] ✅ Delivery ACK sent successfully")
|
|
141
|
+
} else {
|
|
142
|
+
NSLog("[SwanSDK Extension] ⚠️ ACK request returned non-200 status")
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
task.resume()
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// MARK: - Extension State Management
|
|
150
|
+
|
|
151
|
+
private func markExtensionActive() {
|
|
152
|
+
let appGroupId = "group.swan.sdk.notifications"
|
|
153
|
+
guard let sharedDefaults = UserDefaults(suiteName: appGroupId) else {
|
|
154
|
+
NSLog("[SwanSDK Extension] ⚠️ Failed to mark extension active")
|
|
155
|
+
return
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// Set flag to indicate Notification Service Extension is active
|
|
159
|
+
// React Native checks this flag to skip delivery ACKs (since NES handles them)
|
|
160
|
+
sharedDefaults.set("active", forKey: "swanNESActive")
|
|
161
|
+
sharedDefaults.synchronize()
|
|
162
|
+
|
|
163
|
+
NSLog("[SwanSDK Extension] ✅ Marked extension as active")
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// MARK: - Credential Storage
|
|
167
|
+
|
|
168
|
+
private struct SwanCredentials {
|
|
169
|
+
let appId: String
|
|
170
|
+
let deviceId: String
|
|
171
|
+
let cdid: String?
|
|
172
|
+
let ackUrl: String
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
private func readCredentials() -> SwanCredentials? {
|
|
176
|
+
// IMPORTANT: App Group ID must match what's configured in the main app
|
|
177
|
+
// Default: group.swan.sdk.notifications
|
|
178
|
+
// Can be customized by developer during setup
|
|
179
|
+
let appGroupId = "group.swan.sdk.notifications"
|
|
180
|
+
|
|
181
|
+
guard let sharedDefaults = UserDefaults(suiteName: appGroupId) else {
|
|
182
|
+
NSLog("[SwanSDK Extension] ❌ Failed to access App Group: \(appGroupId)")
|
|
183
|
+
NSLog("[SwanSDK Extension] Make sure App Group is configured in both app and extension")
|
|
184
|
+
return nil
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
guard let credentialsString = sharedDefaults.string(forKey: "swanCredentials") else {
|
|
188
|
+
NSLog("[SwanSDK Extension] ❌ No credentials found in App Group")
|
|
189
|
+
return nil
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// Decode base64 credentials
|
|
193
|
+
guard let credentialsData = Data(base64Encoded: credentialsString),
|
|
194
|
+
let credentialsDict = try? JSONSerialization.jsonObject(with: credentialsData)
|
|
195
|
+
as? [String: String]
|
|
196
|
+
else {
|
|
197
|
+
NSLog("[SwanSDK Extension] ❌ Failed to decode credentials")
|
|
198
|
+
return nil
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
guard let appId = credentialsDict["appId"],
|
|
202
|
+
let deviceId = credentialsDict["deviceId"]
|
|
203
|
+
else {
|
|
204
|
+
NSLog("[SwanSDK Extension] ❌ Missing required credentials (appId or deviceId)")
|
|
205
|
+
return nil
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
guard let ackUrl = credentialsDict["ackUrl"] else {
|
|
209
|
+
NSLog("[SwanSDK Extension] ❌ Missing required credentials (ackUrl)")
|
|
210
|
+
return nil
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
let cdid = credentialsDict["cdid"]
|
|
214
|
+
return SwanCredentials(appId: appId, deviceId: deviceId, cdid: cdid, ackUrl: ackUrl)
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
// MARK: - Image Download
|
|
218
|
+
|
|
219
|
+
private func downloadImage(
|
|
220
|
+
from url: URL, completion: @escaping (UNNotificationAttachment?) -> Void
|
|
221
|
+
) {
|
|
222
|
+
let task = URLSession.shared.downloadTask(with: url) { location, response, error in
|
|
223
|
+
if let error = error {
|
|
224
|
+
NSLog("[SwanSDK Extension] Image download error: \(error.localizedDescription)")
|
|
225
|
+
completion(nil)
|
|
226
|
+
return
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
guard let location = location else {
|
|
230
|
+
NSLog("[SwanSDK Extension] No file location for downloaded image")
|
|
231
|
+
completion(nil)
|
|
232
|
+
return
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
// Determine file extension and UTI type
|
|
236
|
+
var pathExtension = "jpg"
|
|
237
|
+
var utiType = "public.jpeg"
|
|
238
|
+
|
|
239
|
+
if let mimeType = response?.mimeType {
|
|
240
|
+
NSLog("[SwanSDK Extension] Image MIME type: \(mimeType)")
|
|
241
|
+
switch mimeType {
|
|
242
|
+
case "image/jpeg", "image/jpg":
|
|
243
|
+
pathExtension = "jpg"
|
|
244
|
+
utiType = "public.jpeg"
|
|
245
|
+
case "image/png":
|
|
246
|
+
pathExtension = "png"
|
|
247
|
+
utiType = "public.png"
|
|
248
|
+
case "image/gif":
|
|
249
|
+
pathExtension = "gif"
|
|
250
|
+
utiType = "com.compuserve.gif"
|
|
251
|
+
default:
|
|
252
|
+
// Try to get extension from URL
|
|
253
|
+
let urlExt = url.pathExtension.lowercased()
|
|
254
|
+
if urlExt == "png" {
|
|
255
|
+
pathExtension = "png"
|
|
256
|
+
utiType = "public.png"
|
|
257
|
+
} else if urlExt == "gif" {
|
|
258
|
+
pathExtension = "gif"
|
|
259
|
+
utiType = "com.compuserve.gif"
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
} else {
|
|
263
|
+
// Fallback to URL extension
|
|
264
|
+
let urlExt = url.pathExtension.lowercased()
|
|
265
|
+
if urlExt == "png" {
|
|
266
|
+
pathExtension = "png"
|
|
267
|
+
utiType = "public.png"
|
|
268
|
+
} else if urlExt == "gif" {
|
|
269
|
+
pathExtension = "gif"
|
|
270
|
+
utiType = "com.compuserve.gif"
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
NSLog("[SwanSDK Extension] Using extension: \(pathExtension), UTI: \(utiType)")
|
|
275
|
+
|
|
276
|
+
// Use FileManager to get the cache directory for the extension
|
|
277
|
+
// This is more reliable than NSTemporaryDirectory for notification extensions
|
|
278
|
+
let fileManager = FileManager.default
|
|
279
|
+
guard
|
|
280
|
+
let cacheDirectory = fileManager.urls(for: .cachesDirectory, in: .userDomainMask)
|
|
281
|
+
.first
|
|
282
|
+
else {
|
|
283
|
+
NSLog("[SwanSDK Extension] Could not get cache directory")
|
|
284
|
+
completion(nil)
|
|
285
|
+
return
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
let uniqueId = UUID().uuidString
|
|
289
|
+
let destinationURL = cacheDirectory.appendingPathComponent(
|
|
290
|
+
"swan-notification-\(uniqueId).\(pathExtension)")
|
|
291
|
+
|
|
292
|
+
NSLog("[SwanSDK Extension] Destination URL: \(destinationURL.path)")
|
|
293
|
+
|
|
294
|
+
do {
|
|
295
|
+
// Remove existing file if it exists
|
|
296
|
+
if fileManager.fileExists(atPath: destinationURL.path) {
|
|
297
|
+
try fileManager.removeItem(at: destinationURL)
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
// Copy instead of move (more reliable)
|
|
301
|
+
try fileManager.copyItem(at: location, to: destinationURL)
|
|
302
|
+
|
|
303
|
+
// Verify file exists and has content
|
|
304
|
+
let attributes = try fileManager.attributesOfItem(atPath: destinationURL.path)
|
|
305
|
+
let fileSize = attributes[.size] as? Int64 ?? 0
|
|
306
|
+
NSLog("[SwanSDK Extension] Image file size: \(fileSize) bytes")
|
|
307
|
+
|
|
308
|
+
if fileSize == 0 {
|
|
309
|
+
NSLog("[SwanSDK Extension] ❌ Downloaded file is empty!")
|
|
310
|
+
completion(nil)
|
|
311
|
+
return
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
// Create attachment with type hint options
|
|
315
|
+
let options: [String: Any] = [
|
|
316
|
+
UNNotificationAttachmentOptionsTypeHintKey: utiType
|
|
317
|
+
]
|
|
318
|
+
|
|
319
|
+
let attachment = try UNNotificationAttachment(
|
|
320
|
+
identifier: "swan-image-\(uniqueId)",
|
|
321
|
+
url: destinationURL,
|
|
322
|
+
options: options
|
|
323
|
+
)
|
|
324
|
+
|
|
325
|
+
NSLog("[SwanSDK Extension] ✅ Attachment created successfully")
|
|
326
|
+
completion(attachment)
|
|
327
|
+
} catch {
|
|
328
|
+
NSLog(
|
|
329
|
+
"[SwanSDK Extension] Failed to create attachment: \(error.localizedDescription)"
|
|
330
|
+
)
|
|
331
|
+
NSLog("[SwanSDK Extension] Error details: \(error)")
|
|
332
|
+
completion(nil)
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
task.resume()
|
|
336
|
+
}
|
|
337
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
3
|
+
<plist version="1.0">
|
|
4
|
+
<dict>
|
|
5
|
+
<key>com.apple.security.application-groups</key>
|
|
6
|
+
<array>
|
|
7
|
+
<string>group.swan.sdk.notifications</string>
|
|
8
|
+
</array>
|
|
9
|
+
</dict>
|
|
10
|
+
</plist>
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _reactNative = require("react-native");
|
|
8
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
9
|
+
const {
|
|
10
|
+
width: screenWidth,
|
|
11
|
+
height: screenHeight
|
|
12
|
+
} = _reactNative.Dimensions.get('window');
|
|
13
|
+
const FooterNotification = ({
|
|
14
|
+
designConfig,
|
|
15
|
+
onClose,
|
|
16
|
+
onButtonClick
|
|
17
|
+
}) => {
|
|
18
|
+
const {
|
|
19
|
+
commId = '',
|
|
20
|
+
themeBackgroundColor = '#ffffff',
|
|
21
|
+
crossButtonColor = '#000000',
|
|
22
|
+
iconURL = null,
|
|
23
|
+
descriptionColor = '#000000',
|
|
24
|
+
description = 'Default description.',
|
|
25
|
+
onClickAction,
|
|
26
|
+
onClickActionType
|
|
27
|
+
} = designConfig;
|
|
28
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.TouchableOpacity, {
|
|
29
|
+
style: [styles.notification, {
|
|
30
|
+
backgroundColor: themeBackgroundColor
|
|
31
|
+
}],
|
|
32
|
+
onPress: () => {
|
|
33
|
+
onButtonClick({
|
|
34
|
+
type: 'primary',
|
|
35
|
+
event: 'clicked',
|
|
36
|
+
action: onClickAction,
|
|
37
|
+
actionType: onClickActionType,
|
|
38
|
+
commId
|
|
39
|
+
});
|
|
40
|
+
},
|
|
41
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TouchableOpacity, {
|
|
42
|
+
onPress: onClose,
|
|
43
|
+
style: styles.closeButton,
|
|
44
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
45
|
+
style: [styles.closeIcon, {
|
|
46
|
+
color: crossButtonColor
|
|
47
|
+
}],
|
|
48
|
+
children: "\xD7"
|
|
49
|
+
})
|
|
50
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
51
|
+
style: styles.content,
|
|
52
|
+
children: [iconURL && /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
53
|
+
style: styles.iconContainer,
|
|
54
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Image, {
|
|
55
|
+
source: {
|
|
56
|
+
uri: iconURL
|
|
57
|
+
},
|
|
58
|
+
style: styles.icon,
|
|
59
|
+
resizeMode: "cover"
|
|
60
|
+
})
|
|
61
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
62
|
+
style: [styles.description, {
|
|
63
|
+
color: descriptionColor
|
|
64
|
+
}],
|
|
65
|
+
numberOfLines: 3,
|
|
66
|
+
children: description
|
|
67
|
+
})]
|
|
68
|
+
})]
|
|
69
|
+
});
|
|
70
|
+
};
|
|
71
|
+
const styles = _reactNative.StyleSheet.create({
|
|
72
|
+
notification: {
|
|
73
|
+
position: 'absolute',
|
|
74
|
+
bottom: screenHeight * 0.05,
|
|
75
|
+
// Positioned 5% from the bottom of the screen
|
|
76
|
+
left: screenWidth * 0.05,
|
|
77
|
+
// Centered with 5% padding on each side
|
|
78
|
+
width: screenWidth * 0.9,
|
|
79
|
+
// 90% of screen width
|
|
80
|
+
padding: 16,
|
|
81
|
+
shadowColor: '#000',
|
|
82
|
+
shadowOffset: {
|
|
83
|
+
width: 0,
|
|
84
|
+
height: 4
|
|
85
|
+
},
|
|
86
|
+
shadowOpacity: 0.2,
|
|
87
|
+
shadowRadius: 6,
|
|
88
|
+
elevation: 4
|
|
89
|
+
},
|
|
90
|
+
closeButton: {
|
|
91
|
+
position: 'absolute',
|
|
92
|
+
right: 4
|
|
93
|
+
},
|
|
94
|
+
closeIcon: {
|
|
95
|
+
fontSize: 18,
|
|
96
|
+
fontWeight: 'bold'
|
|
97
|
+
},
|
|
98
|
+
content: {
|
|
99
|
+
flexDirection: 'row',
|
|
100
|
+
alignItems: 'center'
|
|
101
|
+
},
|
|
102
|
+
iconContainer: {
|
|
103
|
+
width: 48,
|
|
104
|
+
// Fixed size for icon
|
|
105
|
+
height: 48,
|
|
106
|
+
borderRadius: 24,
|
|
107
|
+
overflow: 'hidden',
|
|
108
|
+
backgroundColor: '#f0f0f0',
|
|
109
|
+
justifyContent: 'center',
|
|
110
|
+
alignItems: 'center',
|
|
111
|
+
marginRight: 12
|
|
112
|
+
},
|
|
113
|
+
icon: {
|
|
114
|
+
width: '100%',
|
|
115
|
+
height: '100%'
|
|
116
|
+
},
|
|
117
|
+
description: {
|
|
118
|
+
fontSize: 14,
|
|
119
|
+
lineHeight: 18,
|
|
120
|
+
flex: 1,
|
|
121
|
+
textAlign: 'left'
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
var _default = exports.default = FooterNotification;
|
|
125
|
+
//# sourceMappingURL=FooterView.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_jsxRuntime","width","screenWidth","height","screenHeight","Dimensions","get","FooterNotification","designConfig","onClose","onButtonClick","commId","themeBackgroundColor","crossButtonColor","iconURL","descriptionColor","description","onClickAction","onClickActionType","jsxs","TouchableOpacity","style","styles","notification","backgroundColor","onPress","type","event","action","actionType","children","jsx","closeButton","Text","closeIcon","color","View","content","iconContainer","Image","source","uri","icon","resizeMode","numberOfLines","StyleSheet","create","position","bottom","left","padding","shadowColor","shadowOffset","shadowOpacity","shadowRadius","elevation","right","fontSize","fontWeight","flexDirection","alignItems","borderRadius","overflow","justifyContent","marginRight","lineHeight","flex","textAlign","_default","exports","default"],"sourceRoot":"../../../src","sources":["components/FooterView.tsx"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAOsB,IAAAC,WAAA,GAAAD,OAAA;AAEtB,MAAM;EAAEE,KAAK,EAAEC,WAAW;EAAEC,MAAM,EAAEC;AA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EAAE;IACbrC,KAAK,EAAE,EAAE;IAAE;IACXE,MAAM,EAAE,EAAE;IACV0D,YAAY,EAAE,EAAE;IAChBC,QAAQ,EAAE,QAAQ;IAClBtC,eAAe,EAAE,SAAS;IAC1BuC,cAAc,EAAE,QAAQ;IACxBH,UAAU,EAAE,QAAQ;IACpBI,WAAW,EAAE;EACf,CAAC;EACDtB,IAAI,EAAE;IACJzC,KAAK,EAAE,MAAM;IACbE,MAAM,EAAE;EACV,CAAC;EACDa,WAAW,EAAE;IACXyC,QAAQ,EAAE,EAAE;IACZQ,UAAU,EAAE,EAAE;IACdC,IAAI,EAAE,CAAC;IACPC,SAAS,EAAE;EACb;AACF,CAAC,CAAC;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEY/D,kBAAkB","ignoreList":[]}
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _reactNative = require("react-native");
|
|
8
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
9
|
+
/* eslint-disable react-native/no-inline-styles */
|
|
10
|
+
|
|
11
|
+
const FullScreenView = ({
|
|
12
|
+
designConfig,
|
|
13
|
+
onClose,
|
|
14
|
+
onButtonClick
|
|
15
|
+
}) => {
|
|
16
|
+
const {
|
|
17
|
+
commId = '',
|
|
18
|
+
backgroundImageURL,
|
|
19
|
+
crossButtonColor,
|
|
20
|
+
primaryButtonColor,
|
|
21
|
+
primaryButtonFontColor,
|
|
22
|
+
primaryButtonSwitch,
|
|
23
|
+
primaryButtonText,
|
|
24
|
+
primaryButtonAction = '',
|
|
25
|
+
primaryButtonActionType = '',
|
|
26
|
+
secondaryButtonColor,
|
|
27
|
+
secondaryButtonFontColor,
|
|
28
|
+
secondaryButtonSwitch,
|
|
29
|
+
secondaryButtonText,
|
|
30
|
+
secondaryButtonAction = '',
|
|
31
|
+
secondaryButtonActionType = ''
|
|
32
|
+
} = designConfig;
|
|
33
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
34
|
+
style: [styles.notification, {
|
|
35
|
+
backgroundColor: 'steelblue' // You can replace this with a dynamic value if needed
|
|
36
|
+
}],
|
|
37
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
38
|
+
style: styles.backgroundContainer,
|
|
39
|
+
children: backgroundImageURL && /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Image, {
|
|
40
|
+
source: {
|
|
41
|
+
uri: backgroundImageURL
|
|
42
|
+
},
|
|
43
|
+
style: styles.backgroundImage,
|
|
44
|
+
resizeMode: "stretch"
|
|
45
|
+
})
|
|
46
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
47
|
+
style: styles.foreground,
|
|
48
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TouchableOpacity, {
|
|
49
|
+
onPress: onClose,
|
|
50
|
+
style: styles.closeButton,
|
|
51
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
52
|
+
style: [styles.closeIcon, {
|
|
53
|
+
color: crossButtonColor
|
|
54
|
+
}],
|
|
55
|
+
children: "\xD7"
|
|
56
|
+
})
|
|
57
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
58
|
+
style: styles.buttonContainer,
|
|
59
|
+
children: [primaryButtonSwitch && /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TouchableOpacity, {
|
|
60
|
+
onPress: () => {
|
|
61
|
+
onButtonClick({
|
|
62
|
+
type: 'primary',
|
|
63
|
+
event: 'clicked',
|
|
64
|
+
action: primaryButtonAction,
|
|
65
|
+
actionType: primaryButtonActionType,
|
|
66
|
+
commId
|
|
67
|
+
});
|
|
68
|
+
},
|
|
69
|
+
style: [styles.button, {
|
|
70
|
+
backgroundColor: primaryButtonColor,
|
|
71
|
+
marginRight: secondaryButtonSwitch ? 15 : 0
|
|
72
|
+
}],
|
|
73
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
74
|
+
style: {
|
|
75
|
+
color: primaryButtonFontColor
|
|
76
|
+
},
|
|
77
|
+
children: primaryButtonText
|
|
78
|
+
})
|
|
79
|
+
}), secondaryButtonSwitch && /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TouchableOpacity, {
|
|
80
|
+
onPress: () => {
|
|
81
|
+
onButtonClick({
|
|
82
|
+
type: 'secondary',
|
|
83
|
+
event: 'clicked',
|
|
84
|
+
action: secondaryButtonAction,
|
|
85
|
+
actionType: secondaryButtonActionType,
|
|
86
|
+
commId
|
|
87
|
+
});
|
|
88
|
+
},
|
|
89
|
+
style: [styles.button, {
|
|
90
|
+
backgroundColor: secondaryButtonColor
|
|
91
|
+
}],
|
|
92
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
93
|
+
style: {
|
|
94
|
+
color: secondaryButtonFontColor
|
|
95
|
+
},
|
|
96
|
+
children: secondaryButtonText
|
|
97
|
+
})
|
|
98
|
+
})]
|
|
99
|
+
})]
|
|
100
|
+
})]
|
|
101
|
+
});
|
|
102
|
+
};
|
|
103
|
+
const styles = _reactNative.StyleSheet.create({
|
|
104
|
+
notification: {
|
|
105
|
+
borderRadius: 10,
|
|
106
|
+
overflow: 'hidden',
|
|
107
|
+
position: 'absolute',
|
|
108
|
+
flexDirection: 'column',
|
|
109
|
+
width: '90%',
|
|
110
|
+
top: '5%',
|
|
111
|
+
// Approx. 2.5% from the top
|
|
112
|
+
height: '92%',
|
|
113
|
+
backgroundColor: 'steelblue' // Can be customized if necessary
|
|
114
|
+
},
|
|
115
|
+
backgroundContainer: {
|
|
116
|
+
position: 'absolute',
|
|
117
|
+
top: 0,
|
|
118
|
+
zIndex: 0,
|
|
119
|
+
width: '100%',
|
|
120
|
+
height: '100%'
|
|
121
|
+
},
|
|
122
|
+
backgroundImage: {
|
|
123
|
+
width: '100%',
|
|
124
|
+
height: '100%'
|
|
125
|
+
},
|
|
126
|
+
placeholderImage: {
|
|
127
|
+
height: 50,
|
|
128
|
+
// Approx. 5rem
|
|
129
|
+
width: 50,
|
|
130
|
+
// Approx. 5rem
|
|
131
|
+
transform: [{
|
|
132
|
+
translateX: 130
|
|
133
|
+
}, {
|
|
134
|
+
translateY: 250
|
|
135
|
+
}] // Approx. (13rem, 25rem)
|
|
136
|
+
},
|
|
137
|
+
foreground: {
|
|
138
|
+
zIndex: 1,
|
|
139
|
+
position: 'absolute',
|
|
140
|
+
width: '100%',
|
|
141
|
+
height: '100%',
|
|
142
|
+
justifyContent: 'flex-end',
|
|
143
|
+
alignItems: 'center',
|
|
144
|
+
paddingBottom: 20
|
|
145
|
+
},
|
|
146
|
+
closeButton: {
|
|
147
|
+
position: 'absolute',
|
|
148
|
+
top: 10,
|
|
149
|
+
right: 10
|
|
150
|
+
},
|
|
151
|
+
closeIcon: {
|
|
152
|
+
fontSize: 30,
|
|
153
|
+
fontWeight: 'bold'
|
|
154
|
+
},
|
|
155
|
+
buttonContainer: {
|
|
156
|
+
flexDirection: 'row',
|
|
157
|
+
position: 'absolute',
|
|
158
|
+
bottom: '5%',
|
|
159
|
+
// Approx. 89% from the top
|
|
160
|
+
left: '5%',
|
|
161
|
+
width: '90%',
|
|
162
|
+
justifyContent: 'space-between'
|
|
163
|
+
},
|
|
164
|
+
button: {
|
|
165
|
+
flex: 1,
|
|
166
|
+
padding: 10,
|
|
167
|
+
justifyContent: 'center',
|
|
168
|
+
alignItems: 'center'
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
var _default = exports.default = FullScreenView;
|
|
172
|
+
//# sourceMappingURL=FullScreenView.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_jsxRuntime","FullScreenView","designConfig","onClose","onButtonClick","commId","backgroundImageURL","crossButtonColor","primaryButtonColor","primaryButtonFontColor","primaryButtonSwitch","primaryButtonText","primaryButtonAction","primaryButtonActionType","secondaryButtonColor","secondaryButtonFontColor","secondaryButtonSwitch","secondaryButtonText","secondaryButtonAction","secondaryButtonActionType","jsxs","View","style","styles","notification","backgroundColor","children","jsx","backgroundContainer","Image","source","uri","backgroundImage","resizeMode","foreground","TouchableOpacity","onPress","closeButton","Text","closeIcon","color","buttonContainer","type","event","action","actionType","button","marginRight","StyleSheet","create","borderRadius","overflow","position","flexDirection","width","top","height","zIndex","placeholderImage","transform","translateX","translateY","justifyContent","alignItems","paddingBottom","right","fontSize","fontWeight","bottom","left","flex","padding","_default","exports","default"],"sourceRoot":"../../../src","sources":["components/FullScreenView.tsx"],"mappings":";;;;;;AACA,IAAAA,YAAA,GAAAC,OAAA;AAA+E,IAAAC,WAAA,GAAAD,OAAA;AAD/E;;AAGA,MAAME,cAAc,GAAGA,CAAC;EAAEC,YAAY;EAAEC,OAAO;EAAEC;AAAmB,CAAC,KAAK;EACxE,MAAM;IACJC,MAAM,GAAG,EAAE;IACXC,kBAAkB;IAClBC,gBAAgB;IAChBC,kBAAkB;IAClBC,sBAAsB;IACtBC,mBAAmB;IACnBC,iBAAiB;IACjBC,mBAAmB,GAAG,EAAE;IACxBC,uBAAuB,GAAG,EAAE;IAC5BC,oBAAoB;IACpBC,wBAAwB;IACxBC,qBAAqB;IACrBC,mBAAmB;IACnBC,qBAAqB,GAAG,EAAE;IAC1BC,yBAAyB,GAAG;EAC9B,CAAC,GAAGjB,YAAY;EAEhB,oBACE,IAAAF,WAAA,CAAAoB,IAAA,EAACtB,YAAA,CAAAuB,IAAI;IACHC,KAAK,EAAE,CACLC,MAAM,CAACC,YAAY,EACnB;MACEC,eAAe,EAAE,WAAW,CAAE;IAChC,CAAC,CACD;IAAAC,QAAA,gBAGF,IAAA1B,WAAA,CAAA2B,GAAA,EAAC7B,YAAA,CAAAuB,I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