@woosmap/react-native-plugin-geofencing 0.1.5 → 0.1.8
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.
- package/README.md +219 -19
- package/android/build.gradle +7 -0
- package/android/src/main/java/com/reactnativeplugingeofencing/PluginGeofencingModule.java +328 -35
- package/android/src/main/java/com/reactnativeplugingeofencing/WoosmapMessageAndKey.java +17 -0
- package/android/src/main/java/com/reactnativeplugingeofencing/WoosmapTask.java +299 -0
- package/android/src/main/java/com/reactnativeplugingeofencing/WoosmapUtil.java +118 -2
- package/ios/DataLocation.swift +4 -0
- package/ios/DataPOI.swift +11 -0
- package/ios/DataRegion.swift +33 -3
- package/ios/PluginGeofencing.m +43 -0
- package/ios/PluginGeofencing.swift +377 -22
- package/ios/WoosmapGeofenceMessage.swift +12 -0
- package/ios/WoosmapGeofenceService.swift +203 -30
- package/lib/commonjs/index.js +171 -68
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/{Airship.js → internal/Airship.js} +0 -0
- package/lib/commonjs/{Airship.js.map → internal/Airship.js.map} +0 -0
- package/lib/commonjs/{Location.js → internal/Location.js} +0 -0
- package/lib/commonjs/{Location.js.map → internal/Location.js.map} +0 -0
- package/lib/commonjs/{MarketingCloud.js → internal/MarketingCloud.js} +0 -0
- package/lib/commonjs/{MarketingCloud.js.map → internal/MarketingCloud.js.map} +0 -0
- package/lib/{module → commonjs/internal}/Poi.js +10 -1
- package/lib/commonjs/internal/Poi.js.map +1 -0
- package/lib/commonjs/{Region.js → internal/Region.js} +0 -0
- package/lib/commonjs/{Region.js.map → internal/Region.js.map} +0 -0
- package/lib/commonjs/{Visit.js → internal/Visit.js} +0 -0
- package/lib/commonjs/{Visit.js.map → internal/Visit.js.map} +0 -0
- package/lib/commonjs/{Zoi.js → internal/Zoi.js} +0 -0
- package/lib/commonjs/{Zoi.js.map → internal/Zoi.js.map} +0 -0
- package/lib/commonjs/internal/nativeInterface.js +18 -0
- package/lib/commonjs/internal/nativeInterface.js.map +1 -0
- package/lib/commonjs/internal/types.js +2 -0
- package/lib/commonjs/internal/types.js.map +1 -0
- package/lib/module/index.js +155 -53
- package/lib/module/index.js.map +1 -1
- package/lib/module/{Airship.js → internal/Airship.js} +0 -0
- package/lib/module/{Airship.js.map → internal/Airship.js.map} +0 -0
- package/lib/module/{Location.js → internal/Location.js} +0 -0
- package/lib/module/{Location.js.map → internal/Location.js.map} +0 -0
- package/lib/module/{MarketingCloud.js → internal/MarketingCloud.js} +0 -0
- package/lib/module/{MarketingCloud.js.map → internal/MarketingCloud.js.map} +0 -0
- package/lib/{commonjs → module/internal}/Poi.js +2 -3
- package/lib/module/internal/Poi.js.map +1 -0
- package/lib/module/{Region.js → internal/Region.js} +0 -0
- package/lib/module/{Region.js.map → internal/Region.js.map} +0 -0
- package/lib/module/{Visit.js → internal/Visit.js} +0 -0
- package/lib/module/{Visit.js.map → internal/Visit.js.map} +0 -0
- package/lib/module/{Zoi.js → internal/Zoi.js} +0 -0
- package/lib/module/{Zoi.js.map → internal/Zoi.js.map} +0 -0
- package/lib/module/internal/nativeInterface.js +9 -0
- package/lib/module/internal/nativeInterface.js.map +1 -0
- package/lib/module/internal/types.js +2 -0
- package/lib/module/internal/types.js.map +1 -0
- package/lib/typescript/index.d.ts +63 -4
- package/lib/typescript/{Airship.d.ts → internal/Airship.d.ts} +0 -0
- package/lib/typescript/{Location.d.ts → internal/Location.d.ts} +0 -0
- package/lib/typescript/{MarketingCloud.d.ts → internal/MarketingCloud.d.ts} +0 -0
- package/lib/typescript/{Poi.d.ts → internal/Poi.d.ts} +4 -2
- package/lib/typescript/{Region.d.ts → internal/Region.d.ts} +0 -0
- package/lib/typescript/{Visit.d.ts → internal/Visit.d.ts} +0 -0
- package/lib/typescript/{Zoi.d.ts → internal/Zoi.d.ts} +0 -0
- package/lib/typescript/internal/nativeInterface.d.ts +2 -0
- package/lib/typescript/internal/types.d.ts +18 -0
- package/package.json +1 -1
- package/src/index.tsx +173 -53
- package/src/{Airship.tsx → internal/Airship.tsx} +0 -0
- package/src/{Location.tsx → internal/Location.tsx} +0 -0
- package/src/{MarketingCloud.tsx → internal/MarketingCloud.tsx} +0 -0
- package/src/{Poi.tsx → internal/Poi.tsx} +4 -3
- package/src/{Region.tsx → internal/Region.tsx} +0 -0
- package/src/{Visit.tsx → internal/Visit.tsx} +0 -0
- package/src/{Zoi.tsx → internal/Zoi.tsx} +0 -0
- package/src/internal/nativeInterface.tsx +8 -0
- package/src/internal/types.tsx +20 -0
- package/lib/commonjs/Poi.js.map +0 -1
- package/lib/module/Poi.js.map +0 -1
|
@@ -8,6 +8,7 @@ import android.util.ArraySet;
|
|
|
8
8
|
import android.util.Log;
|
|
9
9
|
|
|
10
10
|
import androidx.annotation.NonNull;
|
|
11
|
+
import androidx.annotation.RequiresApi;
|
|
11
12
|
import androidx.core.app.ActivityCompat;
|
|
12
13
|
|
|
13
14
|
import com.facebook.react.bridge.Callback;
|
|
@@ -24,6 +25,7 @@ import com.facebook.react.modules.core.PermissionAwareActivity;
|
|
|
24
25
|
import com.facebook.react.modules.core.PermissionListener;
|
|
25
26
|
import com.webgeoservices.woosmapgeofencing.Woosmap;
|
|
26
27
|
import com.webgeoservices.woosmapgeofencing.WoosmapSettings;
|
|
28
|
+
import com.webgeoservices.woosmapgeofencing.database.Region;
|
|
27
29
|
|
|
28
30
|
import java.lang.reflect.Array;
|
|
29
31
|
import java.util.ArrayList;
|
|
@@ -79,40 +81,38 @@ public class PluginGeofencingModule extends ReactContextBaseJavaModule implement
|
|
|
79
81
|
public void initialize(ReadableMap map, Promise promise) {
|
|
80
82
|
String trackingProfile = "";
|
|
81
83
|
try {
|
|
82
|
-
if (
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
if (map.
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
} else if (map.getString(WoosmapMessageAndKey.profileTrackingKey).equals(Woosmap.ConfigurationProfile.visitsTracking)) {
|
|
93
|
-
trackingProfile = Woosmap.ConfigurationProfile.visitsTracking;
|
|
94
|
-
} else {
|
|
95
|
-
promise.reject(WoosmapMessageAndKey.errorCode, WoosmapMessageAndKey.invalidProfileTrackingError);
|
|
96
|
-
return;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
woosmap = Woosmap.getInstance().initializeWoosmap(reactContext);
|
|
100
|
-
if (map.hasKey(WoosmapMessageAndKey.woosmapPrivateKeyString)) {
|
|
101
|
-
WoosmapSettings.privateKeyWoosmapAPI = map.getString(WoosmapMessageAndKey.woosmapPrivateKeyString);
|
|
102
|
-
}
|
|
103
|
-
// Set the Delay of Duration data
|
|
104
|
-
WoosmapSettings.numberOfDayDataDuration = 30;
|
|
105
|
-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
|
106
|
-
this.woosmap.createWoosmapNotifChannel();
|
|
107
|
-
}
|
|
108
|
-
this.woosmap.onResume();
|
|
109
|
-
if (!trackingProfile.isEmpty()) {
|
|
110
|
-
woosmap.startTracking(trackingProfile);
|
|
84
|
+
if (map.hasKey(WoosmapMessageAndKey.profileTrackingKey)) {
|
|
85
|
+
if (map.getString(WoosmapMessageAndKey.profileTrackingKey).equals(Woosmap.ConfigurationProfile.liveTracking)) {
|
|
86
|
+
trackingProfile = Woosmap.ConfigurationProfile.liveTracking;
|
|
87
|
+
} else if (map.getString(WoosmapMessageAndKey.profileTrackingKey).equals(Woosmap.ConfigurationProfile.passiveTracking)) {
|
|
88
|
+
trackingProfile = Woosmap.ConfigurationProfile.passiveTracking;
|
|
89
|
+
} else if (map.getString(WoosmapMessageAndKey.profileTrackingKey).equals(Woosmap.ConfigurationProfile.visitsTracking)) {
|
|
90
|
+
trackingProfile = Woosmap.ConfigurationProfile.visitsTracking;
|
|
91
|
+
} else {
|
|
92
|
+
promise.reject(WoosmapMessageAndKey.errorCode, WoosmapMessageAndKey.invalidProfileTrackingError);
|
|
93
|
+
return;
|
|
111
94
|
}
|
|
112
|
-
|
|
95
|
+
}
|
|
96
|
+
woosmap = Woosmap.getInstance().initializeWoosmap(reactContext);
|
|
97
|
+
if (map.hasKey(WoosmapMessageAndKey.woosmapPrivateKeyString)) {
|
|
98
|
+
WoosmapSettings.privateKeyWoosmapAPI = map.getString(WoosmapMessageAndKey.woosmapPrivateKeyString);
|
|
99
|
+
}
|
|
100
|
+
// Set the Delay of Duration data
|
|
101
|
+
WoosmapSettings.numberOfDayDataDuration = 30;
|
|
102
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
|
103
|
+
this.woosmap.createWoosmapNotifChannel();
|
|
104
|
+
}
|
|
105
|
+
this.woosmap.onResume();
|
|
106
|
+
if (!trackingProfile.isEmpty()) {
|
|
107
|
+
woosmap.startTracking(trackingProfile);
|
|
108
|
+
}
|
|
109
|
+
promise.resolve(WoosmapMessageAndKey.successMessage);
|
|
110
|
+
/* if (hasPermission(false)) {
|
|
111
|
+
//check required permission first
|
|
112
|
+
|
|
113
113
|
} else {
|
|
114
114
|
promise.reject(WoosmapMessageAndKey.errorCode, WoosmapMessageAndKey.permissionNotGrantedMessage);
|
|
115
|
-
}
|
|
115
|
+
}*/
|
|
116
116
|
} catch (Exception ex) {
|
|
117
117
|
promise.reject(WoosmapMessageAndKey.errorCode, ex.getMessage());
|
|
118
118
|
}
|
|
@@ -206,10 +206,10 @@ public class PluginGeofencingModule extends ReactContextBaseJavaModule implement
|
|
|
206
206
|
|
|
207
207
|
/***
|
|
208
208
|
* Checks if the required location permissions are granted or not.
|
|
209
|
-
* Returns
|
|
210
|
-
* Returns
|
|
211
|
-
* Returns
|
|
212
|
-
* Returns UNKNOWN
|
|
209
|
+
* Returns DENIED if no permissions are granted.
|
|
210
|
+
* Returns GRANTED_FOREGROUND if foreground location permission is granted.
|
|
211
|
+
* Returns GRANTED_BACKGROUND if background location permission is granted.
|
|
212
|
+
* Returns UNKNOWN if plugin is unable to determine or asking for permission without providing any permission.
|
|
213
213
|
*/
|
|
214
214
|
@ReactMethod
|
|
215
215
|
public void getPermissionsStatus(final Promise promise) {
|
|
@@ -257,9 +257,14 @@ public class PluginGeofencingModule extends ReactContextBaseJavaModule implement
|
|
|
257
257
|
|
|
258
258
|
@Override
|
|
259
259
|
public void onHostDestroy() {
|
|
260
|
+
if(profileReadyListener!=null){
|
|
261
|
+
woosmap.setProfileReadyListener(null);
|
|
262
|
+
profileReadyListener=null;
|
|
263
|
+
}
|
|
260
264
|
if (woosmap != null) {
|
|
261
265
|
woosmap.onDestroy();
|
|
262
266
|
}
|
|
267
|
+
|
|
263
268
|
}
|
|
264
269
|
|
|
265
270
|
/***
|
|
@@ -537,5 +542,293 @@ public class PluginGeofencingModule extends ReactContextBaseJavaModule implement
|
|
|
537
542
|
}
|
|
538
543
|
}
|
|
539
544
|
|
|
545
|
+
/**
|
|
546
|
+
* Adds/updates a region in DB as well as geofence collection
|
|
547
|
+
* @param map Readable map with region detail.
|
|
548
|
+
* @param promise React native callback context.
|
|
549
|
+
*/
|
|
550
|
+
@RequiresApi(api = Build.VERSION_CODES.N)
|
|
551
|
+
@ReactMethod
|
|
552
|
+
public void addRegion(ReadableMap map, Promise promise) {
|
|
553
|
+
try {
|
|
554
|
+
Region region;
|
|
555
|
+
if (isWoosmapInitialized()) {
|
|
556
|
+
if (map.toHashMap().isEmpty()) {
|
|
557
|
+
throw new Exception(WoosmapMessageAndKey.regionInfoEmptyMessage);
|
|
558
|
+
}
|
|
559
|
+
region = new Region();
|
|
560
|
+
region.identifier = map.getString("regionId");
|
|
561
|
+
region.idStore = map.hasKey("idStore") ? map.getString("idStore") : "";
|
|
562
|
+
region.lat = map.getDouble("lat");
|
|
563
|
+
region.lng = map.getDouble("lng");
|
|
564
|
+
region.type = map.hasKey("type") ? map.getString("type") : "";
|
|
565
|
+
region.radius = map.getDouble("radius");
|
|
566
|
+
|
|
567
|
+
WoosmapTask.getInstance(reactContext).addRegion(region, promise);
|
|
568
|
+
} else {
|
|
569
|
+
promise.reject(WoosmapMessageAndKey.errorCode, WoosmapMessageAndKey.woosmapNotInitialized);
|
|
570
|
+
}
|
|
571
|
+
} catch (Exception ex) {
|
|
572
|
+
promise.reject(WoosmapMessageAndKey.errorCode, ex.getMessage());
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
/**
|
|
577
|
+
* Gets saved region from the database.
|
|
578
|
+
* @param regionid A string unique value for region.
|
|
579
|
+
* @param promise React native callback context.
|
|
580
|
+
*/
|
|
581
|
+
@RequiresApi(api = Build.VERSION_CODES.N)
|
|
582
|
+
@ReactMethod
|
|
583
|
+
public void getRegions(String regionid, Promise promise){
|
|
584
|
+
try{
|
|
585
|
+
if (isWoosmapInitialized()){
|
|
586
|
+
if(!regionid.isEmpty()){
|
|
587
|
+
WoosmapTask.getInstance(reactContext).enqueGetRegionsRequest(regionid,promise);
|
|
588
|
+
|
|
589
|
+
}else {
|
|
590
|
+
promise.reject(WoosmapMessageAndKey.errorCode,WoosmapMessageAndKey.requiredRegionid);
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
}else {
|
|
594
|
+
promise.reject(WoosmapMessageAndKey.errorCode,WoosmapMessageAndKey.woosmapNotInitialized);
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
catch (Exception ex){
|
|
598
|
+
promise.reject(WoosmapMessageAndKey.errorCode,ex.getMessage());
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
/**
|
|
603
|
+
* Gets all saved region from the database.
|
|
604
|
+
* @param promise React native callback context.
|
|
605
|
+
*/
|
|
606
|
+
@RequiresApi(api = Build.VERSION_CODES.N)
|
|
607
|
+
@ReactMethod
|
|
608
|
+
public void getAllRegions(Promise promise){
|
|
609
|
+
try{
|
|
610
|
+
if (isWoosmapInitialized()){
|
|
611
|
+
WoosmapTask.getInstance(reactContext).enqueGetRegionsRequest(promise);
|
|
612
|
+
}else {
|
|
613
|
+
promise.reject(WoosmapMessageAndKey.errorCode,WoosmapMessageAndKey.woosmapNotInitialized);
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
catch (Exception ex){
|
|
617
|
+
promise.reject(WoosmapMessageAndKey.errorCode,ex.getMessage());
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
/***
|
|
622
|
+
* Removes the region by given region id.
|
|
623
|
+
* @param regionid A unique string region id which is to be removed.
|
|
624
|
+
* @param promise React native callback context.
|
|
625
|
+
*/
|
|
626
|
+
@RequiresApi(api = Build.VERSION_CODES.N)
|
|
627
|
+
@ReactMethod
|
|
628
|
+
private void removeRegion(String regionid, Promise promise){
|
|
629
|
+
try{
|
|
630
|
+
if (isWoosmapInitialized()){
|
|
631
|
+
if(!regionid.isEmpty()){
|
|
632
|
+
WoosmapTask.getInstance(reactContext).removeRegion(regionid,promise);
|
|
633
|
+
}else {
|
|
634
|
+
promise.reject(WoosmapMessageAndKey.errorCode,WoosmapMessageAndKey.requiredRegionid);
|
|
635
|
+
}
|
|
636
|
+
}else {
|
|
637
|
+
promise.reject(WoosmapMessageAndKey.errorCode,WoosmapMessageAndKey.woosmapNotInitialized);
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
catch (Exception ex){
|
|
641
|
+
promise.reject(WoosmapMessageAndKey.errorCode,ex.getMessage());
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
/***
|
|
646
|
+
* Removes all region from saved database.
|
|
647
|
+
* @param promise React native callback context.
|
|
648
|
+
*/
|
|
649
|
+
@RequiresApi(api = Build.VERSION_CODES.N)
|
|
650
|
+
@ReactMethod
|
|
651
|
+
private void removeAllRegions(Promise promise){
|
|
652
|
+
try{
|
|
653
|
+
if (isWoosmapInitialized()){
|
|
654
|
+
WoosmapTask.getInstance(reactContext).removeRegion("",promise);
|
|
655
|
+
}else {
|
|
656
|
+
promise.reject(WoosmapMessageAndKey.errorCode,WoosmapMessageAndKey.woosmapNotInitialized);
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
catch (Exception ex){
|
|
660
|
+
promise.reject(WoosmapMessageAndKey.errorCode,ex.getMessage());
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
/***
|
|
665
|
+
* Removes all POI from saved database.
|
|
666
|
+
* @param promise React native callback context.
|
|
667
|
+
*/
|
|
668
|
+
@RequiresApi(api = Build.VERSION_CODES.N)
|
|
669
|
+
@ReactMethod
|
|
670
|
+
private void removeAllPois(Promise promise){
|
|
671
|
+
try{
|
|
672
|
+
if (isWoosmapInitialized()){
|
|
673
|
+
WoosmapTask.getInstance(reactContext).removeAllPois(promise);
|
|
674
|
+
}else {
|
|
675
|
+
promise.reject(WoosmapMessageAndKey.errorCode,WoosmapMessageAndKey.woosmapNotInitialized);
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
catch (Exception ex){
|
|
679
|
+
promise.reject(WoosmapMessageAndKey.errorCode,ex.getMessage());
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
/**
|
|
684
|
+
* Gets all saved POIs from the database.
|
|
685
|
+
* @param promise React native callback context.
|
|
686
|
+
*/
|
|
687
|
+
@RequiresApi(api = Build.VERSION_CODES.N)
|
|
688
|
+
@ReactMethod
|
|
689
|
+
public void getAllPois(Promise promise){
|
|
690
|
+
try{
|
|
691
|
+
if (isWoosmapInitialized()){
|
|
692
|
+
WoosmapTask.getInstance(reactContext).enqueGetAllPoiRequest(promise);
|
|
693
|
+
}else {
|
|
694
|
+
promise.reject(WoosmapMessageAndKey.errorCode,WoosmapMessageAndKey.woosmapNotInitialized);
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
catch (Exception ex){
|
|
698
|
+
promise.reject(WoosmapMessageAndKey.errorCode,ex.getMessage());
|
|
699
|
+
}
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
/**
|
|
703
|
+
* Gets saved POI info from the database.
|
|
704
|
+
* @param poiID A unique string value of locationID/StoreID for POI which user want to fetch.
|
|
705
|
+
* @param promise React native callback context.
|
|
706
|
+
*/
|
|
707
|
+
@RequiresApi(api = Build.VERSION_CODES.N)
|
|
708
|
+
@ReactMethod
|
|
709
|
+
public void getPoi(String poiID, Promise promise){
|
|
710
|
+
try{
|
|
711
|
+
if (isWoosmapInitialized()){
|
|
712
|
+
if(!poiID.isEmpty()){
|
|
713
|
+
WoosmapTask.getInstance(reactContext).enqueGetPOIRequest(poiID,promise);
|
|
714
|
+
|
|
715
|
+
}else {
|
|
716
|
+
promise.reject(WoosmapMessageAndKey.errorCode,WoosmapMessageAndKey.requiredLocationid);
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
}else {
|
|
720
|
+
promise.reject(WoosmapMessageAndKey.errorCode,WoosmapMessageAndKey.woosmapNotInitialized);
|
|
721
|
+
}
|
|
722
|
+
}
|
|
723
|
+
catch (Exception ex){
|
|
724
|
+
promise.reject(WoosmapMessageAndKey.errorCode,ex.getMessage());
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
|
|
728
|
+
/**
|
|
729
|
+
* Gets saved location from the database.
|
|
730
|
+
* @param locationid A string unique value for location.
|
|
731
|
+
* @param promise React native callback context.
|
|
732
|
+
*/
|
|
733
|
+
@RequiresApi(api = Build.VERSION_CODES.N)
|
|
734
|
+
@ReactMethod
|
|
735
|
+
private void getLocation(String locationid, Promise promise){
|
|
736
|
+
try{
|
|
737
|
+
if (isWoosmapInitialized()){
|
|
738
|
+
if(!locationid.isEmpty()){
|
|
739
|
+
WoosmapTask.getInstance(reactContext).enqueueGetLocationRequest(locationid,promise);
|
|
740
|
+
|
|
741
|
+
}else {
|
|
742
|
+
promise.reject(WoosmapMessageAndKey.errorCode,WoosmapMessageAndKey.requiredLocationID);
|
|
743
|
+
}
|
|
744
|
+
|
|
745
|
+
}else {
|
|
746
|
+
promise.reject(WoosmapMessageAndKey.errorCode,WoosmapMessageAndKey.woosmapNotInitialized);
|
|
747
|
+
}
|
|
748
|
+
}
|
|
749
|
+
catch (Exception ex){
|
|
750
|
+
promise.reject(WoosmapMessageAndKey.errorCode,ex.getMessage());
|
|
751
|
+
}
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
/**
|
|
755
|
+
* Gets all saved location from the database.
|
|
756
|
+
* @param promise React native callback context.
|
|
757
|
+
*/
|
|
758
|
+
@RequiresApi(api = Build.VERSION_CODES.N)
|
|
759
|
+
@ReactMethod
|
|
760
|
+
private void getAllLocations(Promise promise){
|
|
761
|
+
try{
|
|
762
|
+
if (isWoosmapInitialized()){
|
|
763
|
+
WoosmapTask.getInstance(reactContext).enqueueGetLocationRequest(promise);
|
|
764
|
+
}else {
|
|
765
|
+
promise.reject(WoosmapMessageAndKey.errorCode,WoosmapMessageAndKey.woosmapNotInitialized);
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
catch (Exception ex){
|
|
769
|
+
promise.reject(WoosmapMessageAndKey.errorCode,ex.getMessage());
|
|
770
|
+
}
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
/***
|
|
774
|
+
* Removes all location from saved database.
|
|
775
|
+
* @param promise React native callback context.
|
|
776
|
+
*/
|
|
777
|
+
@RequiresApi(api = Build.VERSION_CODES.N)
|
|
778
|
+
@ReactMethod
|
|
779
|
+
private void removeAllLocations(Promise promise){
|
|
780
|
+
try{
|
|
781
|
+
if (isWoosmapInitialized()){
|
|
782
|
+
WoosmapTask.getInstance(reactContext).removeAllLocation(promise);
|
|
783
|
+
}else {
|
|
784
|
+
promise.reject(WoosmapMessageAndKey.errorCode,WoosmapMessageAndKey.woosmapNotInitialized);
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
catch (Exception ex){
|
|
788
|
+
promise.reject(WoosmapMessageAndKey.errorCode,ex.getMessage());
|
|
789
|
+
}
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
|
|
793
|
+
private Woosmap.ProfileReadyListener profileReadyListener;
|
|
794
|
+
|
|
795
|
+
/***
|
|
796
|
+
* Set custom tracking profile if preset tracking profile don't match your requirement.
|
|
797
|
+
* @param mode A string value which can be local or external.
|
|
798
|
+
* @param source Location of file in json format.
|
|
799
|
+
* 1.Local mode put json file in assets folder and provide file name as source.
|
|
800
|
+
* 2.External mode put json file in server and provide file url as source.
|
|
801
|
+
* @param promise React native callback context.
|
|
802
|
+
*/
|
|
803
|
+
@ReactMethod
|
|
804
|
+
public void startCustomTracking(String mode,String source, Promise promise){
|
|
805
|
+
try{
|
|
806
|
+
if (isWoosmapInitialized()){
|
|
807
|
+
profileReadyListener= (status, errors) -> {
|
|
808
|
+
try {
|
|
809
|
+
if(status){
|
|
810
|
+
promise.resolve(WoosmapMessageAndKey.successMessage);
|
|
811
|
+
}else {
|
|
812
|
+
promise.reject(WoosmapMessageAndKey.errorCode,errors.get(0));
|
|
813
|
+
}
|
|
814
|
+
}catch (Exception ex){
|
|
815
|
+
promise.reject(WoosmapMessageAndKey.errorCode,ex.getMessage());
|
|
816
|
+
}
|
|
817
|
+
};
|
|
818
|
+
woosmap.setProfileReadyListener(profileReadyListener);
|
|
819
|
+
if(mode.equalsIgnoreCase(WoosmapMessageAndKey.localMode)||mode.equalsIgnoreCase(WoosmapMessageAndKey.externalMode)){
|
|
820
|
+
woosmap.startCustomTracking(source);
|
|
821
|
+
}else {
|
|
822
|
+
promise.reject(WoosmapMessageAndKey.errorCode,WoosmapMessageAndKey.invalidProfileSourceType);
|
|
823
|
+
}
|
|
824
|
+
}else {
|
|
825
|
+
promise.reject(WoosmapMessageAndKey.errorCode,WoosmapMessageAndKey.woosmapNotInitialized);
|
|
826
|
+
}
|
|
827
|
+
}
|
|
828
|
+
catch (Exception ex){
|
|
829
|
+
promise.reject(WoosmapMessageAndKey.errorCode,ex.getMessage());
|
|
830
|
+
}
|
|
831
|
+
}
|
|
832
|
+
|
|
540
833
|
|
|
541
834
|
}
|
|
@@ -33,6 +33,23 @@ public class WoosmapMessageAndKey {
|
|
|
33
33
|
protected static String regionWatchNotStarted="region watch not started";
|
|
34
34
|
protected static String radiusEmptyMessage="Radius value can not be empty";
|
|
35
35
|
protected static String invalidRadiusMessage="POI Radius should be an integer or a string.";
|
|
36
|
+
protected static String regionInfoEmptyMessage="regionInfo cannot be empty or null.";
|
|
37
|
+
protected static String circleTypeKey="circle";
|
|
38
|
+
protected static String isochroneTypeKey="isochrone";
|
|
39
|
+
protected static String validRegionTypeMessage="Provide valid region type (circle/isochrone)";
|
|
40
|
+
protected static String requiredRegionid="Region id cannot be empty or null";
|
|
41
|
+
protected static String requiredLocationid="Location id cannot be empty or null";
|
|
42
|
+
protected static String invalidRegionid="Unable to fetch region info";
|
|
43
|
+
protected static String invalidLocationid="Unable to fetch POI info";
|
|
44
|
+
protected static String deleteMessage="Deleted";
|
|
45
|
+
protected static String requiredLocationID = "Location id cannot be empty or null";
|
|
46
|
+
protected static String invalidLocationID = "Unable to fetch location info";
|
|
47
|
+
protected static String invalidProfileSourceType = "Provide valid source type type (local/external)";
|
|
48
|
+
protected static String invalidProfileFile = "Invalid profile file";
|
|
49
|
+
protected static String localMode="local";
|
|
50
|
+
protected static String externalMode="external";
|
|
51
|
+
|
|
52
|
+
|
|
36
53
|
|
|
37
54
|
|
|
38
55
|
|