vibes-react-native 1.1.5 → 1.1.7

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 (39) hide show
  1. package/README.md +2 -392
  2. package/android/.gradle/6.8/fileChanges/last-build.bin +0 -0
  3. package/android/.gradle/6.8/fileHashes/fileHashes.lock +0 -0
  4. package/android/.gradle/6.8/gc.properties +0 -0
  5. package/android/.gradle/checksums/checksums.lock +0 -0
  6. package/android/.gradle/configuration-cache/gc.properties +0 -0
  7. package/android/.gradle/nb-cache/trust/0FE3017D1D91C06BBB23B2D967E1CF942770CADF1DE28563D6C5A7D96E872CFD +1 -0
  8. package/android/.gradle/vcs-1/gc.properties +0 -0
  9. package/android/build.gradle +51 -0
  10. package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  11. package/android/gradle/wrapper/gradle-wrapper.properties +5 -0
  12. package/android/gradlew +185 -0
  13. package/android/gradlew.bat +89 -0
  14. package/android/src/main/AndroidManifest.xml +30 -0
  15. package/android/src/main/java/com/vibes/push/rn/plugin/PushEvtEmitter.java +65 -0
  16. package/android/src/main/java/com/vibes/push/rn/plugin/VibesAppHelper.java +186 -0
  17. package/android/src/main/java/com/vibes/push/rn/plugin/VibesModule.java +490 -0
  18. package/android/src/main/java/com/vibes/push/rn/plugin/VibesPackage.java +28 -0
  19. package/android/src/main/java/com/vibes/push/rn/plugin/notifications/Fms.java +132 -0
  20. package/android/src/main/java/com/vibes/push/rn/plugin/notifications/PayloadWrapper.java +23 -0
  21. package/android/src/main/java/com/vibes/push/rn/plugin/notifications/VibesPushReceiver.java +62 -0
  22. package/ios/Configuration.swift +68 -0
  23. package/ios/Notifications.swift +72 -0
  24. package/ios/Vibes-Bridging-Header.h +2 -0
  25. package/ios/Vibes.m +56 -0
  26. package/ios/Vibes.swift +378 -0
  27. package/ios/Vibes.xcodeproj/project.pbxproj +293 -0
  28. package/ios/Vibes.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  29. package/ios/Vibes.xcodeproj/project.xcworkspace/xcuserdata/ed.lafoy.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  30. package/ios/Vibes.xcodeproj/xcuserdata/ed.lafoy.xcuserdatad/xcschemes/xcschememanagement.plist +14 -0
  31. package/ios/VibesClient.swift +35 -0
  32. package/ios/VibesPluginLogger.swift +160 -0
  33. package/lib/commonjs/index.js +163 -0
  34. package/lib/commonjs/index.js.map +1 -0
  35. package/lib/module/index.js +143 -0
  36. package/lib/module/index.js.map +1 -0
  37. package/package.json +10 -11
  38. package/src/index.tsx +182 -0
  39. /package/{ib → lib}/typescript/index.d.ts +0 -0
@@ -0,0 +1,293 @@
1
+ // !$*UTF8*$!
2
+ {
3
+ archiveVersion = 1;
4
+ classes = {
5
+ };
6
+ objectVersion = 46;
7
+ objects = {
8
+
9
+ /* Begin PBXBuildFile section */
10
+ B37330EA281323F700662936 /* VibesClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = B37330E9281322A500662936 /* VibesClient.swift */; };
11
+ B37330EB281323FC00662936 /* Notifications.swift in Sources */ = {isa = PBXBuildFile; fileRef = B37330E82813224100662936 /* Notifications.swift */; };
12
+ B37330EC2813240000662936 /* EventEmitterLogger.swift in Sources */ = {isa = PBXBuildFile; fileRef = B37330E7281321CF00662936 /* EventEmitterLogger.swift */; };
13
+ B37330ED2813240500662936 /* Configuration.swift in Sources */ = {isa = PBXBuildFile; fileRef = B37330E62813215800662936 /* Configuration.swift */; };
14
+ /* End PBXBuildFile section */
15
+
16
+ /* Begin PBXCopyFilesBuildPhase section */
17
+ 58B511D91A9E6C8500147676 /* CopyFiles */ = {
18
+ isa = PBXCopyFilesBuildPhase;
19
+ buildActionMask = 2147483647;
20
+ dstPath = "include/$(PRODUCT_NAME)";
21
+ dstSubfolderSpec = 16;
22
+ files = (
23
+ );
24
+ runOnlyForDeploymentPostprocessing = 0;
25
+ };
26
+ /* End PBXCopyFilesBuildPhase section */
27
+
28
+ /* Begin PBXFileReference section */
29
+ 134814201AA4EA6300B7C361 /* libVibes.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libVibes.a; sourceTree = BUILT_PRODUCTS_DIR; };
30
+ 24E8E590281702690042822D /* Vibes.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Vibes.swift; sourceTree = "<group>"; };
31
+ B37330E62813215800662936 /* Configuration.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Configuration.swift; sourceTree = "<group>"; };
32
+ B37330E7281321CF00662936 /* EventEmitterLogger.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EventEmitterLogger.swift; sourceTree = "<group>"; };
33
+ B37330E82813224100662936 /* Notifications.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Notifications.swift; sourceTree = "<group>"; };
34
+ B37330E9281322A500662936 /* VibesClient.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VibesClient.swift; sourceTree = "<group>"; };
35
+ B3E7B5891CC2AC0600A0062D /* Vibes.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Vibes.m; sourceTree = "<group>"; };
36
+ F4FF95D5245B92E700C19C63 /* Vibes-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Vibes-Bridging-Header.h"; sourceTree = "<group>"; };
37
+ /* End PBXFileReference section */
38
+
39
+ /* Begin PBXFrameworksBuildPhase section */
40
+ 58B511D81A9E6C8500147676 /* Frameworks */ = {
41
+ isa = PBXFrameworksBuildPhase;
42
+ buildActionMask = 2147483647;
43
+ files = (
44
+ );
45
+ runOnlyForDeploymentPostprocessing = 0;
46
+ };
47
+ /* End PBXFrameworksBuildPhase section */
48
+
49
+ /* Begin PBXGroup section */
50
+ 134814211AA4EA7D00B7C361 /* Products */ = {
51
+ isa = PBXGroup;
52
+ children = (
53
+ 134814201AA4EA6300B7C361 /* libVibes.a */,
54
+ );
55
+ name = Products;
56
+ sourceTree = "<group>";
57
+ };
58
+ 58B511D21A9E6C8500147676 = {
59
+ isa = PBXGroup;
60
+ children = (
61
+ 24E8E590281702690042822D /* Vibes.swift */,
62
+ B37330E9281322A500662936 /* VibesClient.swift */,
63
+ B37330E82813224100662936 /* Notifications.swift */,
64
+ B37330E7281321CF00662936 /* EventEmitterLogger.swift */,
65
+ B37330E62813215800662936 /* Configuration.swift */,
66
+ B3E7B5891CC2AC0600A0062D /* Vibes.m */,
67
+ F4FF95D5245B92E700C19C63 /* Vibes-Bridging-Header.h */,
68
+ 134814211AA4EA7D00B7C361 /* Products */,
69
+ );
70
+ sourceTree = "<group>";
71
+ };
72
+ /* End PBXGroup section */
73
+
74
+ /* Begin PBXNativeTarget section */
75
+ 58B511DA1A9E6C8500147676 /* Vibes */ = {
76
+ isa = PBXNativeTarget;
77
+ buildConfigurationList = 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "Vibes" */;
78
+ buildPhases = (
79
+ 58B511D71A9E6C8500147676 /* Sources */,
80
+ 58B511D81A9E6C8500147676 /* Frameworks */,
81
+ 58B511D91A9E6C8500147676 /* CopyFiles */,
82
+ );
83
+ buildRules = (
84
+ );
85
+ dependencies = (
86
+ );
87
+ name = Vibes;
88
+ productName = RCTDataManager;
89
+ productReference = 134814201AA4EA6300B7C361 /* libVibes.a */;
90
+ productType = "com.apple.product-type.library.static";
91
+ };
92
+ /* End PBXNativeTarget section */
93
+
94
+ /* Begin PBXProject section */
95
+ 58B511D31A9E6C8500147676 /* Project object */ = {
96
+ isa = PBXProject;
97
+ attributes = {
98
+ LastUpgradeCheck = 0920;
99
+ ORGANIZATIONNAME = Facebook;
100
+ TargetAttributes = {
101
+ 58B511DA1A9E6C8500147676 = {
102
+ CreatedOnToolsVersion = 6.1.1;
103
+ };
104
+ };
105
+ };
106
+ buildConfigurationList = 58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "Vibes" */;
107
+ compatibilityVersion = "Xcode 3.2";
108
+ developmentRegion = English;
109
+ hasScannedForEncodings = 0;
110
+ knownRegions = (
111
+ English,
112
+ en,
113
+ );
114
+ mainGroup = 58B511D21A9E6C8500147676;
115
+ productRefGroup = 58B511D21A9E6C8500147676;
116
+ projectDirPath = "";
117
+ projectRoot = "";
118
+ targets = (
119
+ 58B511DA1A9E6C8500147676 /* Vibes */,
120
+ );
121
+ };
122
+ /* End PBXProject section */
123
+
124
+ /* Begin PBXSourcesBuildPhase section */
125
+ 58B511D71A9E6C8500147676 /* Sources */ = {
126
+ isa = PBXSourcesBuildPhase;
127
+ buildActionMask = 2147483647;
128
+ files = (
129
+ B37330EB281323FC00662936 /* Notifications.swift in Sources */,
130
+ B37330ED2813240500662936 /* Configuration.swift in Sources */,
131
+ B37330EA281323F700662936 /* VibesClient.swift in Sources */,
132
+ B37330EC2813240000662936 /* EventEmitterLogger.swift in Sources */,
133
+ );
134
+ runOnlyForDeploymentPostprocessing = 0;
135
+ };
136
+ /* End PBXSourcesBuildPhase section */
137
+
138
+ /* Begin XCBuildConfiguration section */
139
+ 58B511ED1A9E6C8500147676 /* Debug */ = {
140
+ isa = XCBuildConfiguration;
141
+ buildSettings = {
142
+ ALWAYS_SEARCH_USER_PATHS = NO;
143
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
144
+ CLANG_CXX_LIBRARY = "libc++";
145
+ CLANG_ENABLE_MODULES = YES;
146
+ CLANG_ENABLE_OBJC_ARC = YES;
147
+ CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
148
+ CLANG_WARN_BOOL_CONVERSION = YES;
149
+ CLANG_WARN_COMMA = YES;
150
+ CLANG_WARN_CONSTANT_CONVERSION = YES;
151
+ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
152
+ CLANG_WARN_EMPTY_BODY = YES;
153
+ CLANG_WARN_ENUM_CONVERSION = YES;
154
+ CLANG_WARN_INFINITE_RECURSION = YES;
155
+ CLANG_WARN_INT_CONVERSION = YES;
156
+ CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
157
+ CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
158
+ CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
159
+ CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
160
+ CLANG_WARN_STRICT_PROTOTYPES = YES;
161
+ CLANG_WARN_SUSPICIOUS_MOVE = YES;
162
+ CLANG_WARN_UNREACHABLE_CODE = YES;
163
+ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
164
+ COPY_PHASE_STRIP = NO;
165
+ ENABLE_STRICT_OBJC_MSGSEND = YES;
166
+ ENABLE_TESTABILITY = YES;
167
+ GCC_C_LANGUAGE_STANDARD = gnu99;
168
+ GCC_DYNAMIC_NO_PIC = NO;
169
+ GCC_NO_COMMON_BLOCKS = YES;
170
+ GCC_OPTIMIZATION_LEVEL = 0;
171
+ GCC_PREPROCESSOR_DEFINITIONS = (
172
+ "DEBUG=1",
173
+ "$(inherited)",
174
+ );
175
+ GCC_SYMBOLS_PRIVATE_EXTERN = NO;
176
+ GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
177
+ GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
178
+ GCC_WARN_UNDECLARED_SELECTOR = YES;
179
+ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
180
+ GCC_WARN_UNUSED_FUNCTION = YES;
181
+ GCC_WARN_UNUSED_VARIABLE = YES;
182
+ IPHONEOS_DEPLOYMENT_TARGET = 8.0;
183
+ MTL_ENABLE_DEBUG_INFO = YES;
184
+ ONLY_ACTIVE_ARCH = YES;
185
+ SDKROOT = iphoneos;
186
+ };
187
+ name = Debug;
188
+ };
189
+ 58B511EE1A9E6C8500147676 /* Release */ = {
190
+ isa = XCBuildConfiguration;
191
+ buildSettings = {
192
+ ALWAYS_SEARCH_USER_PATHS = NO;
193
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
194
+ CLANG_CXX_LIBRARY = "libc++";
195
+ CLANG_ENABLE_MODULES = YES;
196
+ CLANG_ENABLE_OBJC_ARC = YES;
197
+ CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
198
+ CLANG_WARN_BOOL_CONVERSION = YES;
199
+ CLANG_WARN_COMMA = YES;
200
+ CLANG_WARN_CONSTANT_CONVERSION = YES;
201
+ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
202
+ CLANG_WARN_EMPTY_BODY = YES;
203
+ CLANG_WARN_ENUM_CONVERSION = YES;
204
+ CLANG_WARN_INFINITE_RECURSION = YES;
205
+ CLANG_WARN_INT_CONVERSION = YES;
206
+ CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
207
+ CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
208
+ CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
209
+ CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
210
+ CLANG_WARN_STRICT_PROTOTYPES = YES;
211
+ CLANG_WARN_SUSPICIOUS_MOVE = YES;
212
+ CLANG_WARN_UNREACHABLE_CODE = YES;
213
+ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
214
+ COPY_PHASE_STRIP = YES;
215
+ ENABLE_NS_ASSERTIONS = NO;
216
+ ENABLE_STRICT_OBJC_MSGSEND = YES;
217
+ GCC_C_LANGUAGE_STANDARD = gnu99;
218
+ GCC_NO_COMMON_BLOCKS = YES;
219
+ GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
220
+ GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
221
+ GCC_WARN_UNDECLARED_SELECTOR = YES;
222
+ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
223
+ GCC_WARN_UNUSED_FUNCTION = YES;
224
+ GCC_WARN_UNUSED_VARIABLE = YES;
225
+ IPHONEOS_DEPLOYMENT_TARGET = 8.0;
226
+ MTL_ENABLE_DEBUG_INFO = NO;
227
+ SDKROOT = iphoneos;
228
+ VALIDATE_PRODUCT = YES;
229
+ };
230
+ name = Release;
231
+ };
232
+ 58B511F01A9E6C8500147676 /* Debug */ = {
233
+ isa = XCBuildConfiguration;
234
+ buildSettings = {
235
+ HEADER_SEARCH_PATHS = (
236
+ "$(inherited)",
237
+ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
238
+ "$(SRCROOT)/../../../React/**",
239
+ "$(SRCROOT)/../../react-native/React/**",
240
+ );
241
+ LIBRARY_SEARCH_PATHS = "$(inherited)";
242
+ OTHER_LDFLAGS = "-ObjC";
243
+ PRODUCT_NAME = Vibes;
244
+ SKIP_INSTALL = YES;
245
+ SWIFT_OBJC_BRIDGING_HEADER = "Vibes-Bridging-Header.h";
246
+ SWIFT_OPTIMIZATION_LEVEL = "-Onone";
247
+ SWIFT_VERSION = 5.0;
248
+ };
249
+ name = Debug;
250
+ };
251
+ 58B511F11A9E6C8500147676 /* Release */ = {
252
+ isa = XCBuildConfiguration;
253
+ buildSettings = {
254
+ HEADER_SEARCH_PATHS = (
255
+ "$(inherited)",
256
+ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
257
+ "$(SRCROOT)/../../../React/**",
258
+ "$(SRCROOT)/../../react-native/React/**",
259
+ );
260
+ LIBRARY_SEARCH_PATHS = "$(inherited)";
261
+ OTHER_LDFLAGS = "-ObjC";
262
+ PRODUCT_NAME = Vibes;
263
+ SKIP_INSTALL = YES;
264
+ SWIFT_OBJC_BRIDGING_HEADER = "Vibes-Bridging-Header.h";
265
+ SWIFT_VERSION = 5.0;
266
+ };
267
+ name = Release;
268
+ };
269
+ /* End XCBuildConfiguration section */
270
+
271
+ /* Begin XCConfigurationList section */
272
+ 58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "Vibes" */ = {
273
+ isa = XCConfigurationList;
274
+ buildConfigurations = (
275
+ 58B511ED1A9E6C8500147676 /* Debug */,
276
+ 58B511EE1A9E6C8500147676 /* Release */,
277
+ );
278
+ defaultConfigurationIsVisible = 0;
279
+ defaultConfigurationName = Release;
280
+ };
281
+ 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "Vibes" */ = {
282
+ isa = XCConfigurationList;
283
+ buildConfigurations = (
284
+ 58B511F01A9E6C8500147676 /* Debug */,
285
+ 58B511F11A9E6C8500147676 /* Release */,
286
+ );
287
+ defaultConfigurationIsVisible = 0;
288
+ defaultConfigurationName = Release;
289
+ };
290
+ /* End XCConfigurationList section */
291
+ };
292
+ rootObject = 58B511D31A9E6C8500147676 /* Project object */;
293
+ }
@@ -0,0 +1,7 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <Workspace
3
+ version = "1.0">
4
+ <FileRef
5
+ location = "self:">
6
+ </FileRef>
7
+ </Workspace>
@@ -0,0 +1,14 @@
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>SchemeUserState</key>
6
+ <dict>
7
+ <key>Vibes.xcscheme_^#shared#^_</key>
8
+ <dict>
9
+ <key>orderHint</key>
10
+ <integer>0</integer>
11
+ </dict>
12
+ </dict>
13
+ </dict>
14
+ </plist>
@@ -0,0 +1,35 @@
1
+ //
2
+ // VibesClient.swift
3
+ // Vibes
4
+ //
5
+ // Created by DHwty on 22/04/2022.
6
+ // Copyright © 2022 Facebook. All rights reserved.
7
+ //
8
+
9
+ import VibesPush
10
+
11
+ @objcMembers
12
+ class VibesClient: NSObject {
13
+ static let standard = VibesClient()
14
+
15
+ public let vibes: VibesPush.Vibes
16
+ public var logger: VibesLogger? = VibesPluginLogger.shared
17
+
18
+ override private init() {
19
+ // ensure we have Vibes app url set in current build config's Info.plist
20
+ guard let appUrl = Configuration.configValue(.vibesApiURL) else {
21
+ fatalError("`\(ConfigKey.vibesApiURL.value())` must be set in plist file of current build configuration")
22
+ }
23
+ // ensure we have Vibes app id set in current build config's Info.plist
24
+ guard let appId = Configuration.configValue(.vibesAppId) else {
25
+ fatalError("`\(ConfigKey.vibesAppId.value())` must be set in plist file of current build configuration")
26
+ }
27
+ let config = VibesConfiguration(advertisingId: nil,
28
+ apiUrl: appUrl,
29
+ logger: logger,
30
+ storageType: .USERDEFAULTS)
31
+
32
+ VibesPush.Vibes.configure(appId: appId, configuration: config)
33
+ vibes = VibesPush.Vibes.shared
34
+ }
35
+ }
@@ -0,0 +1,160 @@
1
+ //
2
+ // EventEmitterLogger.swift
3
+ // Vibes
4
+ //
5
+ // Created by DHwty on 22/04/2022.
6
+ // Copyright © 2022 Facebook. All rights reserved.
7
+ //
8
+
9
+ import UIKit
10
+ import VibesPush
11
+
12
+ @objcMembers
13
+ class VibesPluginLogger: NSObject {
14
+ static let Log = NSNotification.Name(rawValue: "Log")
15
+ static var data = [NSString]()
16
+ static let shared = VibesPluginLogger()
17
+ public typealias JsonObject = [String: Any]
18
+ let kBodyUrl = "url"
19
+ let kBodyMethod = "method"
20
+ let kBodyHeaders = "headers"
21
+ let kBody = "body"
22
+ let kBodyType = "type"
23
+ let kHTTPStatusCode = "http_status"
24
+
25
+ var deviceId: String! = "-"
26
+
27
+ // Can't init is singleton
28
+ override private init() { }
29
+
30
+ fileprivate func sendLog(uuid: String,
31
+ timestamp: String,
32
+ body: [AnyHashable: Any],
33
+ request_type: String) {
34
+ // get the saved device id from prefs, if not exist we will use "-"
35
+ if let devId = UserDefaults.standard.vibesDeviceId {
36
+ deviceId = devId
37
+ }
38
+ // get env from plist config file if set, else throw fatal error
39
+ guard let env = Configuration.configValue(.vibesAppEnv) else {
40
+ fatalError("`\(ConfigKey.vibesAppEnv.value())` must be set in plist file of current build configuration")
41
+ }
42
+ let jsonObj: [String: Any] = ["os_type": "iOS",
43
+ "device_id": deviceId ?? " - ",
44
+ "env": env,
45
+ "uuid": uuid,
46
+ "request type": request_type,
47
+ "data": body,
48
+ ]
49
+
50
+ // we comment out in case of debugging in xcode
51
+ // debugPrint(VibesPluginLogger.stringify(json: jsonObj, prettyPrinted: true))
52
+ }
53
+
54
+ static func stringify(json: Any, prettyPrinted: Bool = false) -> String {
55
+ var options: JSONSerialization.WritingOptions = []
56
+ if prettyPrinted {
57
+ options = JSONSerialization.WritingOptions.prettyPrinted
58
+ }
59
+
60
+ do {
61
+ let data = try JSONSerialization.data(withJSONObject: json, options: options)
62
+ if let string = String(data: data, encoding: String.Encoding.utf8) {
63
+ return string
64
+ }
65
+ } catch {
66
+ debugPrint(error)
67
+ }
68
+
69
+ return ""
70
+ }
71
+
72
+ fileprivate func dispatch(_ body: [AnyHashable: Any], requestType: String) {
73
+ do {
74
+ let pretty = try JSONSerialization.data(withJSONObject: body, options: .prettyPrinted)
75
+ let uuid = (UIDevice.current.identifierForVendor?.uuidString)!
76
+ let timestamp = Date().description
77
+ if let log = NSString(data: pretty, encoding: String.Encoding.utf8.rawValue) {
78
+ VibesPluginLogger.data.insert(NSString(string: "\(timestamp) \(log)"), at: 0)
79
+ }
80
+ sendLog(uuid: uuid, timestamp: timestamp, body: body, request_type: requestType)
81
+ } catch {
82
+ debugPrint("[LOG] Error during deserialization")
83
+ }
84
+ }
85
+
86
+ fileprivate func getLogMetaData() -> JsonObject {
87
+ var meta: JsonObject = [:]
88
+
89
+ if let buildNumber = Configuration.configValue(.appBuildNumber),
90
+ let versionNumber = Configuration.configValue(.appVersionNumber) {
91
+ meta["appBuildNumber"] = buildNumber
92
+ meta["appVersionNumber"] = versionNumber
93
+ }
94
+
95
+ let os = ProcessInfo.processInfo.operatingSystemVersion
96
+ meta["osRelease"] = "\(os.majorVersion).\(os.minorVersion).\(os.patchVersion)"
97
+ meta["vendorIdentifier"] = UIDevice.current.identifierForVendor!.uuidString
98
+ return meta
99
+ }
100
+ }
101
+
102
+ extension String {
103
+ func capitalizingFirstLetter() -> String {
104
+ return prefix(1).capitalized + dropFirst()
105
+ }
106
+
107
+ mutating func capitalizeFirstLetter() {
108
+ self = capitalizingFirstLetter()
109
+ }
110
+ }
111
+
112
+ extension VibesPluginLogger: VibesLogger {
113
+ func log(_ logObject: LogObject) {
114
+ let body = [
115
+ "type": "\(logObject.level.logPrefix.lowercased().capitalizingFirstLetter())",
116
+ "description": logObject.message,
117
+ ]
118
+ dispatch(body, requestType: "[\(logObject.level.logPrefix)]")
119
+ }
120
+
121
+ func log(request: URLRequest) {
122
+ let body = [
123
+ "type": "Request",
124
+ "method": request.methodDescription,
125
+ "url": request.urlDescription,
126
+ "headers": request.headerFieldsDescription,
127
+ "body": request.bodyDescription,
128
+ ]
129
+ dispatch(body, requestType: "[REQUEST]")
130
+ }
131
+
132
+ func log(response: URLResponse, data: Data?) {
133
+ var responseBody: NSString
134
+ if let url = response.url {
135
+ if let data = data {
136
+ responseBody = NSString(data: data, encoding: String.Encoding.utf8.rawValue)!
137
+ } else {
138
+ responseBody = "[]"
139
+ }
140
+
141
+ let body = [
142
+ kBodyType: "Response",
143
+ kBodyMethod: "-",
144
+ kBodyUrl: (response.url?.absoluteString)!,
145
+ kBodyHeaders: (response as? HTTPURLResponse)?.headersDescription as Any,
146
+ kBody: responseBody as String,
147
+ kHTTPStatusCode: (response as? HTTPURLResponse)?.statusCode as Any,
148
+ ] as [AnyHashable: Any]
149
+ dispatch(body, requestType: "[RESPONSE]")
150
+ }
151
+ }
152
+
153
+ func log(error: Error) {
154
+ let body = [
155
+ "type": "Error",
156
+ "description": error.localizedDescription,
157
+ ]
158
+ dispatch(body, requestType: "[ERROR]")
159
+ }
160
+ }
@@ -0,0 +1,163 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.associatePerson = associatePerson;
7
+ exports.default = void 0;
8
+ exports.expireInboxMessage = expireInboxMessage;
9
+ exports.fetchInboxMessage = fetchInboxMessage;
10
+ exports.fetchInboxMessages = fetchInboxMessages;
11
+ exports.getPerson = getPerson;
12
+ exports.getVibesDeviceInfo = getVibesDeviceInfo;
13
+ exports.markInboxMessageAsRead = markInboxMessageAsRead;
14
+ exports.onInboxMessageOpen = onInboxMessageOpen;
15
+ exports.onInboxMessagesFetched = onInboxMessagesFetched;
16
+ exports.registerDevice = registerDevice;
17
+ exports.registerPush = registerPush;
18
+ exports.unregisterDevice = unregisterDevice;
19
+ exports.unregisterPush = unregisterPush;
20
+ exports.updateDevice = updateDevice;
21
+ var _reactNative = require("react-native");
22
+ const LINKING_ERROR = `The package 'vibes-react-native' doesn't seem to be linked. Make sure: \n\n` + _reactNative.Platform.select({
23
+ ios: "- You have run 'pod install'\n",
24
+ default: ''
25
+ }) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo managed workflow\n';
26
+ const Vibes = _reactNative.NativeModules.Vibes ? _reactNative.NativeModules.Vibes : new Proxy({}, {
27
+ get() {
28
+ throw new Error(LINKING_ERROR);
29
+ }
30
+ });
31
+ /**
32
+ * Register this device with the Vibes platform
33
+ *
34
+ * @return {Promise<DeviceResponse>}
35
+ */
36
+ function registerDevice() {
37
+ return Vibes.registerDevice();
38
+ }
39
+ /**
40
+ * Unregister this device with the Vibes platform
41
+ *
42
+ * @return {Promise<void>}
43
+ */
44
+ function unregisterDevice() {
45
+ return Vibes.unregisterDevice();
46
+ }
47
+
48
+ /**
49
+ * Register this device to receive push notifications
50
+ *
51
+ * @return {Promise<void>}
52
+ */
53
+ function registerPush() {
54
+ return Vibes.registerPush();
55
+ }
56
+
57
+ /**
58
+ * Unregister the device from receiving push notifications
59
+ *
60
+ * @return {Promise<void>}
61
+ */
62
+ function unregisterPush() {
63
+ return Vibes.registerPush();
64
+ }
65
+
66
+ /**
67
+ * Fetches a DeviceInfoResponse with details about the Vibes Device ID and Push Token
68
+ *
69
+ * @return {Promise<DeviceInfoResponse>}
70
+ */
71
+ function getVibesDeviceInfo() {
72
+ return Vibes.getVibesDeviceInfo();
73
+ }
74
+
75
+ /**
76
+ * Updates the Vibes platform with changes to the device since the last time device information was submitted.
77
+ *
78
+ * @param updateCredential - if true, the authentication token will be refreshed. Unless required, pass false here.
79
+ * @param latitude - if you collect geolocation information, then pass the latitude here. Otherwise, pass 0
80
+ * @param longitude - if you collect geolocation information, then pass the latitude here. Otherwise, pass 0
81
+ * @returns {Promise<void>}
82
+ */
83
+ function updateDevice(updateCredential, latitude, longitude) {
84
+ return Vibes.updateDevice(updateCredential, latitude, longitude);
85
+ }
86
+
87
+ /**
88
+ * Associate an external ID with the current person.
89
+ *
90
+ * @param {string} externalPersonId
91
+ * @return {Promise<void>}
92
+ */
93
+ function associatePerson(externalPersonId) {
94
+ return Vibes.associatePerson(externalPersonId);
95
+ }
96
+
97
+ /**
98
+ * Fetches the PersonResponse associated with this device currently
99
+ *
100
+ * @return {Promise<PersonResponse>}
101
+ */
102
+ function getPerson() {
103
+ return Vibes.getPerson();
104
+ }
105
+ /**
106
+ * Fetches an array of inbox messages for the person associated with this device.
107
+ *
108
+ * @return {Promise<InboxMessage[]>}
109
+ */
110
+ function fetchInboxMessages() {
111
+ return Vibes.fetchInboxMessages();
112
+ }
113
+
114
+ /**
115
+ * Fetches a single inbox message by it's id.
116
+ *
117
+ * @param {string} message_uid
118
+ * @return {Promise<InboxMessage>}
119
+ */
120
+ function fetchInboxMessage(message_uid) {
121
+ return Vibes.fetchInboxMessage(message_uid);
122
+ }
123
+
124
+ /**
125
+ * Marks an inbox message as read.
126
+ *
127
+ * @param {string} message_uid
128
+ * @return {Promise<InboxMessage>} an updated version of the InboxMessage with read field updated
129
+ */
130
+ function markInboxMessageAsRead(message_uid) {
131
+ return Vibes.markInboxMessageAsRead(message_uid);
132
+ }
133
+
134
+ /**
135
+ * Marks an inbox message as expired using message_uid and the expiry date supplied. Uses current date as expiry date
136
+ *
137
+ * @param {string} message_uid
138
+ * @return {Promise<InboxMessage>} an updated version of the InboxMessage with expires_at date updated
139
+ */
140
+ function expireInboxMessage(message_uid) {
141
+ return Vibes.expireInboxMessage(message_uid);
142
+ }
143
+
144
+ /**
145
+ * Records an event for when the user opens an inbox message.
146
+ *
147
+ * @param inboxMap json map of the InboxMessage
148
+ * @return {Promise<void>}
149
+ */
150
+ function onInboxMessageOpen(inboxMap) {
151
+ return Vibes.onInboxMessageOpen(inboxMap);
152
+ }
153
+
154
+ /**
155
+ * Records an event for when the user fetches a list of inbox messages.
156
+ *
157
+ * @return {Promise<void>}
158
+ */
159
+ function onInboxMessagesFetched() {
160
+ return Vibes.onInboxMessagesFetched();
161
+ }
162
+ var _default = exports.default = Vibes;
163
+ //# sourceMappingURL=index.js.map