@adobe/react-native-aepmessaging 5.0.0 → 6.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/.babelrc +1 -1
  2. package/RCTAEPMessaging.podspec +26 -8
  3. package/README.md +93 -10
  4. package/android/build.gradle +84 -22
  5. package/android/gradle.properties +5 -0
  6. package/android/src/main/AndroidManifest.xml +0 -2
  7. package/android/src/main/AndroidManifestNew.xml +2 -0
  8. package/android/src/main/java/com/adobe/marketing/mobile/reactnative/messaging/RCTAEPMessagingModule.java +215 -202
  9. package/android/src/main/java/com/adobe/marketing/mobile/reactnative/messaging/RCTAEPMessagingPackage.java +27 -25
  10. package/android/src/main/java/com/adobe/marketing/mobile/reactnative/messaging/RCTAEPMessagingUtil.java +134 -0
  11. package/dist/Messaging.d.ts +62 -0
  12. package/dist/Messaging.js +118 -0
  13. package/dist/Messaging.js.map +1 -0
  14. package/{js → dist}/index.d.ts +3 -1
  15. package/{js → dist}/index.js +4 -2
  16. package/dist/index.js.map +1 -0
  17. package/dist/models/Message.d.ts +39 -0
  18. package/dist/models/Message.js +64 -0
  19. package/dist/models/Message.js.map +1 -0
  20. package/dist/models/MessagingDelegate.d.ts +35 -0
  21. package/{js → dist}/models/MessagingDelegate.js +1 -1
  22. package/dist/models/MessagingDelegate.js.map +1 -0
  23. package/{js → dist}/models/MessagingEdgeEventType.d.ts +4 -4
  24. package/{js → dist}/models/MessagingEdgeEventType.js +5 -5
  25. package/dist/models/MessagingEdgeEventType.js.map +1 -0
  26. package/dist/models/MessagingProposition.d.ts +8 -0
  27. package/dist/models/MessagingProposition.js +24 -0
  28. package/dist/models/MessagingProposition.js.map +1 -0
  29. package/dist/models/MessagingPropositionItem.d.ts +8 -0
  30. package/dist/models/MessagingPropositionItem.js +14 -0
  31. package/dist/models/MessagingPropositionItem.js.map +1 -0
  32. package/ios/src/RCTAEPMessaging-Bridging-Header.h +15 -0
  33. package/ios/src/RCTAEPMessaging.mm +50 -0
  34. package/ios/src/RCTAEPMessaging.swift +266 -0
  35. package/ios/src/RCTAEPMessagingConstants.swift +22 -0
  36. package/ios/src/RCTAEPMessagingDataBridge.swift +47 -0
  37. package/package.json +6 -6
  38. package/src/Messaging.ts +164 -0
  39. package/{ts → src}/index.ts +11 -2
  40. package/src/models/Message.ts +72 -0
  41. package/src/models/MessagingDelegate.ts +53 -0
  42. package/{ts → src}/models/MessagingEdgeEventType.ts +5 -5
  43. package/src/models/MessagingProposition.ts +32 -0
  44. package/src/models/MessagingPropositionItem.ts +20 -0
  45. package/tsconfig.json +2 -2
  46. package/ios/RCTAEPMessaging.xcodeproj/project.pbxproj +0 -304
  47. package/ios/src/RCTAEPMessaging.h +0 -20
  48. package/ios/src/RCTAEPMessaging.m +0 -196
  49. package/js/Messaging.d.ts +0 -32
  50. package/js/Messaging.js +0 -80
  51. package/js/Messaging.js.map +0 -1
  52. package/js/index.js.map +0 -1
  53. package/js/models/Message.d.ts +0 -43
  54. package/js/models/Message.js +0 -80
  55. package/js/models/Message.js.map +0 -1
  56. package/js/models/MessagingDelegate.d.ts +0 -25
  57. package/js/models/MessagingDelegate.js.map +0 -1
  58. package/js/models/MessagingEdgeEventType.js.map +0 -1
  59. package/ts/Messaging.ts +0 -99
  60. package/ts/models/Message.ts +0 -82
  61. package/ts/models/MessagingDelegate.ts +0 -41
@@ -0,0 +1,53 @@
1
+ /*
2
+ Copyright 2023 Adobe. All rights reserved.
3
+ This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License. You may obtain a copy
5
+ of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+
7
+ Unless required by applicable law or agreed to in writing, software distributed under
8
+ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ OF ANY KIND, either express or implied. See the License for the specific language
10
+ governing permissions and limitations under the License.
11
+ */
12
+
13
+ import Message from './Message';
14
+
15
+ export interface MessagingDelegate {
16
+ /**
17
+ * Invoked when the any message is displayed
18
+ * @param {Message} message: Message that is being displayed.
19
+ */
20
+ onShow?(message: Message): void;
21
+
22
+ /**
23
+ * Invoked when any message is dismissed
24
+ * @param {Message} message: Message that is being dismissed
25
+ */
26
+ onDismiss?(message: Message): void;
27
+
28
+ /**
29
+ * Used to determine whether a message should be cached, so it can be used later. Return true if the message should be cached.
30
+ * Note: Message must be cached in order to call any of the functions of the message object
31
+ */
32
+ shouldSaveMessage?(message: Message): boolean;
33
+
34
+ /**
35
+ * Used to find whether messages should be shown or not
36
+ * @param {Message} message: Message that is about to get displayed
37
+ * @returns {boolean}: true if the message should be shown else false
38
+ */
39
+ shouldShowMessage?(message: Message): boolean;
40
+
41
+ /**
42
+ * IOS Only - Called when message loads a URL
43
+ * @param {string} url: the URL being loaded by the message
44
+ * @param {Message} message: the Message loading a URL
45
+ */
46
+ urlLoaded?(url: string, message: Message): void;
47
+
48
+ /**
49
+ * Android Only - Called when message loads
50
+ * @param {Message} message: the Message loaded
51
+ */
52
+ onContentLoaded?( message: Message): void;
53
+ }
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2022 Adobe. All rights reserved.
2
+ Copyright 2023 Adobe. All rights reserved.
3
3
  This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
4
  you may not use this file except in compliance with the License. You may obtain a copy
5
5
  of the License at http://www.apache.org/licenses/LICENSE-2.0
@@ -11,10 +11,10 @@ governing permissions and limitations under the License.
11
11
  */
12
12
 
13
13
  enum MessagingEdgeEventType {
14
- IN_APP_DISMISS = 0,
15
- IN_APP_INTERACT = 1,
16
- IN_APP_TRIGGER = 2,
17
- IN_APP_DISPLAY = 3,
14
+ DISMISS = 0,
15
+ INTERACT = 1,
16
+ TRIGGER = 2,
17
+ DISPLAY = 3,
18
18
  PUSH_APPLICATION_OPENED = 4,
19
19
  PUSH_CUSTOM_ACTION = 5
20
20
  };
@@ -0,0 +1,32 @@
1
+ import { MessagingPropositionItem } from './MessagingPropositionItem';
2
+
3
+ /*
4
+ Copyright 2023 Adobe. All rights reserved.
5
+ This file is licensed to you under the Apache License, Version 2.0 (the
6
+ "License"); you may not use this file except in compliance with the License.
7
+ You may obtain a copy of the License at
8
+ http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law
9
+ or agreed to in writing, software distributed under the License is
10
+ distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF
11
+ ANY KIND, either express or implied. See the License for the specific
12
+ language governing permissions and limitations under the License.
13
+ */
14
+
15
+ export class MessagingProposition {
16
+ public items: MessagingPropositionItem[];
17
+ public uniqueId: string;
18
+ public scope: string;
19
+ public scopeDetails: Record<string, any>;
20
+
21
+ constructor(
22
+ uniqueId: string,
23
+ scope: string,
24
+ scopeDetails: Record<string, any>,
25
+ items: MessagingPropositionItem[]
26
+ ) {
27
+ this.uniqueId = uniqueId;
28
+ this.scope = scope;
29
+ this.scopeDetails = scopeDetails;
30
+ this.items = items;
31
+ }
32
+ }
@@ -0,0 +1,20 @@
1
+ /*
2
+ Copyright 2023 Adobe. All rights reserved.
3
+ This file is licensed to you under the Apache License, Version 2.0 (the
4
+ "License"); you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+ http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law
7
+ or agreed to in writing, software distributed under the License is
8
+ distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF
9
+ ANY KIND, either express or implied. See the License for the specific
10
+ language governing permissions and limitations under the License.
11
+ */
12
+
13
+ export interface MessagingPropositionItem {
14
+ htmlContent?: string;
15
+ jsonArrayContent?: string;
16
+ jsonContent?: string;
17
+ itemData?: Record<string, any>;
18
+ schema: string;
19
+ uniqueId: string;
20
+ }
package/tsconfig.json CHANGED
@@ -2,8 +2,8 @@
2
2
  "extends": "../../tsconfig.json",
3
3
  "compilerOptions": {
4
4
  "noEmit": false,
5
- "rootDir": "./ts",
6
- "outDir": "./js",
5
+ "rootDir": "./src",
6
+ "outDir": "./dist",
7
7
  "noImplicitAny": false
8
8
  },
9
9
  "exclude": ["__tests__", "js"]
@@ -1,304 +0,0 @@
1
- // !$*UTF8*$!
2
- {
3
- archiveVersion = 1;
4
- classes = {
5
- };
6
- objectVersion = 46;
7
- objects = {
8
-
9
- /* Begin PBXBuildFile section */
10
- B3E7B58A1CC2AC0600A0062D /* RCTAEPMessaging.m in Sources */ = {isa = PBXBuildFile; fileRef = B3E7B5891CC2AC0600A0062D /* RCTAEPMessaging.m */; };
11
- /* End PBXBuildFile section */
12
-
13
- /* Begin PBXCopyFilesBuildPhase section */
14
- 58B511D91A9E6C8500147676 /* CopyFiles */ = {
15
- isa = PBXCopyFilesBuildPhase;
16
- buildActionMask = 2147483647;
17
- dstPath = "include/$(PRODUCT_NAME)";
18
- dstSubfolderSpec = 16;
19
- files = (
20
- );
21
- runOnlyForDeploymentPostprocessing = 0;
22
- };
23
- /* End PBXCopyFilesBuildPhase section */
24
-
25
- /* Begin PBXFileReference section */
26
- 134814201AA4EA6300B7C361 /* libRCTAEPMessaging.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRCTAEPMessaging.a; sourceTree = BUILT_PRODUCTS_DIR; };
27
- 13DF1315553E7A765C495C83 /* libPods-RCTACPUserProfile.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-RCTACPUserProfile.a"; sourceTree = BUILT_PRODUCTS_DIR; };
28
- B3E7B5881CC2AC0600A0062D /* RCTAEPMessaging.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RCTAEPMessaging.h; path = src/RCTAEPMessaging.h; sourceTree = "<group>"; };
29
- B3E7B5891CC2AC0600A0062D /* RCTAEPMessaging.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = RCTAEPMessaging.m; path = src/RCTAEPMessaging.m; sourceTree = "<group>"; };
30
- /* End PBXFileReference section */
31
-
32
- /* Begin PBXFrameworksBuildPhase section */
33
- 58B511D81A9E6C8500147676 /* Frameworks */ = {
34
- isa = PBXFrameworksBuildPhase;
35
- buildActionMask = 2147483647;
36
- files = (
37
- );
38
- runOnlyForDeploymentPostprocessing = 0;
39
- };
40
- /* End PBXFrameworksBuildPhase section */
41
-
42
- /* Begin PBXGroup section */
43
- 134814211AA4EA7D00B7C361 /* Products */ = {
44
- isa = PBXGroup;
45
- children = (
46
- 134814201AA4EA6300B7C361 /* libRCTAEPMessaging.a */,
47
- );
48
- name = Products;
49
- sourceTree = "<group>";
50
- };
51
- 536328606496798629B88317 /* Frameworks */ = {
52
- isa = PBXGroup;
53
- children = (
54
- 13DF1315553E7A765C495C83 /* libPods-RCTACPUserProfile.a */,
55
- );
56
- name = Frameworks;
57
- sourceTree = "<group>";
58
- };
59
- 58B511D21A9E6C8500147676 = {
60
- isa = PBXGroup;
61
- children = (
62
- B3E7B5881CC2AC0600A0062D /* RCTAEPMessaging.h */,
63
- B3E7B5891CC2AC0600A0062D /* RCTAEPMessaging.m */,
64
- 134814211AA4EA7D00B7C361 /* Products */,
65
- 536328606496798629B88317 /* Frameworks */,
66
- );
67
- sourceTree = "<group>";
68
- };
69
- /* End PBXGroup section */
70
-
71
- /* Begin PBXNativeTarget section */
72
- 58B511DA1A9E6C8500147676 /* RCTAEPMessaging */ = {
73
- isa = PBXNativeTarget;
74
- buildConfigurationList = 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "RCTAEPMessaging" */;
75
- buildPhases = (
76
- D078FD99F863A8DAB193C525 /* [CP] Check Pods Manifest.lock */,
77
- 58B511D91A9E6C8500147676 /* CopyFiles */,
78
- 58B511D71A9E6C8500147676 /* Sources */,
79
- 58B511D81A9E6C8500147676 /* Frameworks */,
80
- );
81
- buildRules = (
82
- );
83
- dependencies = (
84
- );
85
- name = RCTAEPMessaging;
86
- productName = RCTDataManager;
87
- productReference = 134814201AA4EA6300B7C361 /* libRCTAEPMessaging.a */;
88
- productType = "com.apple.product-type.library.static";
89
- };
90
- /* End PBXNativeTarget section */
91
-
92
- /* Begin PBXProject section */
93
- 58B511D31A9E6C8500147676 /* Project object */ = {
94
- isa = PBXProject;
95
- attributes = {
96
- LastUpgradeCheck = 0830;
97
- ORGANIZATIONNAME = Facebook;
98
- TargetAttributes = {
99
- 58B511DA1A9E6C8500147676 = {
100
- CreatedOnToolsVersion = 6.1.1;
101
- };
102
- };
103
- };
104
- buildConfigurationList = 58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "RCTAEPMessaging" */;
105
- compatibilityVersion = "Xcode 3.2";
106
- developmentRegion = English;
107
- hasScannedForEncodings = 0;
108
- knownRegions = (
109
- English,
110
- en,
111
- );
112
- mainGroup = 58B511D21A9E6C8500147676;
113
- productRefGroup = 58B511D21A9E6C8500147676;
114
- projectDirPath = "";
115
- projectRoot = "";
116
- targets = (
117
- 58B511DA1A9E6C8500147676 /* RCTAEPMessaging */,
118
- );
119
- };
120
- /* End PBXProject section */
121
-
122
- /* Begin PBXShellScriptBuildPhase section */
123
- D078FD99F863A8DAB193C525 /* [CP] Check Pods Manifest.lock */ = {
124
- isa = PBXShellScriptBuildPhase;
125
- buildActionMask = 2147483647;
126
- files = (
127
- );
128
- inputFileListPaths = (
129
- );
130
- inputPaths = (
131
- "${PODS_PODFILE_DIR_PATH}/Podfile.lock",
132
- "${PODS_ROOT}/Manifest.lock",
133
- );
134
- name = "[CP] Check Pods Manifest.lock";
135
- outputFileListPaths = (
136
- );
137
- outputPaths = (
138
- "$(DERIVED_FILE_DIR)/Pods-RCTACPUserProfile-checkManifestLockResult.txt",
139
- );
140
- runOnlyForDeploymentPostprocessing = 0;
141
- shellPath = /bin/sh;
142
- shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
143
- showEnvVarsInLog = 0;
144
- };
145
- /* End PBXShellScriptBuildPhase section */
146
-
147
- /* Begin PBXSourcesBuildPhase section */
148
- 58B511D71A9E6C8500147676 /* Sources */ = {
149
- isa = PBXSourcesBuildPhase;
150
- buildActionMask = 2147483647;
151
- files = (
152
- B3E7B58A1CC2AC0600A0062D /* RCTAEPMessaging.m in Sources */,
153
- );
154
- runOnlyForDeploymentPostprocessing = 0;
155
- };
156
- /* End PBXSourcesBuildPhase section */
157
-
158
- /* Begin XCBuildConfiguration section */
159
- 58B511ED1A9E6C8500147676 /* Debug */ = {
160
- isa = XCBuildConfiguration;
161
- buildSettings = {
162
- ALWAYS_SEARCH_USER_PATHS = NO;
163
- CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
164
- CLANG_CXX_LIBRARY = "libc++";
165
- CLANG_ENABLE_MODULES = YES;
166
- CLANG_ENABLE_OBJC_ARC = YES;
167
- CLANG_WARN_BOOL_CONVERSION = YES;
168
- CLANG_WARN_CONSTANT_CONVERSION = YES;
169
- CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
170
- CLANG_WARN_EMPTY_BODY = YES;
171
- CLANG_WARN_ENUM_CONVERSION = YES;
172
- CLANG_WARN_INFINITE_RECURSION = YES;
173
- CLANG_WARN_INT_CONVERSION = YES;
174
- CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
175
- CLANG_WARN_SUSPICIOUS_MOVE = YES;
176
- CLANG_WARN_UNREACHABLE_CODE = YES;
177
- CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
178
- COPY_PHASE_STRIP = NO;
179
- ENABLE_STRICT_OBJC_MSGSEND = YES;
180
- ENABLE_TESTABILITY = YES;
181
- GCC_C_LANGUAGE_STANDARD = gnu99;
182
- GCC_DYNAMIC_NO_PIC = NO;
183
- GCC_NO_COMMON_BLOCKS = YES;
184
- GCC_OPTIMIZATION_LEVEL = 0;
185
- GCC_PREPROCESSOR_DEFINITIONS = (
186
- "DEBUG=1",
187
- "$(inherited)",
188
- );
189
- GCC_SYMBOLS_PRIVATE_EXTERN = NO;
190
- GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
191
- GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
192
- GCC_WARN_UNDECLARED_SELECTOR = YES;
193
- GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
194
- GCC_WARN_UNUSED_FUNCTION = YES;
195
- GCC_WARN_UNUSED_VARIABLE = YES;
196
- IPHONEOS_DEPLOYMENT_TARGET = 8.0;
197
- MTL_ENABLE_DEBUG_INFO = YES;
198
- ONLY_ACTIVE_ARCH = YES;
199
- SDKROOT = iphoneos;
200
- };
201
- name = Debug;
202
- };
203
- 58B511EE1A9E6C8500147676 /* Release */ = {
204
- isa = XCBuildConfiguration;
205
- buildSettings = {
206
- ALWAYS_SEARCH_USER_PATHS = NO;
207
- CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
208
- CLANG_CXX_LIBRARY = "libc++";
209
- CLANG_ENABLE_MODULES = YES;
210
- CLANG_ENABLE_OBJC_ARC = YES;
211
- CLANG_WARN_BOOL_CONVERSION = YES;
212
- CLANG_WARN_CONSTANT_CONVERSION = YES;
213
- CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
214
- CLANG_WARN_EMPTY_BODY = YES;
215
- CLANG_WARN_ENUM_CONVERSION = YES;
216
- CLANG_WARN_INFINITE_RECURSION = YES;
217
- CLANG_WARN_INT_CONVERSION = YES;
218
- CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
219
- CLANG_WARN_SUSPICIOUS_MOVE = YES;
220
- CLANG_WARN_UNREACHABLE_CODE = YES;
221
- CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
222
- COPY_PHASE_STRIP = YES;
223
- ENABLE_NS_ASSERTIONS = NO;
224
- ENABLE_STRICT_OBJC_MSGSEND = YES;
225
- GCC_C_LANGUAGE_STANDARD = gnu99;
226
- GCC_NO_COMMON_BLOCKS = YES;
227
- GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
228
- GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
229
- GCC_WARN_UNDECLARED_SELECTOR = YES;
230
- GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
231
- GCC_WARN_UNUSED_FUNCTION = YES;
232
- GCC_WARN_UNUSED_VARIABLE = YES;
233
- IPHONEOS_DEPLOYMENT_TARGET = 8.0;
234
- MTL_ENABLE_DEBUG_INFO = NO;
235
- SDKROOT = iphoneos;
236
- VALIDATE_PRODUCT = YES;
237
- };
238
- name = Release;
239
- };
240
- 58B511F01A9E6C8500147676 /* Debug */ = {
241
- isa = XCBuildConfiguration;
242
- buildSettings = {
243
- HEADER_SEARCH_PATHS = (
244
- "$(inherited)",
245
- /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
246
- "$(SRCROOT)/../../../React/**",
247
- "$(SRCROOT)/../../react-native/React/**",
248
- );
249
- LIBRARY_SEARCH_PATHS = (
250
- "$(inherited)",
251
- "$(PROJECT_DIR)/libs",
252
- );
253
- OTHER_LDFLAGS = "-ObjC";
254
- PRODUCT_NAME = RCTAEPMessaging;
255
- SKIP_INSTALL = YES;
256
- SUPPORTS_MACCATALYST = NO;
257
- };
258
- name = Debug;
259
- };
260
- 58B511F11A9E6C8500147676 /* Release */ = {
261
- isa = XCBuildConfiguration;
262
- buildSettings = {
263
- HEADER_SEARCH_PATHS = (
264
- "$(inherited)",
265
- /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
266
- "$(SRCROOT)/../../../React/**",
267
- "$(SRCROOT)/../../react-native/React/**",
268
- );
269
- LIBRARY_SEARCH_PATHS = (
270
- "$(inherited)",
271
- "$(PROJECT_DIR)/libs",
272
- );
273
- OTHER_LDFLAGS = "-ObjC";
274
- PRODUCT_NAME = RCTAEPMessaging;
275
- SKIP_INSTALL = YES;
276
- SUPPORTS_MACCATALYST = NO;
277
- };
278
- name = Release;
279
- };
280
- /* End XCBuildConfiguration section */
281
-
282
- /* Begin XCConfigurationList section */
283
- 58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "RCTAEPMessaging" */ = {
284
- isa = XCConfigurationList;
285
- buildConfigurations = (
286
- 58B511ED1A9E6C8500147676 /* Debug */,
287
- 58B511EE1A9E6C8500147676 /* Release */,
288
- );
289
- defaultConfigurationIsVisible = 0;
290
- defaultConfigurationName = Release;
291
- };
292
- 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "RCTAEPMessaging" */ = {
293
- isa = XCConfigurationList;
294
- buildConfigurations = (
295
- 58B511F01A9E6C8500147676 /* Debug */,
296
- 58B511F11A9E6C8500147676 /* Release */,
297
- );
298
- defaultConfigurationIsVisible = 0;
299
- defaultConfigurationName = Release;
300
- };
301
- /* End XCConfigurationList section */
302
- };
303
- rootObject = 58B511D31A9E6C8500147676 /* Project object */;
304
- }
@@ -1,20 +0,0 @@
1
- /*
2
- Copyright 2022 Adobe. All rights reserved.
3
- This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
- you may not use this file except in compliance with the License. You may obtain a copy
5
- of the License at http://www.apache.org/licenses/LICENSE-2.0
6
- Unless required by applicable law or agreed to in writing, software distributed under
7
- the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
8
- OF ANY KIND, either express or implied. See the License for the specific language
9
- governing permissions and limitations under the License.
10
- */
11
-
12
- #import <React/RCTBridgeModule.h>
13
- #import <Foundation/Foundation.h>
14
- #import <React/RCTEventEmitter.h>
15
- #import <React/RCTBridgeModule.h>
16
- @import AEPServices;
17
-
18
- @interface RCTAEPMessaging : RCTEventEmitter <RCTBridgeModule, AEPMessagingDelegate>
19
-
20
- @end
@@ -1,196 +0,0 @@
1
- /*
2
- Copyright 2022 Adobe. All rights reserved.
3
- This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
- you may not use this file except in compliance with the License. You may obtain a copy
5
- of the License at http://www.apache.org/licenses/LICENSE-2.0
6
- Unless required by applicable law or agreed to in writing, software distributed under
7
- the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
8
- OF ANY KIND, either express or implied. See the License for the specific language
9
- governing permissions and limitations under the License.
10
- */
11
- #import "RCTAEPMessaging.h"
12
- @import AEPMessaging;
13
- @import AEPCore;
14
-
15
- static NSString* const TAG = @"RCTAEPMessaging";
16
-
17
- @implementation RCTAEPMessaging {
18
- NSMutableDictionary<NSString*, AEPMessage*> * cachedMessages;
19
- dispatch_semaphore_t semaphore;
20
- bool shouldShowMessage;
21
- bool hasListeners;
22
- bool shouldSaveMessage;
23
- }
24
-
25
- - (instancetype) init {
26
- self = [super init];
27
- cachedMessages = [NSMutableDictionary dictionary];
28
- semaphore = dispatch_semaphore_create(0);
29
- hasListeners = false;
30
- shouldShowMessage = true;
31
- shouldSaveMessage = false;
32
- return self;
33
- }
34
-
35
- + (BOOL)requiresMainQueueSetup
36
- {
37
- return NO;
38
- }
39
-
40
- RCT_EXPORT_MODULE(AEPMessaging);
41
-
42
- - (dispatch_queue_t)methodQueue
43
- {
44
- return dispatch_get_main_queue();
45
- }
46
-
47
- RCT_EXPORT_METHOD(extensionVersion: (RCTPromiseResolveBlock) resolve rejecter:(RCTPromiseRejectBlock) reject) {
48
- resolve([AEPMobileMessaging extensionVersion]);
49
- }
50
-
51
- RCT_EXPORT_METHOD(refreshInAppMessages) {
52
- [AEPLog traceWithLabel:TAG message:@"refreshInAppMessages is called."];
53
- [AEPMobileMessaging refreshInAppMessages];
54
- }
55
-
56
- RCT_EXPORT_METHOD(setMessagingDelegate) {
57
- [AEPLog traceWithLabel:TAG message:@"Messaging Delegate is set."];
58
- [AEPMobileCore setMessagingDelegate: self];
59
- }
60
-
61
- RCT_EXPORT_METHOD(show: (NSString *) messageId) {
62
- [AEPLog traceWithLabel:TAG message:[NSString stringWithFormat:@"show is called with message id: %@", messageId]];
63
- AEPMessage * message = [cachedMessages objectForKey:messageId];
64
- if(message){
65
- [message show];
66
- }
67
- }
68
-
69
- RCT_EXPORT_METHOD(dismiss: (NSString *) messageId suppressAutoTrack: (BOOL) suppressAutoTrack) {
70
- [AEPLog traceWithLabel:TAG message:[NSString stringWithFormat:@"dismiss is called with message id: %@ and suppressAutoTrack: %i", messageId, suppressAutoTrack]];
71
- AEPMessage * message = [cachedMessages objectForKey:messageId];
72
- if(message){
73
- [message dismissSuppressingAutoTrack:suppressAutoTrack];
74
- }
75
- }
76
-
77
- RCT_EXPORT_METHOD(track: (NSString *) messageId withInteraction: (NSString *) interaction eventType: (int) eventTypeValue) {
78
- [AEPLog traceWithLabel:TAG message:[NSString stringWithFormat:@"track is called with message id: %@, withInteraction: %@ and eventType: %i", messageId, interaction, eventTypeValue]];
79
- AEPMessage * message = [cachedMessages objectForKey:messageId];
80
- AEPMessagingEdgeEventType messagingEdgeEventType = -1;
81
-
82
- if(eventTypeValue == 0){
83
- messagingEdgeEventType = AEPMessagingEdgeEventTypeInappDismiss;
84
- } else if (eventTypeValue == 1) {
85
- messagingEdgeEventType = AEPMessagingEdgeEventTypeInappInteract;
86
- } else if (eventTypeValue == 2) {
87
- messagingEdgeEventType = AEPMessagingEdgeEventTypeInappTrigger;
88
- } else if (eventTypeValue == 3) {
89
- messagingEdgeEventType = AEPMessagingEdgeEventTypeInappDisplay;
90
- } else if (eventTypeValue == 4) {
91
- messagingEdgeEventType = AEPMessagingEdgeEventTypePushApplicationOpened;
92
- } else if (eventTypeValue == 5) {
93
- messagingEdgeEventType = AEPMessagingEdgeEventTypePushCustomAction;
94
- }
95
-
96
- if(messagingEdgeEventType != -1){
97
- [message trackInteraction:interaction withEdgeEventType:messagingEdgeEventType];
98
- }
99
- }
100
-
101
- RCT_EXPORT_METHOD(handleJavascriptMessage: (NSString *) messageId
102
- messageName: (NSString *) name resolver: (RCTPromiseResolveBlock) resolve rejector:(RCTPromiseRejectBlock) reject) {
103
- [AEPLog traceWithLabel:TAG message:[NSString stringWithFormat:@"handleJavascriptMessage is called with message id: %@ and messageName: %@", messageId, name]];
104
- AEPMessage * message = [cachedMessages objectForKey: messageId];
105
- [message handleJavascriptMessage:name withHandler:^(id result) {
106
- if(result) {
107
- resolve(result);
108
- } else {
109
- reject(@"error", @"error in handleJavaScriptMessage", nil);
110
- }
111
- }];
112
- }
113
-
114
- RCT_EXPORT_METHOD(clear: (NSString *) messageId) {
115
- [AEPLog traceWithLabel:TAG message:[NSString stringWithFormat:@"clearMessage is called with message id: %@", messageId]];
116
- [cachedMessages removeObjectForKey:messageId];
117
- }
118
-
119
- RCT_EXPORT_METHOD(setAutoTrack: (NSString *) messageId autoTrack: (BOOL) autoTrack) {
120
- [AEPLog traceWithLabel:TAG message:[NSString stringWithFormat:@"setAutoTrack called for messageId: %@ and autoTrack value: %i", messageId, autoTrack]];
121
- AEPMessage * messageObj = [cachedMessages objectForKey:messageId];
122
- if(messageObj) {
123
- messageObj.autoTrack = autoTrack;
124
- }
125
- }
126
-
127
- RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(shouldShowMessage: (BOOL) shouldShowMessage shouldSaveMessage: (BOOL) saveMessage) {
128
- [AEPLog traceWithLabel:TAG message:[NSString stringWithFormat:@"shouldShowMessage is called with values (shouldShowMessage: %i) and (shouldSaveMessage: %i)", shouldShowMessage, shouldSaveMessage]];
129
- self->shouldShowMessage = shouldShowMessage;
130
- self->shouldSaveMessage = saveMessage;
131
- dispatch_semaphore_signal(semaphore);
132
- return nil;
133
- }
134
-
135
- //MARK: - AEPMessagingDelegate functions.
136
- - (void) onDismiss:(id<AEPShowable> _Nonnull) message {
137
- AEPFullscreenMessage * fullscreenMessage = (AEPFullscreenMessage *) message;
138
- AEPMessage * messageObj = (AEPMessage *) fullscreenMessage.settings.parent;
139
- if(messageObj) {
140
- [self emitEventWithName:@"onDismiss" body:@{@"id":messageObj.id, @"autoTrack":messageObj.autoTrack ? @"true" : @"false"}];
141
- }
142
- }
143
-
144
- - (void) onShow:(id<AEPShowable> _Nonnull)message {
145
- AEPFullscreenMessage * fullscreenMessage = (AEPFullscreenMessage *) message;
146
- AEPMessage * messageObj = (AEPMessage *) fullscreenMessage.settings.parent;
147
- if(messageObj) {
148
- [self emitEventWithName:@"onShow" body:@{@"id":messageObj.id, @"autoTrack":messageObj.autoTrack ? @"true" : @"false"}];
149
- }
150
- }
151
-
152
- - (BOOL) shouldShowMessage:(id<AEPShowable> _Nonnull)message {
153
- AEPFullscreenMessage * fullscreenMessage = (AEPFullscreenMessage *) message;
154
- AEPMessage * messageObj = (AEPMessage *) fullscreenMessage.settings.parent;
155
- if(messageObj) {
156
- [self emitEventWithName:@"shouldShowMessage" body:@{@"id":messageObj.id, @"autoTrack":messageObj.autoTrack ? @"true" : @"false"}];
157
- //Semaphore stops the thread until the value to be returned from this function is received from the JS side on thread dedicated to run JS code. The function called from JS that unlock the Semaphore is "shouldShowMessage".
158
- [AEPLog traceWithLabel:TAG message:@"Semaphore lock initiated."];
159
- dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);
160
- [AEPLog traceWithLabel:TAG message:@"Semaphore lock removed."];
161
- if(self->shouldSaveMessage) {
162
- [AEPLog traceWithLabel:TAG message:[[NSString alloc] initWithFormat:@"Message is saved with id: %@", messageObj.id]];
163
- [cachedMessages setObject:messageObj forKey:messageObj.id];
164
- }
165
- }
166
- return self->shouldShowMessage;
167
- }
168
-
169
- - (void) urlLoaded:(NSURL *)url byMessage:(id<AEPShowable>)message {
170
- AEPFullscreenMessage * fullscreenMessage = (AEPFullscreenMessage *) message;
171
- AEPMessage * messageObj = (AEPMessage *) fullscreenMessage.settings.parent;
172
- if(messageObj){
173
- [self emitEventWithName:@"urlLoaded" body:@{@"id":messageObj.id, @"autoTrack":messageObj.autoTrack ? @"true" : @"false", @"url":url.absoluteString}];
174
- }
175
- }
176
-
177
- - (NSArray<NSString *> *) supportedEvents {
178
- return @[@"onShow", @"onDismiss", @"shouldShowMessage",@"urlLoaded"];
179
- }
180
-
181
- - (void) startObserving {
182
- hasListeners = true;
183
- }
184
-
185
- - (void) stopObserving {
186
- hasListeners = false;
187
- }
188
-
189
- - (void) emitEventWithName: (NSString *) name body: (NSDictionary<NSString*, NSString*> *) dictionary {
190
- if(hasListeners){
191
- [AEPLog traceWithLabel:TAG message:[NSString stringWithFormat:@"Event emitted with name: %@", name]];
192
- [self sendEventWithName:name body:dictionary];
193
- }
194
- }
195
-
196
- @end