@woosmap/react-native-plugin-geofencing 0.1.6 → 0.1.9

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 (100) hide show
  1. package/README.md +219 -19
  2. package/android/build.gradle +7 -0
  3. package/android/src/main/java/com/reactnativeplugingeofencing/PluginGeofencingModule.java +324 -31
  4. package/android/src/main/java/com/reactnativeplugingeofencing/WoosRegionReadyListener.java +1 -7
  5. package/android/src/main/java/com/reactnativeplugingeofencing/WoosmapMessageAndKey.java +17 -0
  6. package/android/src/main/java/com/reactnativeplugingeofencing/WoosmapTask.java +299 -0
  7. package/android/src/main/java/com/reactnativeplugingeofencing/WoosmapUtil.java +118 -2
  8. package/ios/DataLocation.swift +4 -0
  9. package/ios/DataPOI.swift +11 -0
  10. package/ios/DataRegion.swift +33 -3
  11. package/ios/PluginGeofencing.m +43 -0
  12. package/ios/PluginGeofencing.swift +377 -22
  13. package/ios/WoosmapGeofenceMessage.swift +12 -0
  14. package/ios/WoosmapGeofenceService.swift +203 -30
  15. package/lib/commonjs/index.js +171 -68
  16. package/lib/commonjs/index.js.map +1 -1
  17. package/lib/commonjs/{Airship.js → internal/Airship.js} +0 -0
  18. package/lib/commonjs/internal/Airship.js.map +1 -0
  19. package/lib/commonjs/{Location.js → internal/Location.js} +0 -0
  20. package/lib/commonjs/{Location.js.map → internal/Location.js.map} +1 -1
  21. package/lib/commonjs/{MarketingCloud.js → internal/MarketingCloud.js} +0 -0
  22. package/lib/commonjs/internal/MarketingCloud.js.map +1 -0
  23. package/lib/{module → commonjs/internal}/Poi.js +10 -1
  24. package/lib/commonjs/internal/Poi.js.map +1 -0
  25. package/lib/commonjs/{Region.js → internal/Region.js} +0 -0
  26. package/lib/commonjs/internal/Region.js.map +1 -0
  27. package/lib/commonjs/{Visit.js → internal/Visit.js} +0 -0
  28. package/lib/commonjs/internal/Visit.js.map +1 -0
  29. package/lib/commonjs/{Zoi.js → internal/Zoi.js} +0 -0
  30. package/lib/commonjs/internal/Zoi.js.map +1 -0
  31. package/lib/commonjs/internal/nativeInterface.js +18 -0
  32. package/lib/commonjs/internal/nativeInterface.js.map +1 -0
  33. package/lib/commonjs/internal/types.js +2 -0
  34. package/lib/commonjs/internal/types.js.map +1 -0
  35. package/lib/module/index.js +155 -53
  36. package/lib/module/index.js.map +1 -1
  37. package/lib/module/{Airship.js → internal/Airship.js} +0 -0
  38. package/lib/module/internal/Airship.js.map +1 -0
  39. package/lib/module/{Location.js → internal/Location.js} +0 -0
  40. package/lib/module/internal/Location.js.map +1 -0
  41. package/lib/module/{MarketingCloud.js → internal/MarketingCloud.js} +0 -0
  42. package/lib/module/internal/MarketingCloud.js.map +1 -0
  43. package/lib/{commonjs → module/internal}/Poi.js +2 -3
  44. package/lib/module/internal/Poi.js.map +1 -0
  45. package/lib/module/{Region.js → internal/Region.js} +0 -0
  46. package/lib/module/internal/Region.js.map +1 -0
  47. package/lib/module/{Visit.js → internal/Visit.js} +0 -0
  48. package/lib/module/internal/Visit.js.map +1 -0
  49. package/lib/module/{Zoi.js → internal/Zoi.js} +0 -0
  50. package/lib/module/internal/Zoi.js.map +1 -0
  51. package/lib/module/internal/nativeInterface.js +9 -0
  52. package/lib/module/internal/nativeInterface.js.map +1 -0
  53. package/lib/module/internal/types.js +2 -0
  54. package/lib/module/internal/types.js.map +1 -0
  55. package/lib/typescript/index.d.ts +63 -4
  56. package/lib/typescript/{Airship.d.ts → internal/Airship.d.ts} +0 -0
  57. package/lib/typescript/{Location.d.ts → internal/Location.d.ts} +0 -0
  58. package/lib/typescript/{MarketingCloud.d.ts → internal/MarketingCloud.d.ts} +0 -0
  59. package/lib/typescript/{Poi.d.ts → internal/Poi.d.ts} +4 -2
  60. package/lib/typescript/{Region.d.ts → internal/Region.d.ts} +0 -0
  61. package/lib/typescript/{Visit.d.ts → internal/Visit.d.ts} +0 -0
  62. package/lib/typescript/{Zoi.d.ts → internal/Zoi.d.ts} +0 -0
  63. package/lib/typescript/internal/nativeInterface.d.ts +2 -0
  64. package/lib/typescript/internal/types.d.ts +18 -0
  65. package/package.json +1 -1
  66. package/src/index.tsx +173 -53
  67. package/src/{Airship.tsx → internal/Airship.tsx} +0 -0
  68. package/src/{Location.tsx → internal/Location.tsx} +0 -0
  69. package/src/{MarketingCloud.tsx → internal/MarketingCloud.tsx} +0 -0
  70. package/src/{Poi.tsx → internal/Poi.tsx} +4 -3
  71. package/src/{Region.tsx → internal/Region.tsx} +0 -0
  72. package/src/{Visit.tsx → internal/Visit.tsx} +0 -0
  73. package/src/{Zoi.tsx → internal/Zoi.tsx} +0 -0
  74. package/src/internal/nativeInterface.tsx +8 -0
  75. package/src/internal/types.tsx +20 -0
  76. package/android/.gradle/7.1.1/dependencies-accessors/dependencies-accessors.lock +0 -0
  77. package/android/.gradle/7.1.1/dependencies-accessors/gc.properties +0 -0
  78. package/android/.gradle/7.1.1/executionHistory/executionHistory.lock +0 -0
  79. package/android/.gradle/7.1.1/fileChanges/last-build.bin +0 -0
  80. package/android/.gradle/7.1.1/fileHashes/fileHashes.lock +0 -0
  81. package/android/.gradle/7.1.1/gc.properties +0 -0
  82. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  83. package/android/.gradle/buildOutputCleanup/cache.properties +0 -2
  84. package/android/.gradle/checksums/checksums.lock +0 -0
  85. package/android/.gradle/checksums/md5-checksums.bin +0 -0
  86. package/android/.gradle/checksums/sha1-checksums.bin +0 -0
  87. package/android/.gradle/vcs-1/gc.properties +0 -0
  88. package/lib/commonjs/Airship.js.map +0 -1
  89. package/lib/commonjs/MarketingCloud.js.map +0 -1
  90. package/lib/commonjs/Poi.js.map +0 -1
  91. package/lib/commonjs/Region.js.map +0 -1
  92. package/lib/commonjs/Visit.js.map +0 -1
  93. package/lib/commonjs/Zoi.js.map +0 -1
  94. package/lib/module/Airship.js.map +0 -1
  95. package/lib/module/Location.js.map +0 -1
  96. package/lib/module/MarketingCloud.js.map +0 -1
  97. package/lib/module/Poi.js.map +0 -1
  98. package/lib/module/Region.js.map +0 -1
  99. package/lib/module/Visit.js.map +0 -1
  100. package/lib/module/Zoi.js.map +0 -1
package/README.md CHANGED
@@ -33,12 +33,14 @@ For iOS
33
33
  </array>
34
34
 
35
35
  ```
36
+
36
37
  - **Podfile**: configure to use ```use_frameworks!``` and ```platform :ios, '12.0'```
37
38
  if you are using **M1 Mac** Update pod post installation like
39
+
38
40
  ```
39
41
  post_install do |installer|
40
- installer.pods_project.targets.each do |target|
41
- target.build_configurations.each do |config|
42
+ installer.pods_project.targets.each do |target|
43
+ target.build_configurations.each do |config|
42
44
  config.build_settings["ONLY_ACTIVE_ARCH"] = "NO"
43
45
  config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '12.0'
44
46
  end
@@ -46,25 +48,28 @@ if you are using **M1 Mac** Update pod post installation like
46
48
  end
47
49
  ```
48
50
 
49
-
50
51
  ### Supported Platforms ###
52
+
51
53
  ---
54
+
52
55
  - iOS
53
56
  - Android
54
57
 
55
58
  ### Modules
59
+
56
60
  ---
57
- * **WoosmapGeofencing**: Woosmap contains methods to monitor location, regions.
61
+ - **WoosmapGeofencing**: Woosmap contains methods to monitor location, regions.
58
62
 
59
63
  ### Objects(Read Only)
64
+
60
65
  ---
61
- * **Location**: Represents the location object
62
- * **POI**: Represents Point of Interest
63
- * **Region**: Represents a geographical region/geofence
64
- * **Visit**: Represents a visit to a location/POI
65
- * **ZOI**: Represents Zone of Interest
66
- * **Airship**: Contains custom data related to Airship implementation
67
- * **MarketingCloud**: Contains custom data related to third party marketing cloud implementation
66
+ - **Location**: Represents the location object
67
+ - **POI**: Represents Point of Interest
68
+ - **Region**: Represents a geographical region/geofence
69
+ - **Visit**: Represents a visit to a location/POI
70
+ - **ZOI**: Represents Zone of Interest
71
+ - **Airship**: Contains custom data related to Airship implementation
72
+ - **MarketingCloud**: Contains custom data related to third party marketing cloud implementation
68
73
 
69
74
  ## Usage
70
75
 
@@ -76,6 +81,7 @@ import WoosmapGeofencing from 'react-native-plugin-geofencing';
76
81
  ```
77
82
 
78
83
  ### Check and request permissions
84
+
79
85
  ---
80
86
  Before initializing the SDK it is required that you request for required location permissions.
81
87
 
@@ -92,10 +98,10 @@ WoosmapGeofencing.getPermissionsStatus()
92
98
  ```
93
99
 
94
100
  Parameter status will be a string, one of:
95
- * `GRANTED_BACKGROUND` : User has granted location access even when app is not running in the foreground.
96
- * `GRANTED_FOREGROUND` : Location access is granted only while user is using the app.
97
- * `DENIED`: Location access is denied.
98
- * `UNKNOWN`: Without providing or denying any permission then it will return unknown.
101
+ - `GRANTED_BACKGROUND` : User has granted location access even when app is not running in the foreground.
102
+ - `GRANTED_FOREGROUND` : Location access is granted only while user is using the app.
103
+ - `DENIED`: Location access is denied.
104
+ - `UNKNOWN`: Without providing or denying any permission then it will return unknown.
99
105
 
100
106
  **_Please note_**: Plugin will not work as expected if location access is denied.
101
107
 
@@ -114,6 +120,7 @@ WoosmapGeofencing.requestPermissions(props.background)
114
120
  ```
115
121
 
116
122
  ### Initializing the plugin
123
+
117
124
  ---
118
125
 
119
126
  Plugin can be initialized by simply calling `initialize` method.
@@ -151,11 +158,13 @@ WoosmapGeofencing.setWoosmapApiKey(<privateKeyWoosmapAPI>)
151
158
  ```
152
159
 
153
160
  ### Tracking
161
+
154
162
  ---
155
163
 
156
164
  Once you have initialized the plugin and the user has authorized location permissions, you can start tracking the user’s location.
157
165
 
158
166
  To start tracking, call:
167
+
159
168
  ``` javascript
160
169
  WoosmapGeofencing.startTracking('liveTracking')
161
170
  .then((result: string) => {
@@ -168,6 +177,7 @@ WoosmapGeofencing.startTracking('liveTracking')
168
177
  ```
169
178
 
170
179
  To stop tracking, call:
180
+
171
181
  ``` javascript
172
182
  WoosmapGeofencing.stopTracking()
173
183
  .then((value: any) => {
@@ -180,11 +190,12 @@ WoosmapGeofencing.stopTracking()
180
190
 
181
191
  Method `startTracking` accepts only following tracking profiles
182
192
 
183
- * **liveTracking**
184
- * **passiveTracking**
185
- * **visitsTracking**
193
+ - **liveTracking**
194
+ - **passiveTracking**
195
+ - **visitsTracking**
186
196
 
187
197
  ### Tracking profile properties
198
+
188
199
  ---
189
200
 
190
201
  | Property | liveTracking | passiveTracking | visitsTracking
@@ -210,6 +221,7 @@ Method `startTracking` accepts only following tracking profiles
210
221
  | DOUBLEOfDayDataDuration | 30 | 30 | 30
211
222
 
212
223
  ### Listening to events
224
+
213
225
  ---
214
226
 
215
227
  **Location**
@@ -246,6 +258,7 @@ WoosmapGeofencing.clearLocationWatch(watchID)
246
258
  **Define the radius value**
247
259
 
248
260
  When you create a Geofence around a POI (previously imported from Woosmap), manually define the radius value:
261
+
249
262
  ```javascript
250
263
  WoosmapGeofencing.setPoiRadius("100")
251
264
  .then((value: string) => {
@@ -255,7 +268,9 @@ WoosmapGeofencing.setPoiRadius("100")
255
268
  alert('message: ' + error.message);
256
269
  });
257
270
  ```
271
+
258
272
  or choose the user_properties subfield that corresponds to radius value of the Geofence:
273
+
259
274
  ```javascript
260
275
  WoosmapGeofencing.setPoiRadius("radiusPOI")
261
276
  .then((value: string) => {
@@ -292,7 +307,9 @@ WoosmapGeofencing.clearRegionsWatch(watchID)
292
307
  alert('message: ' + error.message);
293
308
  });
294
309
  ```
310
+
295
311
  ### Initialize Salesforce MarketingCloud Connector
312
+
296
313
  ---
297
314
 
298
315
  The SDK needs some input like credentials and object key to perform the API call to Salesforce Marketing Cloud API.
@@ -313,7 +330,155 @@ The SDK needs some input like credentials and object key to perform the API call
313
330
  | zoiClassifiedExitedEventDefinitionKey | Set the EventDefinitionKey that you want to use for the Woosmap event `woos_zoi_classified_exited_event` | |
314
331
  | visitEventDefinitionKey | Set the EventDefinitionKey that you want to use for the Woosmap event `woos_Visit_event` |
315
332
 
316
- **Initialize the connector implementation**
333
+ ### Adding and removing regions
334
+
335
+ ---
336
+
337
+ Call `addRegion` method to add a region that you want to monitor.
338
+ Region type can be 'circle' or 'isochrone' only.
339
+ Method will accept an object with the following attributes:
340
+
341
+ - **regionId** - Id of the region
342
+ - **lat** - Latitude
343
+ - **lng** - Longitude
344
+ - **radius** - Radius in meters
345
+ - **type** - type of region
346
+
347
+ ##### Create a custom circle region
348
+
349
+ ``` javascript
350
+ var regionData = {
351
+ lat: 51.50998,
352
+ lng: -0.1337,
353
+ regionId: '7F91369E-467C-4CBD-8D41-6509815C4780',
354
+ radius: 100,
355
+ type: 'circle',
356
+ };
357
+ WoosmapGeofencing.addRegion(regionData)
358
+ .then((value: string) => {
359
+ console.log(value);
360
+ })
361
+ .catch((error: any) => {
362
+ console.error(error);
363
+ });
364
+ };
365
+ ```
366
+
367
+ ##### Create a custom isochrone region
368
+
369
+ ``` javascript
370
+ var regionData = {
371
+ lat: 51.50998,
372
+ lng: -0.1337,
373
+ regionId: '7F91369E-467C-4CBD-8D41-6509815C4780',
374
+ radius: 180,
375
+ type: 'isochrone',
376
+ };
377
+ WoosmapGeofencing.addRegion(regionData)
378
+ .then((value: string) => {
379
+ console.log(value);
380
+ })
381
+ .catch((error: any) => {
382
+ console.error(error);
383
+ });
384
+ };
385
+ ```
386
+
387
+ Call ```removeRegions``` method to remove a region that you are monitoring. Method will accept the following parameter, and passing a null value will remove all the regions.
388
+
389
+ ``` javascript
390
+ const request = "7F91369E-467C-4CBD-8D41-6509815C4780";
391
+ WoosmapGeofencing.removeRegions(request)
392
+ .then((value: string) => {
393
+ console.log(value);
394
+ })
395
+ .catch((error: any) => {
396
+ console.error(error);
397
+ });
398
+ ```
399
+
400
+ Or To Delete all Regions
401
+
402
+ ``` javascript
403
+ WoosmapGeofencing.removeRegions()
404
+ .then((value: string) => {
405
+ console.log(value);
406
+ })
407
+ .catch((error: any) => {
408
+ console.error(error);
409
+ });
410
+ ```
411
+
412
+ ### Local database operations
413
+
414
+ ---
415
+
416
+ - **Get POIs**: Call `getPois` method to get an array of POIs from the local db
417
+
418
+ ``` javascript
419
+
420
+ WoosmapGeofencing.getPois(optional locationid)
421
+ .then((value: Location[]) => {
422
+ console.log(String(value.length));
423
+ })
424
+ .catch((error: any) => {
425
+ console.error(error);
426
+ });
427
+ ```
428
+
429
+ - **Delete POIs**: Call `removePois` method to clear all POIs from the local db.
430
+
431
+ ``` javascript
432
+ WoosmapGeofencing.removePois()
433
+ .then((value: string) => {
434
+ console.log(value);
435
+ })
436
+ .catch((error: any) => {
437
+ console.error(error);
438
+ });
439
+ ```
440
+
441
+ - **Get Locations**: Call `getLocations` method to get an array of Locations from the local db.
442
+
443
+ ``` javascript
444
+
445
+ WoosmapGeofencing.getLocations(optional locationid)
446
+ .then((value: Location[]) => {
447
+ console.log(String(value.length));
448
+ })
449
+ .catch((error: any) => {
450
+ console.error(error);
451
+ });
452
+ ```
453
+
454
+ - **Delete Locations**: Call `removeLocations` method to clear all Locations info from the local db.
455
+
456
+ ``` javascript
457
+ WoosmapGeofencing.removeLocations()
458
+ .then((value: string) => {
459
+ console.log(value);
460
+ })
461
+ .catch((error: any) => {
462
+ console.error(error);
463
+ });
464
+ ```
465
+
466
+ - **Get Regions**: Call `getRegions` method to get an array of Regions from the local db. specify region id to retrieve specific region info
467
+
468
+ ``` javascript
469
+ WoosmapGeofencing.getRegions(optional regionid).
470
+ .then((value: Region[]) => {
471
+ Toast.show(String(value.length));
472
+ })
473
+ .catch((error: any) => {
474
+ console.error(error);
475
+ });
476
+ ```
477
+
478
+ ### Initialize the connector implementation
479
+
480
+ ---
481
+
317
482
  ``` javascript
318
483
  var sfmcCredentials = {
319
484
  authenticationBaseURI: "https://xxxxxxxxxx.auth.marketingcloudapis.com",
@@ -333,6 +498,41 @@ The SDK needs some input like credentials and object key to perform the API call
333
498
  });
334
499
  ```
335
500
 
501
+ ### Custom tracking profile
502
+
503
+ ---
504
+
505
+ If preset tracking profiles don’t fit with your use cases, you can build your own profile and uses the startCustomTracking() method. There are two way to host the json file:
506
+
507
+ - Include json file in the client application (local) for ios.
508
+ - For local mode put json file in assets folder in android.
509
+ - Host externally in a file folder in your information system (external)
510
+
511
+ ``` javascript
512
+ WoosmapGeofencing.startCustomTracking('local', 'localProfile.json')
513
+ .then((value: any) => {
514
+ console.log(value);
515
+ })
516
+ .catch((error: any) => {
517
+ alert('message: ' + error.message);
518
+ });
519
+ ```
520
+
521
+ or
522
+
523
+ ``` javascript
524
+ WoosmapGeofencing.startCustomTracking('external', 'https://raw.githubusercontent.com/lpernelle-wgs/files/master/customProfileLeo.json')
525
+ .then((value: any) => {
526
+ console.log(value);
527
+ })
528
+ .catch((error: any) => {
529
+ alert('message: ' + error.message);
530
+ });
531
+ ```
532
+
533
+ #### Build a custom tracking profile
534
+
535
+ Define tracking properties in a Json file that respect the Json Schema in the [Tracking properties page](https://developers.woosmap.com/products/geofencing-sdk/tracking-profiles/tracking-properties/).
336
536
 
337
537
  ## License
338
538
 
@@ -57,4 +57,11 @@ dependencies {
57
57
  //noinspection GradleDynamicVersion
58
58
  implementation "com.facebook.react:react-native:+" // From node_modules
59
59
  implementation("com.webgeoservices.woosmapgeofencing:woosmap-mobile-sdk:1.2.1")
60
+ implementation 'com.google.android.gms:play-services-maps:17.0.0'
61
+ implementation 'androidx.room:room-runtime:2.2.4'
62
+ annotationProcessor 'androidx.room:room-compiler:2.2.4'
63
+ implementation 'androidx.room:room-rxjava2:2.2.4'
64
+ implementation 'androidx.room:room-guava:2.2.4'
65
+
66
+
60
67
  }