@woosmap/react-native-plugin-geofencing 0.1.4 → 0.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 (78) hide show
  1. package/README.md +219 -20
  2. package/android/build.gradle +7 -0
  3. package/android/src/main/java/com/reactnativeplugingeofencing/PluginGeofencingModule.java +328 -35
  4. package/android/src/main/java/com/reactnativeplugingeofencing/WoosmapMessageAndKey.java +20 -3
  5. package/android/src/main/java/com/reactnativeplugingeofencing/WoosmapTask.java +299 -0
  6. package/android/src/main/java/com/reactnativeplugingeofencing/WoosmapUtil.java +108 -0
  7. package/ios/DataDistance.swift +14 -23
  8. package/ios/DataLocation.swift +16 -0
  9. package/ios/DataPOI.swift +11 -0
  10. package/ios/DataRegion.swift +32 -29
  11. package/ios/MarketingCloudEvents.swift +6 -6
  12. package/ios/PluginGeofencing.m +43 -0
  13. package/ios/PluginGeofencing.swift +380 -26
  14. package/ios/WoosmapGeofenceMessage.swift +12 -0
  15. package/ios/WoosmapGeofenceService.swift +203 -30
  16. package/lib/commonjs/index.js +171 -68
  17. package/lib/commonjs/index.js.map +1 -1
  18. package/lib/commonjs/{Airship.js → internal/Airship.js} +0 -0
  19. package/lib/commonjs/{Airship.js.map → internal/Airship.js.map} +0 -0
  20. package/lib/commonjs/{Location.js → internal/Location.js} +0 -0
  21. package/lib/commonjs/{Location.js.map → internal/Location.js.map} +0 -0
  22. package/lib/commonjs/{MarketingCloud.js → internal/MarketingCloud.js} +0 -0
  23. package/lib/commonjs/{MarketingCloud.js.map → internal/MarketingCloud.js.map} +0 -0
  24. package/lib/{module → commonjs/internal}/Poi.js +10 -1
  25. package/lib/commonjs/internal/Poi.js.map +1 -0
  26. package/lib/commonjs/{Region.js → internal/Region.js} +0 -0
  27. package/lib/commonjs/{Region.js.map → internal/Region.js.map} +0 -0
  28. package/lib/commonjs/{Visit.js → internal/Visit.js} +0 -0
  29. package/lib/commonjs/{Visit.js.map → internal/Visit.js.map} +0 -0
  30. package/lib/commonjs/{Zoi.js → internal/Zoi.js} +0 -0
  31. package/lib/commonjs/{Zoi.js.map → internal/Zoi.js.map} +0 -0
  32. package/lib/commonjs/internal/nativeInterface.js +18 -0
  33. package/lib/commonjs/internal/nativeInterface.js.map +1 -0
  34. package/lib/commonjs/internal/types.js +2 -0
  35. package/lib/commonjs/internal/types.js.map +1 -0
  36. package/lib/module/index.js +155 -53
  37. package/lib/module/index.js.map +1 -1
  38. package/lib/module/{Airship.js → internal/Airship.js} +0 -0
  39. package/lib/module/{Airship.js.map → internal/Airship.js.map} +0 -0
  40. package/lib/module/{Location.js → internal/Location.js} +0 -0
  41. package/lib/module/{Location.js.map → internal/Location.js.map} +0 -0
  42. package/lib/module/{MarketingCloud.js → internal/MarketingCloud.js} +0 -0
  43. package/lib/module/{MarketingCloud.js.map → internal/MarketingCloud.js.map} +0 -0
  44. package/lib/{commonjs → module/internal}/Poi.js +2 -3
  45. package/lib/module/internal/Poi.js.map +1 -0
  46. package/lib/module/{Region.js → internal/Region.js} +0 -0
  47. package/lib/module/{Region.js.map → internal/Region.js.map} +0 -0
  48. package/lib/module/{Visit.js → internal/Visit.js} +0 -0
  49. package/lib/module/{Visit.js.map → internal/Visit.js.map} +0 -0
  50. package/lib/module/{Zoi.js → internal/Zoi.js} +0 -0
  51. package/lib/module/{Zoi.js.map → internal/Zoi.js.map} +0 -0
  52. package/lib/module/internal/nativeInterface.js +9 -0
  53. package/lib/module/internal/nativeInterface.js.map +1 -0
  54. package/lib/module/internal/types.js +2 -0
  55. package/lib/module/internal/types.js.map +1 -0
  56. package/lib/typescript/index.d.ts +63 -4
  57. package/lib/typescript/{Airship.d.ts → internal/Airship.d.ts} +0 -0
  58. package/lib/typescript/{Location.d.ts → internal/Location.d.ts} +0 -0
  59. package/lib/typescript/{MarketingCloud.d.ts → internal/MarketingCloud.d.ts} +0 -0
  60. package/lib/typescript/{Poi.d.ts → internal/Poi.d.ts} +4 -2
  61. package/lib/typescript/{Region.d.ts → internal/Region.d.ts} +0 -0
  62. package/lib/typescript/{Visit.d.ts → internal/Visit.d.ts} +0 -0
  63. package/lib/typescript/{Zoi.d.ts → internal/Zoi.d.ts} +0 -0
  64. package/lib/typescript/internal/nativeInterface.d.ts +2 -0
  65. package/lib/typescript/internal/types.d.ts +18 -0
  66. package/package.json +1 -1
  67. package/src/index.tsx +173 -53
  68. package/src/{Airship.tsx → internal/Airship.tsx} +0 -0
  69. package/src/{Location.tsx → internal/Location.tsx} +0 -0
  70. package/src/{MarketingCloud.tsx → internal/MarketingCloud.tsx} +0 -0
  71. package/src/{Poi.tsx → internal/Poi.tsx} +4 -3
  72. package/src/{Region.tsx → internal/Region.tsx} +0 -0
  73. package/src/{Visit.tsx → internal/Visit.tsx} +0 -0
  74. package/src/{Zoi.tsx → internal/Zoi.tsx} +0 -0
  75. package/src/internal/nativeInterface.tsx +8 -0
  76. package/src/internal/types.tsx +20 -0
  77. package/lib/commonjs/Poi.js.map +0 -1
  78. package/lib/module/Poi.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,27 +48,28 @@ if you are using **M1 Mac** Update pod post installation like
46
48
  end
47
49
  ```
48
50
 
49
- For Android
50
- - ToDo: Please update for Android
51
-
52
51
  ### Supported Platforms ###
52
+
53
53
  ---
54
+
54
55
  - iOS
55
56
  - Android
56
57
 
57
58
  ### Modules
59
+
58
60
  ---
59
- * **WoosmapGeofencing**: Woosmap contains methods to monitor location, regions.
61
+ - **WoosmapGeofencing**: Woosmap contains methods to monitor location, regions.
60
62
 
61
63
  ### Objects(Read Only)
64
+
62
65
  ---
63
- * **Location**: Represents the location object
64
- * **POI**: Represents Point of Interest
65
- * **Region**: Represents a geographical region/geofence
66
- * **Visit**: Represents a visit to a location/POI
67
- * **ZOI**: Represents Zone of Interest
68
- * **Airship**: Contains custom data related to Airship implementation
69
- * **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
70
73
 
71
74
  ## Usage
72
75
 
@@ -78,6 +81,7 @@ import WoosmapGeofencing from 'react-native-plugin-geofencing';
78
81
  ```
79
82
 
80
83
  ### Check and request permissions
84
+
81
85
  ---
82
86
  Before initializing the SDK it is required that you request for required location permissions.
83
87
 
@@ -94,9 +98,10 @@ WoosmapGeofencing.getPermissionsStatus()
94
98
  ```
95
99
 
96
100
  Parameter status will be a string, one of:
97
- * `GRANTED_BACKGROUND` : User has granted location access even when app is not running in the foreground
98
- * `GRANTED_FOREGROUND` : Location access is granted only while user is using the app
99
- * `DENIED`: Location access is denied
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.
100
105
 
101
106
  **_Please note_**: Plugin will not work as expected if location access is denied.
102
107
 
@@ -115,6 +120,7 @@ WoosmapGeofencing.requestPermissions(props.background)
115
120
  ```
116
121
 
117
122
  ### Initializing the plugin
123
+
118
124
  ---
119
125
 
120
126
  Plugin can be initialized by simply calling `initialize` method.
@@ -152,11 +158,13 @@ WoosmapGeofencing.setWoosmapApiKey(<privateKeyWoosmapAPI>)
152
158
  ```
153
159
 
154
160
  ### Tracking
161
+
155
162
  ---
156
163
 
157
164
  Once you have initialized the plugin and the user has authorized location permissions, you can start tracking the user’s location.
158
165
 
159
166
  To start tracking, call:
167
+
160
168
  ``` javascript
161
169
  WoosmapGeofencing.startTracking('liveTracking')
162
170
  .then((result: string) => {
@@ -169,6 +177,7 @@ WoosmapGeofencing.startTracking('liveTracking')
169
177
  ```
170
178
 
171
179
  To stop tracking, call:
180
+
172
181
  ``` javascript
173
182
  WoosmapGeofencing.stopTracking()
174
183
  .then((value: any) => {
@@ -181,11 +190,12 @@ WoosmapGeofencing.stopTracking()
181
190
 
182
191
  Method `startTracking` accepts only following tracking profiles
183
192
 
184
- * **liveTracking**
185
- * **passiveTracking**
186
- * **visitsTracking**
193
+ - **liveTracking**
194
+ - **passiveTracking**
195
+ - **visitsTracking**
187
196
 
188
197
  ### Tracking profile properties
198
+
189
199
  ---
190
200
 
191
201
  | Property | liveTracking | passiveTracking | visitsTracking
@@ -211,6 +221,7 @@ Method `startTracking` accepts only following tracking profiles
211
221
  | DOUBLEOfDayDataDuration | 30 | 30 | 30
212
222
 
213
223
  ### Listening to events
224
+
214
225
  ---
215
226
 
216
227
  **Location**
@@ -247,6 +258,7 @@ WoosmapGeofencing.clearLocationWatch(watchID)
247
258
  **Define the radius value**
248
259
 
249
260
  When you create a Geofence around a POI (previously imported from Woosmap), manually define the radius value:
261
+
250
262
  ```javascript
251
263
  WoosmapGeofencing.setPoiRadius("100")
252
264
  .then((value: string) => {
@@ -256,7 +268,9 @@ WoosmapGeofencing.setPoiRadius("100")
256
268
  alert('message: ' + error.message);
257
269
  });
258
270
  ```
271
+
259
272
  or choose the user_properties subfield that corresponds to radius value of the Geofence:
273
+
260
274
  ```javascript
261
275
  WoosmapGeofencing.setPoiRadius("radiusPOI")
262
276
  .then((value: string) => {
@@ -293,7 +307,9 @@ WoosmapGeofencing.clearRegionsWatch(watchID)
293
307
  alert('message: ' + error.message);
294
308
  });
295
309
  ```
310
+
296
311
  ### Initialize Salesforce MarketingCloud Connector
312
+
297
313
  ---
298
314
 
299
315
  The SDK needs some input like credentials and object key to perform the API call to Salesforce Marketing Cloud API.
@@ -314,7 +330,155 @@ The SDK needs some input like credentials and object key to perform the API call
314
330
  | zoiClassifiedExitedEventDefinitionKey | Set the EventDefinitionKey that you want to use for the Woosmap event `woos_zoi_classified_exited_event` | |
315
331
  | visitEventDefinitionKey | Set the EventDefinitionKey that you want to use for the Woosmap event `woos_Visit_event` |
316
332
 
317
- **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
+
318
482
  ``` javascript
319
483
  var sfmcCredentials = {
320
484
  authenticationBaseURI: "https://xxxxxxxxxx.auth.marketingcloudapis.com",
@@ -334,6 +498,41 @@ The SDK needs some input like credentials and object key to perform the API call
334
498
  });
335
499
  ```
336
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://deploy-preview-457--developers-woosmap.netlify.app/products/geofencing-sdk/tracking-profiles/tracking-properties/).
337
536
 
338
537
  ## License
339
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
  }