@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.
Files changed (204) hide show
  1. package/LICENSE +55 -0
  2. package/README.md +67 -0
  3. package/docs/IOS_NOTIFICATION_EXTENSION_SETUP.md +335 -0
  4. package/ios/README.md +64 -0
  5. package/ios/SwanNotificationServiceExtension/Info.plist +31 -0
  6. package/ios/SwanNotificationServiceExtension/NotificationService.swift +337 -0
  7. package/ios/SwanNotificationServiceExtension/SwanNotificationServiceExtension.entitlements +10 -0
  8. package/lib/commonjs/components/FooterView.js +125 -0
  9. package/lib/commonjs/components/FooterView.js.map +1 -0
  10. package/lib/commonjs/components/FullScreenView.js +172 -0
  11. package/lib/commonjs/components/FullScreenView.js.map +1 -0
  12. package/lib/commonjs/components/HeaderView.js +205 -0
  13. package/lib/commonjs/components/HeaderView.js.map +1 -0
  14. package/lib/commonjs/components/PopUpView.js +186 -0
  15. package/lib/commonjs/components/PopUpView.js.map +1 -0
  16. package/lib/commonjs/config/BatchConfig.js +53 -0
  17. package/lib/commonjs/config/BatchConfig.js.map +1 -0
  18. package/lib/commonjs/constants/ApiUrls.js +56 -0
  19. package/lib/commonjs/constants/ApiUrls.js.map +1 -0
  20. package/lib/commonjs/core/EventQueueManager.js +345 -0
  21. package/lib/commonjs/core/EventQueueManager.js.map +1 -0
  22. package/lib/commonjs/core/FlushManager.js +245 -0
  23. package/lib/commonjs/core/FlushManager.js.map +1 -0
  24. package/lib/commonjs/core/NetworkMonitor.js +97 -0
  25. package/lib/commonjs/core/NetworkMonitor.js.map +1 -0
  26. package/lib/commonjs/index.js +3506 -0
  27. package/lib/commonjs/index.js.map +1 -0
  28. package/lib/commonjs/providers/FirebasePushProvider.js +130 -0
  29. package/lib/commonjs/providers/FirebasePushProvider.js.map +1 -0
  30. package/lib/commonjs/providers/NullPushProvider.js +59 -0
  31. package/lib/commonjs/providers/NullPushProvider.js.map +1 -0
  32. package/lib/commonjs/providers/PushNotificationProvider.js +30 -0
  33. package/lib/commonjs/providers/PushNotificationProvider.js.map +1 -0
  34. package/lib/commonjs/services/DeviceRegistrationService.js +248 -0
  35. package/lib/commonjs/services/DeviceRegistrationService.js.map +1 -0
  36. package/lib/commonjs/services/PushTokenService.js +284 -0
  37. package/lib/commonjs/services/PushTokenService.js.map +1 -0
  38. package/lib/commonjs/state/AuthStateMachine.js +161 -0
  39. package/lib/commonjs/state/AuthStateMachine.js.map +1 -0
  40. package/lib/commonjs/state/DeviceStateMachine.js +104 -0
  41. package/lib/commonjs/state/DeviceStateMachine.js.map +1 -0
  42. package/lib/commonjs/state/PushStateMachine.js +129 -0
  43. package/lib/commonjs/state/PushStateMachine.js.map +1 -0
  44. package/lib/commonjs/types/EventQueue.js +50 -0
  45. package/lib/commonjs/types/EventQueue.js.map +1 -0
  46. package/lib/commonjs/types/SDK.js +2 -0
  47. package/lib/commonjs/types/SDK.js.map +1 -0
  48. package/lib/commonjs/utils/FirebaseNotificationManager.js +492 -0
  49. package/lib/commonjs/utils/FirebaseNotificationManager.js.map +1 -0
  50. package/lib/commonjs/utils/Logger.js +56 -0
  51. package/lib/commonjs/utils/Logger.js.map +1 -0
  52. package/lib/commonjs/utils/SharedCredentialsManager.js +146 -0
  53. package/lib/commonjs/utils/SharedCredentialsManager.js.map +1 -0
  54. package/lib/commonjs/version.js +12 -0
  55. package/lib/commonjs/version.js.map +1 -0
  56. package/lib/module/components/FooterView.js +121 -0
  57. package/lib/module/components/FooterView.js.map +1 -0
  58. package/lib/module/components/FullScreenView.js +167 -0
  59. package/lib/module/components/FullScreenView.js.map +1 -0
  60. package/lib/module/components/HeaderView.js +199 -0
  61. package/lib/module/components/HeaderView.js.map +1 -0
  62. package/lib/module/components/PopUpView.js +181 -0
  63. package/lib/module/components/PopUpView.js.map +1 -0
  64. package/lib/module/config/BatchConfig.js +49 -0
  65. package/lib/module/config/BatchConfig.js.map +1 -0
  66. package/lib/module/constants/ApiUrls.js +52 -0
  67. package/lib/module/constants/ApiUrls.js.map +1 -0
  68. package/lib/module/core/EventQueueManager.js +340 -0
  69. package/lib/module/core/EventQueueManager.js.map +1 -0
  70. package/lib/module/core/FlushManager.js +240 -0
  71. package/lib/module/core/FlushManager.js.map +1 -0
  72. package/lib/module/core/NetworkMonitor.js +92 -0
  73. package/lib/module/core/NetworkMonitor.js.map +1 -0
  74. package/lib/module/index.js +3494 -0
  75. package/lib/module/index.js.map +1 -0
  76. package/lib/module/providers/FirebasePushProvider.js +124 -0
  77. package/lib/module/providers/FirebasePushProvider.js.map +1 -0
  78. package/lib/module/providers/NullPushProvider.js +53 -0
  79. package/lib/module/providers/NullPushProvider.js.map +1 -0
  80. package/lib/module/providers/PushNotificationProvider.js +26 -0
  81. package/lib/module/providers/PushNotificationProvider.js.map +1 -0
  82. package/lib/module/services/DeviceRegistrationService.js +243 -0
  83. package/lib/module/services/DeviceRegistrationService.js.map +1 -0
  84. package/lib/module/services/PushTokenService.js +278 -0
  85. package/lib/module/services/PushTokenService.js.map +1 -0
  86. package/lib/module/state/AuthStateMachine.js +155 -0
  87. package/lib/module/state/AuthStateMachine.js.map +1 -0
  88. package/lib/module/state/DeviceStateMachine.js +98 -0
  89. package/lib/module/state/DeviceStateMachine.js.map +1 -0
  90. package/lib/module/state/PushStateMachine.js +123 -0
  91. package/lib/module/state/PushStateMachine.js.map +1 -0
  92. package/lib/module/types/EventQueue.js +46 -0
  93. package/lib/module/types/EventQueue.js.map +1 -0
  94. package/lib/module/types/SDK.js +2 -0
  95. package/lib/module/types/SDK.js.map +1 -0
  96. package/lib/module/utils/FirebaseNotificationManager.js +486 -0
  97. package/lib/module/utils/FirebaseNotificationManager.js.map +1 -0
  98. package/lib/module/utils/Logger.js +52 -0
  99. package/lib/module/utils/Logger.js.map +1 -0
  100. package/lib/module/utils/SharedCredentialsManager.js +140 -0
  101. package/lib/module/utils/SharedCredentialsManager.js.map +1 -0
  102. package/lib/module/version.js +8 -0
  103. package/lib/module/version.js.map +1 -0
  104. package/lib/typescript/commonjs/package.json +1 -0
  105. package/lib/typescript/commonjs/src/components/FooterView.d.ts +3 -0
  106. package/lib/typescript/commonjs/src/components/FooterView.d.ts.map +1 -0
  107. package/lib/typescript/commonjs/src/components/FullScreenView.d.ts +3 -0
  108. package/lib/typescript/commonjs/src/components/FullScreenView.d.ts.map +1 -0
  109. package/lib/typescript/commonjs/src/components/HeaderView.d.ts +3 -0
  110. package/lib/typescript/commonjs/src/components/HeaderView.d.ts.map +1 -0
  111. package/lib/typescript/commonjs/src/components/PopUpView.d.ts +3 -0
  112. package/lib/typescript/commonjs/src/components/PopUpView.d.ts.map +1 -0
  113. package/lib/typescript/commonjs/src/config/BatchConfig.d.ts +7 -0
  114. package/lib/typescript/commonjs/src/config/BatchConfig.d.ts.map +1 -0
  115. package/lib/typescript/commonjs/src/constants/ApiUrls.d.ts +56 -0
  116. package/lib/typescript/commonjs/src/constants/ApiUrls.d.ts.map +1 -0
  117. package/lib/typescript/commonjs/src/core/EventQueueManager.d.ts +63 -0
  118. package/lib/typescript/commonjs/src/core/EventQueueManager.d.ts.map +1 -0
  119. package/lib/typescript/commonjs/src/core/FlushManager.d.ts +63 -0
  120. package/lib/typescript/commonjs/src/core/FlushManager.d.ts.map +1 -0
  121. package/lib/typescript/commonjs/src/core/NetworkMonitor.d.ts +38 -0
  122. package/lib/typescript/commonjs/src/core/NetworkMonitor.d.ts.map +1 -0
  123. package/lib/typescript/commonjs/src/index.d.ts +663 -0
  124. package/lib/typescript/commonjs/src/index.d.ts.map +1 -0
  125. package/lib/typescript/commonjs/src/providers/FirebasePushProvider.d.ts +28 -0
  126. package/lib/typescript/commonjs/src/providers/FirebasePushProvider.d.ts.map +1 -0
  127. package/lib/typescript/commonjs/src/providers/NullPushProvider.d.ts +25 -0
  128. package/lib/typescript/commonjs/src/providers/NullPushProvider.d.ts.map +1 -0
  129. package/lib/typescript/commonjs/src/providers/PushNotificationProvider.d.ts +105 -0
  130. package/lib/typescript/commonjs/src/providers/PushNotificationProvider.d.ts.map +1 -0
  131. package/lib/typescript/commonjs/src/services/DeviceRegistrationService.d.ts +60 -0
  132. package/lib/typescript/commonjs/src/services/DeviceRegistrationService.d.ts.map +1 -0
  133. package/lib/typescript/commonjs/src/services/PushTokenService.d.ts +82 -0
  134. package/lib/typescript/commonjs/src/services/PushTokenService.d.ts.map +1 -0
  135. package/lib/typescript/commonjs/src/state/AuthStateMachine.d.ts +61 -0
  136. package/lib/typescript/commonjs/src/state/AuthStateMachine.d.ts.map +1 -0
  137. package/lib/typescript/commonjs/src/state/DeviceStateMachine.d.ts +51 -0
  138. package/lib/typescript/commonjs/src/state/DeviceStateMachine.d.ts.map +1 -0
  139. package/lib/typescript/commonjs/src/state/PushStateMachine.d.ts +61 -0
  140. package/lib/typescript/commonjs/src/state/PushStateMachine.d.ts.map +1 -0
  141. package/lib/typescript/commonjs/src/types/EventQueue.d.ts +85 -0
  142. package/lib/typescript/commonjs/src/types/EventQueue.d.ts.map +1 -0
  143. package/lib/typescript/commonjs/src/types/SDK.d.ts +54 -0
  144. package/lib/typescript/commonjs/src/types/SDK.d.ts.map +1 -0
  145. package/lib/typescript/commonjs/src/utils/FirebaseNotificationManager.d.ts +169 -0
  146. package/lib/typescript/commonjs/src/utils/FirebaseNotificationManager.d.ts.map +1 -0
  147. package/lib/typescript/commonjs/src/utils/Logger.d.ts +32 -0
  148. package/lib/typescript/commonjs/src/utils/Logger.d.ts.map +1 -0
  149. package/lib/typescript/commonjs/src/utils/SharedCredentialsManager.d.ts +54 -0
  150. package/lib/typescript/commonjs/src/utils/SharedCredentialsManager.d.ts.map +1 -0
  151. package/lib/typescript/commonjs/src/version.d.ts +2 -0
  152. package/lib/typescript/commonjs/src/version.d.ts.map +1 -0
  153. package/lib/typescript/module/package.json +1 -0
  154. package/lib/typescript/module/src/components/FooterView.d.ts +3 -0
  155. package/lib/typescript/module/src/components/FooterView.d.ts.map +1 -0
  156. package/lib/typescript/module/src/components/FullScreenView.d.ts +3 -0
  157. package/lib/typescript/module/src/components/FullScreenView.d.ts.map +1 -0
  158. package/lib/typescript/module/src/components/HeaderView.d.ts +3 -0
  159. package/lib/typescript/module/src/components/HeaderView.d.ts.map +1 -0
  160. package/lib/typescript/module/src/components/PopUpView.d.ts +3 -0
  161. package/lib/typescript/module/src/components/PopUpView.d.ts.map +1 -0
  162. package/lib/typescript/module/src/config/BatchConfig.d.ts +7 -0
  163. package/lib/typescript/module/src/config/BatchConfig.d.ts.map +1 -0
  164. package/lib/typescript/module/src/constants/ApiUrls.d.ts +56 -0
  165. package/lib/typescript/module/src/constants/ApiUrls.d.ts.map +1 -0
  166. package/lib/typescript/module/src/core/EventQueueManager.d.ts +63 -0
  167. package/lib/typescript/module/src/core/EventQueueManager.d.ts.map +1 -0
  168. package/lib/typescript/module/src/core/FlushManager.d.ts +63 -0
  169. package/lib/typescript/module/src/core/FlushManager.d.ts.map +1 -0
  170. package/lib/typescript/module/src/core/NetworkMonitor.d.ts +38 -0
  171. package/lib/typescript/module/src/core/NetworkMonitor.d.ts.map +1 -0
  172. package/lib/typescript/module/src/index.d.ts +663 -0
  173. package/lib/typescript/module/src/index.d.ts.map +1 -0
  174. package/lib/typescript/module/src/providers/FirebasePushProvider.d.ts +28 -0
  175. package/lib/typescript/module/src/providers/FirebasePushProvider.d.ts.map +1 -0
  176. package/lib/typescript/module/src/providers/NullPushProvider.d.ts +25 -0
  177. package/lib/typescript/module/src/providers/NullPushProvider.d.ts.map +1 -0
  178. package/lib/typescript/module/src/providers/PushNotificationProvider.d.ts +105 -0
  179. package/lib/typescript/module/src/providers/PushNotificationProvider.d.ts.map +1 -0
  180. package/lib/typescript/module/src/services/DeviceRegistrationService.d.ts +60 -0
  181. package/lib/typescript/module/src/services/DeviceRegistrationService.d.ts.map +1 -0
  182. package/lib/typescript/module/src/services/PushTokenService.d.ts +82 -0
  183. package/lib/typescript/module/src/services/PushTokenService.d.ts.map +1 -0
  184. package/lib/typescript/module/src/state/AuthStateMachine.d.ts +61 -0
  185. package/lib/typescript/module/src/state/AuthStateMachine.d.ts.map +1 -0
  186. package/lib/typescript/module/src/state/DeviceStateMachine.d.ts +51 -0
  187. package/lib/typescript/module/src/state/DeviceStateMachine.d.ts.map +1 -0
  188. package/lib/typescript/module/src/state/PushStateMachine.d.ts +61 -0
  189. package/lib/typescript/module/src/state/PushStateMachine.d.ts.map +1 -0
  190. package/lib/typescript/module/src/types/EventQueue.d.ts +85 -0
  191. package/lib/typescript/module/src/types/EventQueue.d.ts.map +1 -0
  192. package/lib/typescript/module/src/types/SDK.d.ts +54 -0
  193. package/lib/typescript/module/src/types/SDK.d.ts.map +1 -0
  194. package/lib/typescript/module/src/utils/FirebaseNotificationManager.d.ts +169 -0
  195. package/lib/typescript/module/src/utils/FirebaseNotificationManager.d.ts.map +1 -0
  196. package/lib/typescript/module/src/utils/Logger.d.ts +32 -0
  197. package/lib/typescript/module/src/utils/Logger.d.ts.map +1 -0
  198. package/lib/typescript/module/src/utils/SharedCredentialsManager.d.ts +54 -0
  199. package/lib/typescript/module/src/utils/SharedCredentialsManager.d.ts.map +1 -0
  200. package/lib/typescript/module/src/version.d.ts +2 -0
  201. package/lib/typescript/module/src/version.d.ts.map +1 -0
  202. package/package.json +230 -0
  203. package/scripts/generate-version.js +25 -0
  204. package/scripts/setup-ios-extension.js +275 -0
@@ -0,0 +1,275 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Swan SDK - iOS Notification Service Extension Setup Script
5
+ *
6
+ * This script automates the setup of the Notification Service Extension for iOS.
7
+ * It:
8
+ * 1. Copies extension files to the iOS app directory
9
+ * 2. Generates setup instructions for Xcode configuration
10
+ * 3. Validates dependencies
11
+ *
12
+ * Usage:
13
+ * node node_modules/swan-react-native-sdk/scripts/setup-ios-extension.js
14
+ * OR
15
+ * npm run swan-setup-ios-extension
16
+ */
17
+
18
+ const fs = require('fs');
19
+ const path = require('path');
20
+
21
+ const colors = {
22
+ reset: '\x1b[0m',
23
+ bright: '\x1b[1m',
24
+ red: '\x1b[31m',
25
+ green: '\x1b[32m',
26
+ yellow: '\x1b[33m',
27
+ blue: '\x1b[34m',
28
+ cyan: '\x1b[36m',
29
+ };
30
+
31
+ function log(message, color = colors.reset) {
32
+ console.log(`${color}${message}${colors.reset}`);
33
+ }
34
+
35
+ function logSuccess(message) {
36
+ log(`✅ ${message}`, colors.green);
37
+ }
38
+
39
+ function logError(message) {
40
+ log(`❌ ${message}`, colors.red);
41
+ }
42
+
43
+ function logWarning(message) {
44
+ log(`⚠️ ${message}`, colors.yellow);
45
+ }
46
+
47
+ function logInfo(message) {
48
+ log(`ℹ️ ${message}`, colors.cyan);
49
+ }
50
+
51
+ function logStep(step, message) {
52
+ log(`\n${colors.bright}Step ${step}: ${message}${colors.reset}`);
53
+ }
54
+
55
+ function copyFileOrDirectory(src, dest) {
56
+ const stat = fs.statSync(src);
57
+
58
+ if (stat.isDirectory()) {
59
+ // Create directory if it doesn't exist
60
+ if (!fs.existsSync(dest)) {
61
+ fs.mkdirSync(dest, { recursive: true });
62
+ }
63
+
64
+ // Copy all files in directory
65
+ const files = fs.readdirSync(src);
66
+ files.forEach(file => {
67
+ const srcPath = path.join(src, file);
68
+ const destPath = path.join(dest, file);
69
+ copyFileOrDirectory(srcPath, destPath);
70
+ });
71
+ } else {
72
+ // Copy file
73
+ const destDir = path.dirname(dest);
74
+ if (!fs.existsSync(destDir)) {
75
+ fs.mkdirSync(destDir, { recursive: true });
76
+ }
77
+ fs.copyFileSync(src, dest);
78
+ }
79
+ }
80
+
81
+ // Main setup function
82
+ function setup() {
83
+ log('\n' + '='.repeat(60), colors.bright);
84
+ log('Swan SDK - iOS Notification Service Extension Setup', colors.bright);
85
+ log('='.repeat(60) + '\n', colors.bright);
86
+
87
+ // Step 1: Validate environment
88
+ logStep(1, 'Validating environment');
89
+
90
+ // Find project root
91
+ let projectRoot = process.cwd();
92
+
93
+ // Check if ios/ directory exists
94
+ const iosDir = path.join(projectRoot, 'ios');
95
+ if (!fs.existsSync(iosDir)) {
96
+ logError('iOS directory not found! This script must be run from a React Native project root.');
97
+ logError('Expected directory: ' + iosDir);
98
+ process.exit(1);
99
+ }
100
+ logSuccess('iOS directory found');
101
+
102
+ // Check if package.json exists
103
+ const packageJsonPath = path.join(projectRoot, 'package.json');
104
+ if (!fs.existsSync(packageJsonPath)) {
105
+ logError('package.json not found! Run this script from your project root.');
106
+ process.exit(1);
107
+ }
108
+
109
+ // Read package.json to get project name
110
+ const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
111
+ const projectName = packageJson.name;
112
+ logSuccess(`Project name: ${projectName}`);
113
+
114
+ // Find SDK directory
115
+ const sdkDir = path.join(projectRoot, 'node_modules', 'swan-react-native-sdk');
116
+ if (!fs.existsSync(sdkDir)) {
117
+ logError('swan-react-native-sdk not found in node_modules!');
118
+ logError('Make sure the SDK is installed: npm install swan-react-native-sdk');
119
+ process.exit(1);
120
+ }
121
+ logSuccess('Swan SDK found');
122
+
123
+ // Step 2: Check dependencies
124
+ logStep(2, 'Checking dependencies');
125
+
126
+ const dependencies = packageJson.dependencies || {};
127
+ const devDependencies = packageJson.devDependencies || {};
128
+ const allDeps = { ...dependencies, ...devDependencies };
129
+
130
+ const requiredDeps = {
131
+ 'react-native-shared-group-preferences': '^1.1.24',
132
+ };
133
+
134
+ const missingDeps = [];
135
+ for (const [dep, version] of Object.entries(requiredDeps)) {
136
+ if (!allDeps[dep]) {
137
+ missingDeps.push(`${dep}@${version}`);
138
+ } else {
139
+ logSuccess(`${dep} is installed`);
140
+ }
141
+ }
142
+
143
+ if (missingDeps.length > 0) {
144
+ logWarning('Missing required dependencies:');
145
+ missingDeps.forEach(dep => {
146
+ log(` - ${dep}`, colors.yellow);
147
+ });
148
+ logInfo('Install missing dependencies with:');
149
+ log(` npm install ${missingDeps.join(' ')}`, colors.cyan);
150
+ log('');
151
+ }
152
+
153
+ // Step 3: Copy extension files
154
+ logStep(3, 'Copying Notification Service Extension files');
155
+
156
+ const extensionSrcDir = path.join(sdkDir, 'ios', 'SwanNotificationServiceExtension');
157
+ const extensionDestDir = path.join(iosDir, 'SwanNotificationServiceExtension');
158
+
159
+ if (fs.existsSync(extensionDestDir)) {
160
+ logWarning('SwanNotificationServiceExtension directory already exists');
161
+ logInfo('Overwriting existing files...');
162
+ }
163
+
164
+ try {
165
+ copyFileOrDirectory(extensionSrcDir, extensionDestDir);
166
+ logSuccess('Extension files copied successfully');
167
+ logInfo(`Destination: ${extensionDestDir}`);
168
+ } catch (error) {
169
+ logError(`Failed to copy extension files: ${error.message}`);
170
+ process.exit(1);
171
+ }
172
+
173
+ // Step 4: Generate manual setup instructions
174
+ logStep(4, 'Setup Instructions');
175
+
176
+ log('\n' + '─'.repeat(60), colors.cyan);
177
+ log('IMPORTANT: Manual Xcode Configuration Required', colors.bright + colors.yellow);
178
+ log('─'.repeat(60) + '\n', colors.cyan);
179
+
180
+ log('The extension files have been copied to your ios/ directory.', colors.cyan);
181
+ log('You must now complete the setup in Xcode:\n');
182
+
183
+ const instructions = [
184
+ {
185
+ title: '1. Add Extension Target to Xcode (REQUIRED FIRST)',
186
+ steps: [
187
+ 'Open your project in Xcode: ios/*.xcworkspace',
188
+ 'In Xcode, go to File → New → Target',
189
+ 'Choose "Notification Service Extension"',
190
+ 'Product Name: SwanNotificationServiceExtension',
191
+ 'Language: Swift',
192
+ 'Click Finish',
193
+ 'When prompted "Activate scheme?", click "Cancel"',
194
+ 'STOP HERE: If you have not done this, the next steps will fail or be overwritten.',
195
+ ]
196
+ },
197
+ {
198
+ title: '2. Verify Files in Xcode Project',
199
+ steps: [
200
+ 'The script has copied the Swan implementation files to: ios/SwanNotificationServiceExtension/',
201
+ 'This should have overwritten the default files created by Xcode for the target.',
202
+ 'In Xcode Project Navigator, expand `SwanNotificationServiceExtension` folder.',
203
+ 'Verify that `NotificationService.swift`, `Info.plist`, and `SwanNotificationServiceExtension.entitlements` are present and contain the SwanSDK code.',
204
+ 'If any files are missing from the Xcode Project Navigator (even if they exist on disk), right-click on the `SwanNotificationServiceExtension` folder in Xcode and choose "Add Files to YourProject" to re-add them, making sure "Add to target: SwanNotificationServiceExtension" is checked and "Copy items if needed" is UNCHECKED.',
205
+ ]
206
+ },
207
+ {
208
+ title: '3. Configure App Groups',
209
+ steps: [
210
+ 'Select your main app target',
211
+ 'Go to "Signing & Capabilities" tab',
212
+ 'Click "+ Capability" and add "App Groups"',
213
+ 'Click "+" under App Groups and add: group.swan.sdk.notifications',
214
+ 'Now select SwanNotificationServiceExtension target',
215
+ 'Go to "Signing & Capabilities" tab',
216
+ 'Click "+ Capability" and add "App Groups"',
217
+ 'Click "+" under App Groups and add: group.swan.sdk.notifications',
218
+ '(IMPORTANT: Both targets must have the SAME App Group ID)',
219
+ ]
220
+ },
221
+ {
222
+ title: '4. Build and Test',
223
+ steps: [
224
+ 'Build your app: Product → Build (Cmd+B)',
225
+ 'Archive your app: Product → Archive',
226
+ 'Test on a REAL device (push doesn\'t work on simulator)',
227
+ 'Send a test notification and check Xcode console for logs',
228
+ 'Look for: [SwanSDK Extension] logs',
229
+ ]
230
+ }
231
+ ];
232
+
233
+ instructions.forEach((section, index) => {
234
+ log(`\n${colors.bright}${section.title}${colors.reset}`, colors.blue);
235
+ log('─'.repeat(60), colors.blue);
236
+ section.steps.forEach((step, stepIndex) => {
237
+ if (step.startsWith('{') || step.startsWith('[')) {
238
+ // JSON code block
239
+ log(` ${colors.yellow}${step}${colors.reset}`);
240
+ } else {
241
+ log(` ${stepIndex + 1}. ${step}`);
242
+ }
243
+ });
244
+ });
245
+
246
+ log('\n' + '─'.repeat(60), colors.cyan);
247
+ log('Troubleshooting', colors.bright);
248
+ log('─'.repeat(60) + '\n', colors.cyan);
249
+
250
+ log('If extension logs don\'t appear:', colors.yellow);
251
+ log(' • Make sure App Groups are configured in BOTH targets');
252
+ log(' • Verify App Group ID matches: group.swan.sdk.notifications');
253
+ log(' • Check that mutable-content: 1 is in FCM APNS payload');
254
+ log(' • Extension only runs for APNS notifications with mutable-content');
255
+ log(' • Test on a real device, not simulator\n');
256
+
257
+ log('If you see "CocoaPods Error: Unable to find compatibility version string for object version 70":', colors.yellow);
258
+ log(' • In Xcode, select your Project → Build Settings → Project Format');
259
+ log(' • Set it to "Xcode 16.0-compatible" or later\n');
260
+
261
+ log('For detailed documentation, see:', colors.cyan);
262
+ log(' node_modules/swan-react-native-sdk/docs/IOS_NOTIFICATION_EXTENSION_SETUP.md\n');
263
+
264
+ logSuccess('Setup script completed!');
265
+ log('');
266
+ }
267
+
268
+ // Run setup
269
+ try {
270
+ setup();
271
+ } catch (error) {
272
+ logError('Setup failed: ' + error.message);
273
+ console.error(error);
274
+ process.exit(1);
275
+ }