react-native-radar 3.20.4 → 3.21.0-beta.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 (133) hide show
  1. package/Radar.podspec +22 -0
  2. package/android/build.gradle +77 -35
  3. package/android/gradle.properties +5 -1
  4. package/android/src/main/AndroidManifest.xml +1 -3
  5. package/android/src/main/java/{io/radar/react/RNRadarModule.java → com/radar/RadarModuleImpl.java} +131 -258
  6. package/android/src/main/java/com/radar/RadarPackage.kt +35 -0
  7. package/android/src/main/java/{io/radar/react/RNRadarUtils.java → com/radar/RadarUtils.java} +3 -2
  8. package/android/src/newarch/java/com/radar/RadarModule.kt +381 -0
  9. package/android/src/oldarch/java/com/radar/RadarModule.java +416 -0
  10. package/android/src/{main/java/io/radar/react/RNRadarReceiver.java → oldarch/java/com/radar/RadarOldArchReceiver.java} +8 -8
  11. package/android/src/{main/java/io/radar/react/RNRadarVerifiedReceiver.java → oldarch/java/com/radar/RadarOldArchVerifiedReceiver.java} +4 -4
  12. package/app.plugin.js +1 -1
  13. package/ios/RNRadar.h +11 -2
  14. package/ios/{RNRadar.m → RNRadar.mm} +77 -39
  15. package/lib/commonjs/@types/RadarNativeInterface.js +2 -0
  16. package/lib/commonjs/@types/RadarNativeInterface.js.map +1 -0
  17. package/lib/commonjs/@types/types.js +2 -0
  18. package/lib/commonjs/@types/types.js.map +1 -0
  19. package/lib/commonjs/NativeRadar.js +2 -0
  20. package/lib/commonjs/NativeRadar.js.map +1 -0
  21. package/lib/commonjs/helpers.js +2 -0
  22. package/lib/commonjs/helpers.js.map +1 -0
  23. package/lib/commonjs/index.js +2 -0
  24. package/lib/commonjs/index.js.map +1 -0
  25. package/lib/commonjs/index.native.js +2 -0
  26. package/lib/commonjs/index.native.js.map +1 -0
  27. package/lib/commonjs/index.web.js +2 -0
  28. package/lib/commonjs/index.web.js.map +1 -0
  29. package/lib/commonjs/package.json +1 -0
  30. package/lib/commonjs/plugin/types.js +2 -0
  31. package/lib/commonjs/plugin/types.js.map +1 -0
  32. package/lib/commonjs/plugin/withRadar.js +2 -0
  33. package/lib/commonjs/plugin/withRadar.js.map +1 -0
  34. package/lib/commonjs/plugin/withRadarAndroid.js +2 -0
  35. package/lib/commonjs/plugin/withRadarAndroid.js.map +1 -0
  36. package/lib/commonjs/plugin/withRadarIOS.js +2 -0
  37. package/lib/commonjs/plugin/withRadarIOS.js.map +1 -0
  38. package/lib/commonjs/ui/autocomplete.js +2 -0
  39. package/lib/commonjs/ui/autocomplete.js.map +1 -0
  40. package/lib/commonjs/ui/images.js +2 -0
  41. package/lib/commonjs/ui/images.js.map +1 -0
  42. package/lib/commonjs/ui/map.js +2 -0
  43. package/lib/commonjs/ui/map.js.map +1 -0
  44. package/lib/commonjs/ui/styles.js +2 -0
  45. package/lib/commonjs/ui/styles.js.map +1 -0
  46. package/lib/commonjs/version.js +2 -0
  47. package/lib/commonjs/version.js.map +1 -0
  48. package/{dist → lib/typescript/src}/@types/RadarNativeInterface.d.ts +18 -7
  49. package/lib/typescript/src/@types/RadarNativeInterface.d.ts.map +1 -0
  50. package/{dist → lib/typescript/src}/@types/types.d.ts +5 -3
  51. package/lib/typescript/src/@types/types.d.ts.map +1 -0
  52. package/lib/typescript/src/NativeRadar.d.ts +87 -0
  53. package/lib/typescript/src/NativeRadar.d.ts.map +1 -0
  54. package/{dist → lib/typescript/src}/index.d.ts +1 -0
  55. package/lib/typescript/src/index.d.ts.map +1 -0
  56. package/lib/typescript/src/index.native.d.ts +7 -0
  57. package/lib/typescript/src/index.native.d.ts.map +1 -0
  58. package/lib/typescript/src/plugin/types.d.ts +13 -0
  59. package/lib/typescript/src/plugin/types.d.ts.map +1 -0
  60. package/{plugin/build → lib/typescript/src/plugin}/withRadar.d.ts +2 -1
  61. package/lib/typescript/src/plugin/withRadar.d.ts.map +1 -0
  62. package/{plugin/build → lib/typescript/src/plugin}/withRadarAndroid.d.ts +1 -0
  63. package/lib/typescript/src/plugin/withRadarAndroid.d.ts.map +1 -0
  64. package/{plugin/build → lib/typescript/src/plugin}/withRadarIOS.d.ts +1 -0
  65. package/lib/typescript/src/plugin/withRadarIOS.d.ts.map +1 -0
  66. package/lib/typescript/src/version.d.ts +2 -0
  67. package/lib/typescript/src/version.d.ts.map +1 -0
  68. package/package.json +85 -34
  69. package/react-native.config.js +10 -0
  70. package/src/@types/RadarNativeInterface.ts +127 -0
  71. package/src/@types/types.ts +808 -0
  72. package/src/NativeRadar.ts +95 -0
  73. package/src/helpers.js +11 -0
  74. package/src/index.native.ts +419 -0
  75. package/src/index.tsx +22 -0
  76. package/src/index.web.js +528 -0
  77. package/{plugin/build/types.d.ts → src/plugin/types.ts} +1 -1
  78. package/src/plugin/withRadar.ts +39 -0
  79. package/src/plugin/withRadarAndroid.ts +147 -0
  80. package/src/plugin/withRadarIOS.ts +80 -0
  81. package/src/ui/autocomplete.jsx +324 -0
  82. package/src/ui/back.png +0 -0
  83. package/src/ui/close.png +0 -0
  84. package/src/ui/images.js +5 -0
  85. package/src/ui/map-logo.png +0 -0
  86. package/src/ui/map.jsx +122 -0
  87. package/src/ui/marker.png +0 -0
  88. package/src/ui/radar-logo.png +0 -0
  89. package/src/ui/search.png +0 -0
  90. package/src/ui/styles.js +125 -0
  91. package/src/version.ts +3 -0
  92. package/android/build.gradle.template +0 -49
  93. package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  94. package/android/gradle/wrapper/gradle-wrapper.properties +0 -6
  95. package/android/gradlew +0 -160
  96. package/android/gradlew.bat +0 -90
  97. package/android/proguard-rules.pro +0 -4
  98. package/android/src/main/java/io/radar/react/RNRadarPackage.java +0 -29
  99. package/dist/@types/RadarNativeInterface.js +0 -2
  100. package/dist/@types/types.js +0 -150
  101. package/dist/helpers.d.ts +0 -2
  102. package/dist/helpers.js +0 -11
  103. package/dist/index.js +0 -29
  104. package/dist/index.native.d.ts +0 -3
  105. package/dist/index.native.js +0 -150
  106. package/dist/index.web.d.ts +0 -113
  107. package/dist/index.web.js +0 -516
  108. package/dist/ui/autocomplete.d.ts +0 -5
  109. package/dist/ui/autocomplete.js +0 -206
  110. package/dist/ui/images.d.ts +0 -5
  111. package/dist/ui/images.js +0 -8
  112. package/dist/ui/map.d.ts +0 -6
  113. package/dist/ui/map.js +0 -122
  114. package/dist/ui/styles.d.ts +0 -172
  115. package/dist/ui/styles.js +0 -125
  116. package/ios/Cartfile.private +0 -1
  117. package/ios/Cartfile.resolved +0 -1
  118. package/ios/Cartfile.resolved.template +0 -1
  119. package/ios/RNRadar.xcodeproj/project.pbxproj +0 -521
  120. package/ios/RNRadar.xcodeproj/xcshareddata/xcschemes/RNRadar.xcscheme +0 -76
  121. package/plugin/build/index.d.ts +0 -3
  122. package/plugin/build/index.js +0 -6
  123. package/plugin/build/types.js +0 -2
  124. package/plugin/build/withRadar.js +0 -26
  125. package/plugin/build/withRadarAndroid.js +0 -98
  126. package/plugin/build/withRadarIOS.js +0 -76
  127. package/react-native-radar.podspec +0 -19
  128. /package/{dist → lib/commonjs}/ui/back.png +0 -0
  129. /package/{dist → lib/commonjs}/ui/close.png +0 -0
  130. /package/{dist → lib/commonjs}/ui/map-logo.png +0 -0
  131. /package/{dist → lib/commonjs}/ui/marker.png +0 -0
  132. /package/{dist → lib/commonjs}/ui/radar-logo.png +0 -0
  133. /package/{dist → lib/commonjs}/ui/search.png +0 -0
@@ -0,0 +1,528 @@
1
+ import RadarJS from 'radar-sdk-js';
2
+ import { VERSION } from './version';
3
+
4
+ let throws = false;
5
+ const throwOnUnimplemented = (value) => {
6
+ throws = value
7
+ }
8
+
9
+ const initialize = (publishableKey) => {
10
+ RadarJS.initialize(publishableKey);
11
+ }
12
+
13
+ const setLogLevel = (level) => {
14
+ if (throws) throw new Error("setLogLevel() is not implemented on web");
15
+ };
16
+
17
+ const setUserId = (userId) => {
18
+ RadarJS.setUserId(userId);
19
+ };
20
+
21
+ const getUserId = () => {
22
+ if (throws) throw new Error("getUserId() is not implemented on web");
23
+ return new Promise((resolve, reject) => { reject("getUserId() is not implemented on web") });
24
+ }
25
+
26
+ const setDeviceId = (deviceId, installId) => {
27
+ RadarJS.setDeviceId(deviceId, installId);
28
+ }
29
+ const setDeviceType = (deviceType) => {
30
+ RadarJS.setDeviceType(deviceType);
31
+ }
32
+
33
+ const setRequestHeaders = (headers) => {
34
+ RadarJS.setRequestHeaders(headers);
35
+ }
36
+
37
+ const setDescription = (description) => {
38
+ RadarJS.setDescription(description);
39
+ };
40
+
41
+ const getDescription = () => {
42
+ if (throws) throw new Error("getDescription() is not implemented on web");
43
+ return new Promise((resolve, reject) => { reject("getDescription() is not implemented on web") });
44
+ }
45
+
46
+ const setMetadata = (metadata) => {
47
+ RadarJS.setMetadata(metadata);
48
+ };
49
+
50
+ const getMetadata = () => {
51
+ if (throws) throw new Error("getMetadata() is not implemented on web");
52
+ return new Promise((resolve, reject) => { reject("getMetadata() is not implemented on web") });
53
+ }
54
+
55
+ const setAnonymousTrackingEnabled = () => {
56
+ if (throws) throw new Error("setAnonymousTrackingEnabled() is not implemented on web");
57
+ }
58
+
59
+ const getPermissionsStatus = () => {
60
+ return new Promise(resolve => {
61
+ const navigator = window.navigator;
62
+
63
+ if (!navigator.permissions) {
64
+ resolve({
65
+ status: 'UNKNOWN'
66
+ });
67
+ } else {
68
+ navigator.permissions.query({ name: 'geolocation' }).then((result) => {
69
+ resolve({
70
+ status: result.state === 'granted' ? 'GRANTED_FOREGROUND' : 'DENIED',
71
+ });
72
+ });
73
+ }
74
+ });
75
+ };
76
+
77
+ const requestPermissions = (background) => {
78
+ if (throws) throw new Error("requestPermissions() is not implemented on web");
79
+ return new Promise((resolve, reject) => { reject("requestPermissions() is not implemented on web") });
80
+ };
81
+
82
+ const getLocation = () => {
83
+ return new Promise((resolve, reject) => {
84
+ RadarJS.getLocation((err, result) => {
85
+ if (err)
86
+ reject(err);
87
+ else
88
+ resolve(result);
89
+ })
90
+ });
91
+ };
92
+
93
+ const trackOnce = (options) => {
94
+ return new Promise((resolve, reject) => {
95
+ const callback = (err, { status, location, user, events }) => {
96
+ if (err) {
97
+ reject(err);
98
+ } else {
99
+ resolve({
100
+ status,
101
+ location,
102
+ user,
103
+ events,
104
+ });
105
+ }
106
+ };
107
+
108
+ if (options) {
109
+ RadarJS.trackOnce(options.location ? options.location : options, callback);
110
+ } else {
111
+ RadarJS.trackOnce(callback);
112
+ }
113
+ });
114
+ };
115
+
116
+ const trackVerified = () => {
117
+ if (throws) throw new Error("trackVerified() is not implemented on web");
118
+ return new Promise((resolve, reject) => { reject("trackVerified() is not implemented on web") });
119
+ };
120
+
121
+ const getVerifiedLocationToken = () => {
122
+ if (throws) throw new Error("getVerifiedLocationToken() is not implemented on web");
123
+ return new Promise((resolve, reject) => { reject("getVerifiedLocationToken() is not implemented on web") });
124
+ };
125
+
126
+ const startTrackingEfficient = () => {
127
+ if (throws) throw new Error("startTrackingEfficient() is not implemented on web");
128
+ };
129
+
130
+ const startTrackingResponsive = () => {
131
+ if (throws) throw new Error("startTrackingResponsive() is not implemented on web");
132
+ };
133
+
134
+ const startTrackingContinuous = () => {
135
+ if (throws) throw new Error("startTrackingContinuous() is not implemented on web");
136
+ };
137
+
138
+ const startTrackingCustom = (options) => {
139
+ if (throws) throw new Error("startTrackingCustom() is not implemented on web");
140
+ };
141
+
142
+ const startTrackingVerified = (options) => {
143
+ if (throws) throw new Error("startTrackingVerified() is not implemented on web");
144
+ }
145
+
146
+ const mockTracking = (options) => {
147
+ if (throws) throw new Error("mockTracking() is not implemented on web");
148
+ };
149
+
150
+ const stopTracking = () => {
151
+ if (throws) throw new Error("stopTracking() is not implemented on web");
152
+ };
153
+
154
+ const stopTrackingVerified = () => {
155
+ if (throws) throw new Error("stopTrackingVerified() is not implemented on web");
156
+ }
157
+
158
+ const isTracking = () => {
159
+ if (throws) throw new Error("isTracking() is not implemented on web");
160
+ return new Promise((resolve, reject) => { reject("isTracking() is not implemented on web") });
161
+ }
162
+
163
+ const getTrackingOptions = () => {
164
+ if (throws) throw new Error("getTrackingOptions() is not implemented on web");
165
+ return new Promise((resolve, reject) => { reject("getTrackingOptions() is not implemented on web") });
166
+ }
167
+
168
+ const isUsingRemoteTrackingOptions = () => {
169
+ if (throws) throw new Error("isUsingRemoteTrackingOptions() is not implemented on web");
170
+ return new Promise((resolve, reject) => { reject("isUsingRemoteTrackingOptions() is not implemented on web") });
171
+ }
172
+
173
+ const setForegroundServiceOptions = (options) => {
174
+ if (throws) throw new Error("setForegroundServiceOptions() is not implemented on web");
175
+ };
176
+
177
+ const setNotificationOptions = (options) => {
178
+ if (throws) throw new Error("setNotificationOptions() is not implemented on web");
179
+ }
180
+
181
+ const getTripOptions = () => {
182
+ if (throws) throw new Error("getTripOptions() is not implemented on web");
183
+ return new Promise((resolve, reject) => { reject("getTripOptions() is not implemented on web") });
184
+ }
185
+
186
+ const startTrip = (options) => {
187
+ if (options.tripOptions) {
188
+ options = options.tripOptions;
189
+ }
190
+ console.log(options)
191
+ return new Promise((resolve, reject) => {
192
+ const callback = (err, { trip, events, status }) => {
193
+ if (err) {
194
+ reject(err);
195
+ } else {
196
+ resolve({
197
+ trip,
198
+ events,
199
+ status
200
+ });
201
+ }
202
+ };
203
+
204
+ RadarJS.startTrip(options, callback);
205
+ });
206
+ };
207
+
208
+ const completeTrip = () => {
209
+ return new Promise((resolve, reject) => {
210
+ const callback = (err, { trip, events, status }) => {
211
+ if (err) {
212
+ reject(err);
213
+ } else {
214
+ resolve({
215
+ trip,
216
+ events,
217
+ status
218
+ });
219
+ }
220
+ };
221
+
222
+ RadarJS.completeTrip(callback);
223
+ });
224
+ };
225
+
226
+ const cancelTrip = () => {
227
+ return new Promise((resolve, reject) => {
228
+ const callback = (err, { trip, events, status }) => {
229
+ if (err) {
230
+ reject(err);
231
+ } else {
232
+ resolve({
233
+ trip,
234
+ events,
235
+ status
236
+ });
237
+ }
238
+ };
239
+
240
+ RadarJS.cancelTrip(callback);
241
+ });
242
+ };
243
+
244
+ const updateTrip = (tripOptions) => {
245
+ return new Promise((resolve, reject) => {
246
+ const callback = (err, { trip, events, status }) => {
247
+ if (err) {
248
+ reject(err);
249
+ } else {
250
+ resolve({
251
+ trip,
252
+ events,
253
+ status
254
+ });
255
+ }
256
+ };
257
+
258
+ RadarJS.updateTrip(tripOptions.options, tripOptions.status, callback);
259
+ });
260
+ };
261
+
262
+ const acceptEvent = (eventId, verifiedPlaceId) => {
263
+ if (throws) throw new Error("acceptEvent() is not implemented on web");
264
+ };
265
+
266
+ const rejectEvent = (eventId) => {
267
+ if (throws) throw new Error("rejectEvent() is not implemented on web");
268
+ };
269
+
270
+ const getContext = (options) => {
271
+ return new Promise((resolve, reject) => {
272
+ const callback = (err, { status, location, context }) => {
273
+ if (err) {
274
+ reject(err);
275
+ } else {
276
+ resolve({
277
+ status,
278
+ location,
279
+ context,
280
+ });
281
+ }
282
+ };
283
+
284
+ if (options) {
285
+ RadarJS.getContext(options, callback);
286
+ } else {
287
+ RadarJS.getContext(callback);
288
+ }
289
+ });
290
+ };
291
+
292
+ const searchPlaces = (options) => {
293
+ return new Promise((resolve, reject) => {
294
+ RadarJS.searchPlaces(options, (err, { status, location, places }) => {
295
+ if (err) {
296
+ reject(err);
297
+ } else {
298
+ resolve({
299
+ status,
300
+ location,
301
+ places,
302
+ });
303
+ }
304
+ });
305
+ });
306
+ };
307
+
308
+ const searchGeofences = (options) => {
309
+ return new Promise((resolve, reject) => {
310
+ RadarJS.searchGeofences(options, (err, { status, location, geofences }) => {
311
+ if (err) {
312
+ reject(err);
313
+ } else {
314
+ resolve({
315
+ status,
316
+ location,
317
+ geofences,
318
+ });
319
+ }
320
+ });
321
+ });
322
+ };
323
+
324
+ const autocomplete = (options) => {
325
+ return new Promise((resolve, reject) => {
326
+ RadarJS.autocomplete(options, (err, { status, addresses }) => {
327
+ if (err) {
328
+ reject(err);
329
+ } else {
330
+ resolve({
331
+ status,
332
+ addresses,
333
+ });
334
+ }
335
+ });
336
+ });
337
+ };
338
+
339
+ const geocode = (options) => {
340
+ return new Promise((resolve, reject) => {
341
+ let newOptions = options;
342
+ if (typeof options === 'string') {
343
+ newOptions = {
344
+ query: options
345
+ };
346
+ } else if (options.address) {
347
+ newOptions.query = options.address;
348
+ }
349
+ RadarJS.geocode(newOptions, (err, { status, addresses }) => {
350
+ if (err) {
351
+ reject(err);
352
+ } else {
353
+ resolve({
354
+ status,
355
+ addresses,
356
+ });
357
+ }
358
+ });
359
+ });
360
+ };
361
+
362
+ const reverseGeocode = (options) => {
363
+ return new Promise((resolve, reject) => {
364
+ const callback = (err, { status, addresses }) => {
365
+ if (err) {
366
+ reject(err);
367
+ } else {
368
+ resolve({
369
+ status,
370
+ addresses,
371
+ });
372
+ }
373
+ };
374
+
375
+ if (options) {
376
+ RadarJS.reverseGeocode(options, callback);
377
+ } else {
378
+ RadarJS.reverseGeocode(callback);
379
+ }
380
+ });
381
+ };
382
+
383
+ const ipGeocode = () => {
384
+ return new Promise((resolve, reject) => {
385
+ RadarJS.ipGeocode((err, { status, address }) => {
386
+ if (err) {
387
+ reject(err);
388
+ } else {
389
+ resolve({
390
+ status,
391
+ address,
392
+ });
393
+ }
394
+ });
395
+ });
396
+ };
397
+
398
+ const validateAddress = (options) => {
399
+ return new Promise((resolve, reject) => {
400
+ RadarJS.validateAddress(options, (err, { status, address }) => {
401
+ if (err) {
402
+ reject(err);
403
+ } else {
404
+ resolve({
405
+ status,
406
+ address
407
+ })
408
+ }
409
+ });
410
+ })
411
+ };
412
+
413
+ const getDistance = (options) => {
414
+ return new Promise((resolve, reject) => {
415
+ RadarJS.getDistance(options, (err, { status, routes }) => {
416
+ if (err) {
417
+ reject(err);
418
+ } else {
419
+ resolve({
420
+ status,
421
+ routes,
422
+ });
423
+ }
424
+ });
425
+ });
426
+ };
427
+
428
+ const getMatrix = (options) => {
429
+ return new Promise((resolve, reject) => {
430
+ RadarJS.getMatrix(options, (err, { origins, destinations, matrix, status }) => {
431
+ if (err) {
432
+ reject(err);
433
+ } else {
434
+ resolve({
435
+ origins,
436
+ destinations,
437
+ matrix,
438
+ status,
439
+ });
440
+ }
441
+ });
442
+ });
443
+ };
444
+
445
+ const logConversion = (options) => {
446
+ if (throws) throw new Error("logConversion() is not implemented on web");
447
+ return new Promise((resolve, reject) => { reject("logConversion() is not implemented on web") });
448
+ }
449
+
450
+ const sendEvent = (name, metadata) => {
451
+ if (throws) throw new Error("sendEvent() is not implemented on web");
452
+ }
453
+
454
+ const on = (event, callback) => {
455
+ if (throws) throw new Error("on() is not implemented on web");
456
+ };
457
+
458
+ const off = (event, callback) => {
459
+ if (throws) throw new Error("off() is not implemented on web");
460
+ };
461
+
462
+ const nativeSdkVersion = () => {
463
+ return new Promise((resolve, reject) => { resolve(RadarJS.VERSION) });
464
+ }
465
+
466
+ const rnSdkVersion = () => VERSION;
467
+
468
+ const Radar = {
469
+ initialize,
470
+ setLogLevel,
471
+ setUserId,
472
+ getUserId,
473
+ setDescription,
474
+ getDescription,
475
+ setMetadata,
476
+ getMetadata,
477
+ setAnonymousTrackingEnabled,
478
+ getPermissionsStatus,
479
+ requestPermissions,
480
+ getLocation,
481
+ trackOnce,
482
+ trackVerified,
483
+ getVerifiedLocationToken,
484
+ startTrackingEfficient,
485
+ startTrackingResponsive,
486
+ startTrackingContinuous,
487
+ startTrackingCustom,
488
+ startTrackingVerified,
489
+ mockTracking,
490
+ stopTracking,
491
+ stopTrackingVerified,
492
+ isTracking,
493
+ getTrackingOptions,
494
+ isUsingRemoteTrackingOptions,
495
+ setForegroundServiceOptions,
496
+ setNotificationOptions,
497
+ getTripOptions,
498
+ startTrip,
499
+ completeTrip,
500
+ cancelTrip,
501
+ updateTrip,
502
+ acceptEvent,
503
+ rejectEvent,
504
+ getContext,
505
+ searchPlaces,
506
+ searchGeofences,
507
+ autocomplete,
508
+ geocode,
509
+ reverseGeocode,
510
+ ipGeocode,
511
+ validateAddress,
512
+ getDistance,
513
+ getMatrix,
514
+ logConversion,
515
+ sendEvent,
516
+ on,
517
+ off,
518
+ nativeSdkVersion,
519
+ rnSdkVersion,
520
+
521
+ // only for web, these should be called via RadarRNWeb instead of Radar for typing
522
+ throwOnUnimplemented,
523
+ setDeviceId,
524
+ setDeviceType,
525
+ setRequestHeaders,
526
+ };
527
+
528
+ export default Radar;
@@ -9,4 +9,4 @@ export interface RadarPluginProps {
9
9
  androidActivityRecognition?: boolean;
10
10
  addRadarSDKMotion?: boolean;
11
11
  iosNSMotionUsageDescription?: string;
12
- }
12
+ }
@@ -0,0 +1,39 @@
1
+ import {
2
+ ConfigPlugin,
3
+ createRunOncePlugin,
4
+ WarningAggregator,
5
+ } from "expo/config-plugins";
6
+
7
+
8
+ import { withRadarAndroid } from "./withRadarAndroid";
9
+ import { withRadarIOS } from "./withRadarIOS";
10
+ const pkg = require("../../../package.json");
11
+
12
+ import type { RadarPluginProps } from "./types";
13
+
14
+ const withRadarPlugin: ConfigPlugin<RadarPluginProps> = (config, args = {}) => {
15
+ try {
16
+ config = withRadarAndroid(config, args);
17
+ } catch (e) {
18
+ WarningAggregator.addWarningAndroid(
19
+ "react-native-radar",
20
+ "There was a problem configuring react-native-radar in your native Android project: " +
21
+ e
22
+ );
23
+ }
24
+ try {
25
+ config = withRadarIOS(config, args);
26
+ } catch (e) {
27
+ WarningAggregator.addWarningIOS(
28
+ "react-native-radar",
29
+ "There was a problem configuring react-native-radar in your native iOS project: " +
30
+ e
31
+ );
32
+ }
33
+
34
+ return config;
35
+ };
36
+
37
+ const withRadar = createRunOncePlugin(withRadarPlugin, pkg.name, pkg.version);
38
+
39
+ export default withRadar;
@@ -0,0 +1,147 @@
1
+ import { ExpoConfig } from "expo/config";
2
+
3
+ import {
4
+ withAppBuildGradle,
5
+ AndroidConfig,
6
+ withDangerousMod,
7
+ } from "expo/config-plugins";
8
+ import fs from "fs";
9
+ import path from "path";
10
+
11
+ import { RadarPluginProps } from "./types";
12
+
13
+ export const withRadarAndroid = (
14
+ config: ExpoConfig,
15
+ args: RadarPluginProps
16
+ ) => {
17
+ config = withAndroidPermissions(config, args);
18
+
19
+ config = withDangerousMod(config, [
20
+ "android",
21
+ async (config) => {
22
+ if (!args.androidFraud) {
23
+ return config;
24
+ }
25
+ // Get the path to the Android folder
26
+ const androidPath = path.join(
27
+ config.modRequest.projectRoot,
28
+ "android",
29
+ "app",
30
+ "src",
31
+ "main",
32
+ "res",
33
+ "xml"
34
+ );
35
+
36
+ // Check if the directory exists, if not, create it
37
+ if (!fs.existsSync(androidPath)) {
38
+ fs.mkdirSync(androidPath, { recursive: true });
39
+ }
40
+
41
+ // Create the path to the new file
42
+ const newFilePath = path.join(androidPath, "network_security_config.xml");
43
+
44
+ // Define xml content
45
+
46
+ const xml = `<?xml version="1.0" encoding="utf-8"?>
47
+ <network-security-config>
48
+ <!-- for React Native -->
49
+ <domain-config cleartextTrafficPermitted="true">
50
+ <domain includeSubdomains="true">localhost</domain>
51
+ </domain-config>
52
+
53
+ <!-- for SSL pinning -->
54
+ <domain-config cleartextTrafficPermitted="false">
55
+ <domain includeSubdomains="true">api-verified.radar.io</domain>
56
+ <pin-set>
57
+ <pin digest="SHA-256">15ktYXSSU2llpy7YyCgeqUKDBkjcimK/weUcec960sI=</pin>
58
+ <pin digest="SHA-256">15ktYXSSU2llpy7YyCgeqUKDBkjcimK/weUcec960sI=</pin>
59
+ </pin-set>
60
+ </domain-config>
61
+ </network-security-config>`;
62
+
63
+ // Write to the new file
64
+ fs.writeFileSync(newFilePath, xml);
65
+
66
+ return config;
67
+ },
68
+ ]);
69
+
70
+ return withAppBuildGradle(config, (config) => {
71
+ if (config.modResults.language === "groovy") {
72
+ config.modResults.contents = modifyAppBuildGradle(
73
+ config.modResults.contents,
74
+ args.androidFraud ?? false
75
+ );
76
+ } else {
77
+ throw new Error(
78
+ "Cannot configure Sentry in the app gradle because the build.gradle is not groovy"
79
+ );
80
+ }
81
+ return config;
82
+ });
83
+ };
84
+
85
+ function withAndroidPermissions(
86
+ config: any,
87
+ args: RadarPluginProps
88
+ ): ExpoConfig {
89
+ const isAndroidBackgroundLocationEnabled = !!args.androidBackgroundPermission;
90
+ const enableAndroidForegroundService = !!args.androidForegroundService;
91
+ const enableAndroidActivityRecognition = !!args.androidActivityRecognition;
92
+ return AndroidConfig.Permissions.withPermissions(
93
+ config,
94
+ [
95
+ isAndroidBackgroundLocationEnabled &&
96
+ "android.permission.ACCESS_BACKGROUND_LOCATION",
97
+ enableAndroidForegroundService && "android.permission.FOREGROUND_SERVICE",
98
+ enableAndroidForegroundService &&
99
+ "android.permission.FOREGROUND_SERVICE_LOCATION",
100
+ enableAndroidActivityRecognition &&
101
+ "android.permission.ACTIVITY_RECOGNITION",
102
+ ].filter(Boolean) as string[]
103
+ );
104
+ }
105
+
106
+ function modifyAppBuildGradle(buildGradle: string, androidFraud: boolean) {
107
+ let hasLocationService = false;
108
+ let hasPlayIntegrity = false;
109
+ if (
110
+ buildGradle.includes(
111
+ 'com.google.android.gms:play-services-location:21.0.1"'
112
+ )
113
+ ) {
114
+ hasLocationService = true;
115
+ }
116
+
117
+ if (buildGradle.includes('com.google.android.play:integrity:1.2.0"')) {
118
+ hasPlayIntegrity = true;
119
+ }
120
+
121
+ const pattern = /^dependencies {/m;
122
+
123
+ if (!buildGradle.match(pattern)) {
124
+ throw new Error(
125
+ `Failed to find react.gradle script in android/app/build.gradle.
126
+ This is required for react-native-radar to function properly.
127
+ Please ensure your android/app/build.gradle includes the react.gradle script.
128
+ Current build.gradle content: ${buildGradle}`
129
+ );
130
+ }
131
+
132
+ let replacementString =
133
+ "\n\n" +
134
+ (!hasLocationService
135
+ ? ' implementation "com.google.android.gms:play-services-location:21.0.1"'
136
+ : "");
137
+
138
+ if (androidFraud && !hasPlayIntegrity) {
139
+ replacementString +=
140
+ "\n\n" + ' implementation "com.google.android.play:integrity:1.2.0"';
141
+ }
142
+
143
+ return buildGradle.replace(
144
+ pattern,
145
+ (match: string) => match + replacementString
146
+ );
147
+ }