@woosmap/react-native-plugin-geofencing 0.3.0 → 0.4.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.
- package/android/src/main/java/com/reactnativeplugingeofencing/PluginGeofencingModule.java +52 -6
- package/android/src/main/java/com/reactnativeplugingeofencing/WoosmapMessageAndKey.java +1 -0
- package/android/src/main/java/com/reactnativeplugingeofencing/WoosmapTask.java +50 -3
- package/android/src/main/java/com/reactnativeplugingeofencing/WoosmapUtil.java +35 -0
- package/ios/DataPOI.swift +7 -1
- package/ios/PluginGeofencing.m +10 -0
- package/ios/PluginGeofencing.swift +88 -0
- package/ios/WoosmapGeofenceMessage.swift +2 -0
- package/ios/WoosmapGeofenceService.swift +37 -6
- package/lib/commonjs/index.js +70 -12
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/internal/IndoorBeacon.js +76 -0
- package/lib/commonjs/internal/IndoorBeacon.js.map +1 -0
- package/lib/commonjs/internal/Location.js +1 -2
- package/lib/commonjs/internal/Location.js.map +1 -1
- package/lib/commonjs/internal/Poi.js +5 -4
- package/lib/commonjs/internal/Poi.js.map +1 -1
- package/lib/commonjs/internal/Region.js +1 -2
- package/lib/commonjs/internal/Region.js.map +1 -1
- package/lib/commonjs/internal/nativeInterface.js +1 -2
- package/lib/commonjs/internal/nativeInterface.js.map +1 -1
- package/lib/module/index.js +69 -10
- package/lib/module/index.js.map +1 -1
- package/lib/module/internal/IndoorBeacon.js +70 -0
- package/lib/module/internal/IndoorBeacon.js.map +1 -0
- package/lib/module/internal/Poi.js +4 -2
- package/lib/module/internal/Poi.js.map +1 -1
- package/lib/typescript/index.d.ts +16 -1
- package/lib/typescript/internal/IndoorBeacon.d.ts +49 -0
- package/lib/typescript/internal/Poi.d.ts +2 -1
- package/package.json +3 -3
- package/react-native-plugin-geofencing.podspec +1 -1
|
@@ -4,15 +4,12 @@ import android.Manifest;
|
|
|
4
4
|
import android.app.Activity;
|
|
5
5
|
import android.content.pm.PackageManager;
|
|
6
6
|
import android.os.Build;
|
|
7
|
-
import android.util.ArraySet;
|
|
8
7
|
import android.util.Log;
|
|
9
8
|
|
|
10
9
|
import androidx.annotation.NonNull;
|
|
11
10
|
import androidx.annotation.RequiresApi;
|
|
12
|
-
import androidx.appcompat.app.AppCompatActivity;
|
|
13
11
|
import androidx.core.app.ActivityCompat;
|
|
14
12
|
|
|
15
|
-
import com.facebook.react.bridge.Callback;
|
|
16
13
|
import com.facebook.react.bridge.LifecycleEventListener;
|
|
17
14
|
import com.facebook.react.bridge.Promise;
|
|
18
15
|
import com.facebook.react.bridge.ReactApplicationContext;
|
|
@@ -20,7 +17,6 @@ import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
|
|
20
17
|
import com.facebook.react.bridge.ReactMethod;
|
|
21
18
|
import com.facebook.react.bridge.ReadableArray;
|
|
22
19
|
import com.facebook.react.bridge.ReadableMap;
|
|
23
|
-
import com.facebook.react.bridge.WritableMap;
|
|
24
20
|
import com.facebook.react.module.annotations.ReactModule;
|
|
25
21
|
import com.facebook.react.modules.core.PermissionAwareActivity;
|
|
26
22
|
import com.facebook.react.modules.core.PermissionListener;
|
|
@@ -28,8 +24,6 @@ import com.webgeoservices.woosmapgeofencing.Woosmap;
|
|
|
28
24
|
import com.webgeoservices.woosmapgeofencing.WoosmapSettings;
|
|
29
25
|
import com.webgeoservices.woosmapgeofencingcore.database.Region;
|
|
30
26
|
|
|
31
|
-
import java.lang.reflect.Array;
|
|
32
|
-
import java.util.ArrayList;
|
|
33
27
|
import java.util.HashMap;
|
|
34
28
|
import java.util.Iterator;
|
|
35
29
|
|
|
@@ -918,5 +912,57 @@ public class PluginGeofencingModule extends ReactContextBaseJavaModule implement
|
|
|
918
912
|
}
|
|
919
913
|
}
|
|
920
914
|
|
|
915
|
+
/***
|
|
916
|
+
* Fetches all indoor beacons from the local database.
|
|
917
|
+
* @param promise React native callback context.
|
|
918
|
+
*/
|
|
919
|
+
@RequiresApi(api = Build.VERSION_CODES.N)
|
|
920
|
+
@ReactMethod
|
|
921
|
+
public void getAllIndoorBeacons(final Promise promise){
|
|
922
|
+
getIndoorBeacons(null, promise);
|
|
923
|
+
}
|
|
924
|
+
|
|
925
|
+
/***
|
|
926
|
+
* Fetches all indoor beacons from the local database for the given venue id.
|
|
927
|
+
* @param venueId The venue id
|
|
928
|
+
* @param promise React native callback context.
|
|
929
|
+
*/
|
|
930
|
+
@RequiresApi(api = Build.VERSION_CODES.N)
|
|
931
|
+
@ReactMethod
|
|
932
|
+
public void getIndoorBeacons(final String venueId, final Promise promise){
|
|
933
|
+
try{
|
|
934
|
+
if (isWoosmapInitialized()){
|
|
935
|
+
if (venueId != null && venueId.isEmpty()){
|
|
936
|
+
promise.reject(WoosmapMessageAndKey.errorCode,WoosmapMessageAndKey.requiredVenueId);
|
|
937
|
+
}
|
|
938
|
+
else{
|
|
939
|
+
WoosmapTask.getInstance(reactContext).enqueueGetIndoorBeaconRequest(venueId,promise);
|
|
940
|
+
}
|
|
941
|
+
}else {
|
|
942
|
+
promise.reject(WoosmapMessageAndKey.errorCode,WoosmapMessageAndKey.woosmapNotInitialized);
|
|
943
|
+
}
|
|
944
|
+
}
|
|
945
|
+
catch (Exception ex){
|
|
946
|
+
promise.reject(WoosmapMessageAndKey.errorCode,ex.getMessage());
|
|
947
|
+
}
|
|
948
|
+
}
|
|
949
|
+
|
|
950
|
+
/***
|
|
951
|
+
* Removes all indoor beacons from the database
|
|
952
|
+
*/
|
|
953
|
+
@RequiresApi(api = Build.VERSION_CODES.N)
|
|
954
|
+
@ReactMethod
|
|
955
|
+
public void removeIndoorBeacons(final Promise promise){
|
|
956
|
+
try{
|
|
957
|
+
if (isWoosmapInitialized()){
|
|
958
|
+
WoosmapTask.getInstance(reactContext).removeAllBeacons(promise);
|
|
959
|
+
}else {
|
|
960
|
+
promise.reject(WoosmapMessageAndKey.errorCode,WoosmapMessageAndKey.woosmapNotInitialized);
|
|
961
|
+
}
|
|
962
|
+
}
|
|
963
|
+
catch (Exception ex){
|
|
964
|
+
promise.reject(WoosmapMessageAndKey.errorCode,ex.getMessage());
|
|
965
|
+
}
|
|
966
|
+
}
|
|
921
967
|
|
|
922
968
|
}
|
|
@@ -40,6 +40,7 @@ public class WoosmapMessageAndKey {
|
|
|
40
40
|
protected static String isochroneTypeKey="isochrone";
|
|
41
41
|
protected static String validRegionTypeMessage="Provide valid region type (circle/isochrone)";
|
|
42
42
|
protected static String requiredRegionid="Region id cannot be empty or null";
|
|
43
|
+
protected static String requiredVenueId="Venue id cannot be empty";
|
|
43
44
|
protected static String requiredLocationid="Location id cannot be empty or null";
|
|
44
45
|
protected static String invalidRegionid="Unable to fetch region info";
|
|
45
46
|
protected static String invalidLocationid="Unable to fetch POI info";
|
|
@@ -10,16 +10,16 @@ import androidx.annotation.RequiresApi;
|
|
|
10
10
|
import com.facebook.react.bridge.Arguments;
|
|
11
11
|
import com.facebook.react.bridge.Promise;
|
|
12
12
|
import com.facebook.react.bridge.WritableArray;
|
|
13
|
-
import com.facebook.react.bridge.WritableNativeArray;
|
|
14
13
|
import com.google.android.gms.maps.model.LatLng;
|
|
15
14
|
import com.webgeoservices.woosmapgeofencing.Woosmap;
|
|
15
|
+
import com.webgeoservices.woosmapgeofencing.enterpriseDatabase.EnterpriseDB;
|
|
16
|
+
import com.webgeoservices.woosmapgeofencing.enterpriseDatabase.IndoorBeacon;
|
|
16
17
|
import com.webgeoservices.woosmapgeofencingcore.database.MovingPosition;
|
|
17
18
|
import com.webgeoservices.woosmapgeofencingcore.database.POI;
|
|
18
19
|
import com.webgeoservices.woosmapgeofencingcore.database.Region;
|
|
19
20
|
import com.webgeoservices.woosmapgeofencingcore.database.WoosmapDb;
|
|
20
21
|
|
|
21
|
-
import
|
|
22
|
-
|
|
22
|
+
import java.util.List;
|
|
23
23
|
import java.util.concurrent.CompletableFuture;
|
|
24
24
|
import java.util.concurrent.CompletionException;
|
|
25
25
|
import java.util.function.Supplier;
|
|
@@ -294,6 +294,53 @@ public class WoosmapTask {
|
|
|
294
294
|
});
|
|
295
295
|
}
|
|
296
296
|
|
|
297
|
+
@RequiresApi(api = Build.VERSION_CODES.N)
|
|
298
|
+
protected void enqueueGetIndoorBeaconRequest(final String venueId, final Promise promise){
|
|
299
|
+
CompletableFuture.supplyAsync(() -> {
|
|
300
|
+
try {
|
|
301
|
+
List<IndoorBeacon> beacons;
|
|
302
|
+
WritableArray array= Arguments.createArray();
|
|
303
|
+
if (venueId == null){
|
|
304
|
+
beacons = EnterpriseDB.getInstance(context).getIndoorBeaconDAO().getAll();
|
|
305
|
+
}
|
|
306
|
+
else{
|
|
307
|
+
beacons = EnterpriseDB.getInstance(context).getIndoorBeaconDAO().getForVenue(venueId);
|
|
308
|
+
}
|
|
297
309
|
|
|
310
|
+
for(IndoorBeacon beacon: beacons){
|
|
311
|
+
array.pushMap(WoosmapUtil.getIndoorBeaconWritableMap(beacon));
|
|
312
|
+
}
|
|
313
|
+
return array;
|
|
314
|
+
} catch (Exception ex) {
|
|
315
|
+
throw new CompletionException(ex);
|
|
316
|
+
}
|
|
317
|
+
}).whenComplete((data, throwable) -> {
|
|
318
|
+
if (throwable == null) {
|
|
319
|
+
promise.resolve(data);
|
|
320
|
+
} else {
|
|
321
|
+
promise.reject(WoosmapMessageAndKey.errorCode,throwable.getMessage());
|
|
322
|
+
}
|
|
323
|
+
});
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
@RequiresApi(api = Build.VERSION_CODES.N)
|
|
327
|
+
protected void removeAllBeacons(final Promise promise){
|
|
328
|
+
CompletableFuture.supplyAsync((Supplier<Void>) () -> {
|
|
329
|
+
try{
|
|
330
|
+
EnterpriseDB.getInstance(context).getIndoorBeaconDAO().deleteAll();
|
|
331
|
+
}
|
|
332
|
+
catch (Exception ex){
|
|
333
|
+
throw new CompletionException(ex);
|
|
334
|
+
}
|
|
335
|
+
return null;
|
|
336
|
+
}).whenComplete((unused, throwable) -> {
|
|
337
|
+
if (throwable==null){
|
|
338
|
+
promise.resolve(WoosmapMessageAndKey.deleteMessage);
|
|
339
|
+
}
|
|
340
|
+
else{
|
|
341
|
+
promise.reject(WoosmapMessageAndKey.errorCode,throwable.getMessage());
|
|
342
|
+
}
|
|
343
|
+
});
|
|
344
|
+
}
|
|
298
345
|
|
|
299
346
|
}
|
|
@@ -14,6 +14,7 @@ import com.facebook.react.bridge.WritableMap;
|
|
|
14
14
|
import com.facebook.react.bridge.WritableNativeArray;
|
|
15
15
|
import com.facebook.react.bridge.WritableNativeMap;
|
|
16
16
|
import com.webgeoservices.woosmapgeofencing.WoosmapSettings;
|
|
17
|
+
import com.webgeoservices.woosmapgeofencing.enterpriseDatabase.IndoorBeacon;
|
|
17
18
|
import com.webgeoservices.woosmapgeofencingcore.database.MovingPosition;
|
|
18
19
|
import com.webgeoservices.woosmapgeofencingcore.database.POI;
|
|
19
20
|
import com.webgeoservices.woosmapgeofencingcore.database.Region;
|
|
@@ -24,6 +25,7 @@ import org.json.JSONException;
|
|
|
24
25
|
import org.json.JSONObject;
|
|
25
26
|
|
|
26
27
|
import java.util.Iterator;
|
|
28
|
+
import java.util.Map;
|
|
27
29
|
|
|
28
30
|
/***
|
|
29
31
|
* Contains misc. utility functions.
|
|
@@ -89,6 +91,32 @@ public class WoosmapUtil {
|
|
|
89
91
|
return null;
|
|
90
92
|
}
|
|
91
93
|
|
|
94
|
+
protected static WritableMap getIndoorBeaconWritableMap(IndoorBeacon indoorBeacon){
|
|
95
|
+
WritableMap map=new WritableNativeMap();
|
|
96
|
+
try{
|
|
97
|
+
map.putDouble("date", indoorBeacon.dateTime);
|
|
98
|
+
map.putString("beaconId", indoorBeacon.beaconID);
|
|
99
|
+
map.putDouble("major", indoorBeacon.major);
|
|
100
|
+
map.putDouble("minor", indoorBeacon.minor);
|
|
101
|
+
map.putString("venueId", indoorBeacon.venueID);
|
|
102
|
+
map.putString("identifier", indoorBeacon.identifier);
|
|
103
|
+
map.putDouble("latitude", indoorBeacon.latitude);
|
|
104
|
+
map.putDouble("longitude", indoorBeacon.longitude);
|
|
105
|
+
try {
|
|
106
|
+
JSONObject obj = new JSONObject(indoorBeacon.properties);
|
|
107
|
+
map.putMap("properties", convertJsonToMap(obj));
|
|
108
|
+
} catch (Throwable t) {
|
|
109
|
+
Log.e("Geofence Plugin", "Could not parse malformed JSON: \"" + indoorBeacon.properties + "\"");
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return map;
|
|
113
|
+
}
|
|
114
|
+
catch (Exception ex){
|
|
115
|
+
Log.e(TAG,ex.toString());
|
|
116
|
+
}
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
|
|
92
120
|
@Nullable
|
|
93
121
|
protected static WritableMap getPOIWritableMap(POI poi){
|
|
94
122
|
WritableMap map=new WritableNativeMap();
|
|
@@ -105,6 +133,13 @@ public class WoosmapUtil {
|
|
|
105
133
|
map.putString("zipcode", poi.zipCode);
|
|
106
134
|
//map.putString("jsondata", poi.data);
|
|
107
135
|
try {
|
|
136
|
+
JSONObject userProperties = new JSONObject();
|
|
137
|
+
Map<String, Object> userPropertiesMap = poi.getUserPropertyMap();
|
|
138
|
+
for(String key: userPropertiesMap.keySet()){
|
|
139
|
+
userProperties.put(key, userPropertiesMap.get(key));
|
|
140
|
+
}
|
|
141
|
+
map.putMap("userProperties", convertJsonToMap(userProperties));
|
|
142
|
+
|
|
108
143
|
JSONObject obj = new JSONObject(poi.data);
|
|
109
144
|
map.putMap("jsondata", convertJsonToMap(obj));
|
|
110
145
|
} catch (Throwable t) {
|
package/ios/DataPOI.swift
CHANGED
|
@@ -15,7 +15,7 @@ public class DataPOI: SearchAPIDelegate {
|
|
|
15
15
|
NotificationCenter.default.post(name: .newPOISaved, object: self, userInfo: ["POI": poi])
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
public func
|
|
18
|
+
public func searchAPIError(error: String) {
|
|
19
19
|
|
|
20
20
|
}
|
|
21
21
|
|
|
@@ -42,6 +42,12 @@ public class DataPOI: SearchAPIDelegate {
|
|
|
42
42
|
POIs.deleteAll()
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
+
public func readIndoorBeaconPOI(venueid: String?) ->[IndoorBeacon]? {
|
|
46
|
+
return IndoorBeacons.getAll(venue: venueid)
|
|
47
|
+
}
|
|
48
|
+
public func eraseIndoorBeacons() {
|
|
49
|
+
POIs.deleteAll() //TODO
|
|
50
|
+
}
|
|
45
51
|
}
|
|
46
52
|
|
|
47
53
|
extension Notification.Name {
|
package/ios/PluginGeofencing.m
CHANGED
|
@@ -102,4 +102,14 @@ RCT_EXTERN_METHOD(startCustomTracking:(NSString *)mode
|
|
|
102
102
|
withResolver:(RCTPromiseResolveBlock)resolve
|
|
103
103
|
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
104
104
|
|
|
105
|
+
RCT_EXTERN_METHOD(getAllIndoorBeacons:(RCTPromiseResolveBlock)resolve
|
|
106
|
+
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
107
|
+
|
|
108
|
+
RCT_EXTERN_METHOD(getIndoorBeacons:(NSString *)venueID
|
|
109
|
+
withResolver:(RCTPromiseResolveBlock)resolve
|
|
110
|
+
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
111
|
+
|
|
112
|
+
RCT_EXTERN_METHOD(removeIndoorBeacons:(RCTPromiseResolveBlock)resolve
|
|
113
|
+
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
114
|
+
|
|
105
115
|
@end
|
|
@@ -851,6 +851,78 @@ class PluginGeofencing: RCTEventEmitter {
|
|
|
851
851
|
}
|
|
852
852
|
}
|
|
853
853
|
|
|
854
|
+
/// Fetch Indoor Beacons
|
|
855
|
+
/// - Parameters:
|
|
856
|
+
/// - resolve: return list of Array with region info
|
|
857
|
+
/// - reject: return error info
|
|
858
|
+
@objc(getAllIndoorBeacons:withRejecter:)
|
|
859
|
+
func getAllIndoorBeacons(resolve:RCTPromiseResolveBlock,reject:RCTPromiseRejectBlock) {
|
|
860
|
+
if let objWoos = WoosmapGeofenceService.shared {
|
|
861
|
+
let capturedRegions = objWoos.getIndoorBeacons(id: nil) ?? []
|
|
862
|
+
var result: [[AnyHashable: Any]] = []
|
|
863
|
+
for item in capturedRegions {
|
|
864
|
+
result.append(formatIndoorBeaconPOIData(woosdata: item))
|
|
865
|
+
}
|
|
866
|
+
resolve(result);
|
|
867
|
+
} else {
|
|
868
|
+
reject(WoosmapGeofenceMessage.plugin_errorDomain,
|
|
869
|
+
WoosmapGeofenceMessage.woosemapNotInitialized,
|
|
870
|
+
showWoosmapError(WoosmapGeofenceMessage.woosemapNotInitialized))
|
|
871
|
+
}
|
|
872
|
+
}
|
|
873
|
+
|
|
874
|
+
/// Get Indoor beacon info by venueID
|
|
875
|
+
/// - Parameters:
|
|
876
|
+
/// - venueID: id of venue
|
|
877
|
+
/// - resolve: beacon info
|
|
878
|
+
/// - reject: Error Info
|
|
879
|
+
@objc(getIndoorBeacons:withResolver:withRejecter:)
|
|
880
|
+
func getIndoorBeacons(venueID:String, resolve:RCTPromiseResolveBlock,reject:RCTPromiseRejectBlock) {
|
|
881
|
+
if let objWoos = WoosmapGeofenceService.shared {
|
|
882
|
+
|
|
883
|
+
if(venueID != ""){
|
|
884
|
+
if let capturedRegions = objWoos.getIndoorBeacons(id:venueID){
|
|
885
|
+
var result: [[AnyHashable: Any]] = []
|
|
886
|
+
for item in capturedRegions {
|
|
887
|
+
result.append(formatIndoorBeaconPOIData(woosdata: item))
|
|
888
|
+
}
|
|
889
|
+
resolve(result);
|
|
890
|
+
}
|
|
891
|
+
else{
|
|
892
|
+
reject(WoosmapGeofenceMessage.plugin_errorDomain,
|
|
893
|
+
WoosmapGeofenceMessage.notfound_poiid,
|
|
894
|
+
showWoosmapError(WoosmapGeofenceMessage.notfound_venueid))
|
|
895
|
+
}
|
|
896
|
+
}
|
|
897
|
+
else{
|
|
898
|
+
reject(WoosmapGeofenceMessage.plugin_errorDomain,
|
|
899
|
+
WoosmapGeofenceMessage.required_poiid,
|
|
900
|
+
showWoosmapError(WoosmapGeofenceMessage.required_venueid))
|
|
901
|
+
}
|
|
902
|
+
|
|
903
|
+
} else {
|
|
904
|
+
reject(WoosmapGeofenceMessage.plugin_errorDomain,
|
|
905
|
+
WoosmapGeofenceMessage.woosemapNotInitialized,
|
|
906
|
+
showWoosmapError(WoosmapGeofenceMessage.woosemapNotInitialized))
|
|
907
|
+
}
|
|
908
|
+
}
|
|
909
|
+
|
|
910
|
+
/// Clear all Indoor beacons from DB
|
|
911
|
+
/// - Parameters:
|
|
912
|
+
/// - resolve: Deleted
|
|
913
|
+
/// - reject: Error Info
|
|
914
|
+
@objc(removeIndoorBeacons:withRejecter:)
|
|
915
|
+
func removeIndoorBeacons(resolve:RCTPromiseResolveBlock,reject:RCTPromiseRejectBlock) {
|
|
916
|
+
if let objWoos = WoosmapGeofenceService.shared {
|
|
917
|
+
objWoos.deleteIndoorBeacons()
|
|
918
|
+
resolve(WoosmapGeofenceMessage.locationDeleted);
|
|
919
|
+
} else {
|
|
920
|
+
reject(WoosmapGeofenceMessage.plugin_errorDomain,
|
|
921
|
+
WoosmapGeofenceMessage.woosemapNotInitialized,
|
|
922
|
+
showWoosmapError(WoosmapGeofenceMessage.woosemapNotInitialized))
|
|
923
|
+
}
|
|
924
|
+
}
|
|
925
|
+
|
|
854
926
|
|
|
855
927
|
// MARK: Events
|
|
856
928
|
@objc func newLocationAdded(_ notification: Notification) {
|
|
@@ -868,6 +940,21 @@ class PluginGeofencing: RCTEventEmitter {
|
|
|
868
940
|
}
|
|
869
941
|
|
|
870
942
|
// MARK: Supporting functions
|
|
943
|
+
|
|
944
|
+
private func formatIndoorBeaconPOIData(woosdata: IndoorBeacon) -> [AnyHashable: Any] {
|
|
945
|
+
var result: [AnyHashable: Any] = [:]
|
|
946
|
+
result["identifier"] = woosdata.identifier
|
|
947
|
+
result["properties"] = woosdata.properties
|
|
948
|
+
result["latitude"] = woosdata.latitude
|
|
949
|
+
result["longitude"] = woosdata.longitude
|
|
950
|
+
result["venueId"] = woosdata.venue_id
|
|
951
|
+
result["major"] = woosdata.Major
|
|
952
|
+
result["minor"] = woosdata.Minor
|
|
953
|
+
result["beaconId"] = woosdata.BeaconID
|
|
954
|
+
result["date"] = woosdata.date.timeIntervalSince1970 * 1000
|
|
955
|
+
return result
|
|
956
|
+
}
|
|
957
|
+
|
|
871
958
|
private func formatLocationData(woosdata: Location) -> [AnyHashable: Any] {
|
|
872
959
|
var result: [AnyHashable: Any] = [:]
|
|
873
960
|
if let date = woosdata.date {
|
|
@@ -909,6 +996,7 @@ class PluginGeofencing: RCTEventEmitter {
|
|
|
909
996
|
result["tags"] = woosdata.tags
|
|
910
997
|
result["types"] = woosdata.types
|
|
911
998
|
result["contact"] = woosdata.contact
|
|
999
|
+
result["userProperties"] = woosdata.user_properties
|
|
912
1000
|
return result
|
|
913
1001
|
}
|
|
914
1002
|
private func formatZOIData(woosdata: ZOI) -> [AnyHashable: Any] {
|
|
@@ -44,6 +44,8 @@ internal struct WoosmapGeofenceMessage {
|
|
|
44
44
|
static let regionid_notexist = "Region id invalid"
|
|
45
45
|
static let notfound_locationid = "Unable to fetch location info"
|
|
46
46
|
static let notfound_poiid = "Unable to fetch POI info"
|
|
47
|
+
static let notfound_venueid = "Unable to fetch beacons for venue"
|
|
48
|
+
static let required_venueid = "venue id cannot be empty or null"
|
|
47
49
|
static let plugin_errorcode = 10001
|
|
48
50
|
static let plugin_errorDomain = "WoosmapGeofencePlugin"
|
|
49
51
|
static let plugin_parsingFailed = "Something wrong while processing data. Please check input parameters"
|
|
@@ -149,13 +149,27 @@ import WoosmapGeofencing
|
|
|
149
149
|
/// - airshipEnable: To enable airship callback
|
|
150
150
|
private init(_ woosmapKey: String, _ configurationProfile: String, _ airshipEnable: Bool = false) {
|
|
151
151
|
super.init()
|
|
152
|
-
|
|
153
|
-
|
|
152
|
+
let defaults = UserDefaults.standard
|
|
153
|
+
if(woosmapKey == ""){
|
|
154
|
+
let lastSaved = defaults.string(forKey: "WoosmapGeofenceService.woosmap") ?? ""
|
|
155
|
+
self.woosmapKey = lastSaved
|
|
156
|
+
}
|
|
157
|
+
else{
|
|
158
|
+
self.woosmapKey = woosmapKey
|
|
159
|
+
}
|
|
160
|
+
if(configurationProfile == ""){
|
|
161
|
+
let lastSaved = defaults.string(forKey: "WoosmapGeofenceService.profile") ?? ""
|
|
162
|
+
self.defaultProfile = lastSaved
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
self.defaultProfile = configurationProfile
|
|
166
|
+
}
|
|
167
|
+
|
|
154
168
|
self.enableAirshipCallback = airshipEnable
|
|
155
169
|
// Save it on preferences
|
|
156
|
-
|
|
157
|
-
defaults.set(woosmapKey, forKey: "WoosmapGeofenceService.woosmap")
|
|
158
|
-
defaults.set(
|
|
170
|
+
|
|
171
|
+
defaults.set(self.woosmapKey, forKey: "WoosmapGeofenceService.woosmap")
|
|
172
|
+
defaults.set(self.defaultProfile, forKey: "WoosmapGeofenceService.profile")
|
|
159
173
|
defaults.set(airshipEnable, forKey: "WoosmapGeofenceService.AirshipCallbackEnable")
|
|
160
174
|
|
|
161
175
|
defaults.register(defaults: ["TrackingEnable": true,
|
|
@@ -246,7 +260,11 @@ import WoosmapGeofencing
|
|
|
246
260
|
private func activateGeofenceService() {
|
|
247
261
|
// Set private Woosmap key API
|
|
248
262
|
WoosmapGeofenceManager.shared.setWoosmapAPIKey(key: woosmapKey)
|
|
249
|
-
|
|
263
|
+
#if DEBUG
|
|
264
|
+
WoosmapGeofenceManager.shared.logLevel = .trace
|
|
265
|
+
#else
|
|
266
|
+
WoosmapGeofenceManager.shared.logLevel = .info
|
|
267
|
+
#endif
|
|
250
268
|
// Set delegate of protocol Location, POI and Distance
|
|
251
269
|
WoosmapGeofenceManager.shared.getLocationService().locationServiceDelegate = dataLocation
|
|
252
270
|
WoosmapGeofenceManager.shared.getLocationService().searchAPIDataDelegate = dataPOI
|
|
@@ -382,6 +400,19 @@ import WoosmapGeofencing
|
|
|
382
400
|
let poi = DataPOI().readPOI(id: id)
|
|
383
401
|
return poi
|
|
384
402
|
}
|
|
403
|
+
|
|
404
|
+
///Fetch beacon info from storage
|
|
405
|
+
/// - Returns: Array of Beacon POIs
|
|
406
|
+
public func getIndoorBeacons(id:String?) -> [IndoorBeacon]? {
|
|
407
|
+
let info = DataPOI().readIndoorBeaconPOI(venueid: id)
|
|
408
|
+
return info
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
///Delete Becaon info from storage
|
|
412
|
+
public func deleteIndoorBeacons() {
|
|
413
|
+
IndoorBeacons.deleteAll()
|
|
414
|
+
}
|
|
415
|
+
|
|
385
416
|
|
|
386
417
|
/// List all intrest zone capture by system
|
|
387
418
|
/// - Returns: Array of zones
|
package/lib/commonjs/index.js
CHANGED
|
@@ -10,6 +10,7 @@ var _nativeInterface = _interopRequireDefault(require("./internal/nativeInterfac
|
|
|
10
10
|
var _Location = _interopRequireDefault(require("./internal/Location"));
|
|
11
11
|
var _Region = _interopRequireDefault(require("./internal/Region"));
|
|
12
12
|
var _Poi = _interopRequireDefault(require("./internal/Poi"));
|
|
13
|
+
var _IndoorBeacon = _interopRequireDefault(require("./internal/IndoorBeacon"));
|
|
13
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
15
|
const eventEmitter = new _reactNative.NativeEventEmitter(_nativeInterface.default);
|
|
15
16
|
let subscriptionsLocation = {};
|
|
@@ -70,15 +71,15 @@ function requestPermissions(background) {
|
|
|
70
71
|
|
|
71
72
|
/**
|
|
72
73
|
* A method to request the required permissions to collect locations.
|
|
73
|
-
* @returns A callback that will be called on successful authorization by the app. A callback that will be called when the app denies permission.
|
|
74
|
+
* @returns A callback that will be called on successful authorization by the app. A callback that will be called when the app denies permission.
|
|
74
75
|
* The plugin will return an object with either one of the messages - BACKGROUND_LOCATION_DENIED, GRANTED, DENIED
|
|
75
76
|
*/
|
|
76
77
|
function requestBLEPermissions() {
|
|
77
|
-
if (_reactNative.Platform.OS
|
|
78
|
+
if (_reactNative.Platform.OS === 'android') {
|
|
78
79
|
return _nativeInterface.default.requestBLEPermissions();
|
|
79
80
|
} else {
|
|
80
81
|
return new Promise(resolve => {
|
|
81
|
-
resolve(
|
|
82
|
+
resolve('GRANTED');
|
|
82
83
|
});
|
|
83
84
|
}
|
|
84
85
|
}
|
|
@@ -100,7 +101,7 @@ function getBLEPermissionsStatus() {
|
|
|
100
101
|
return _nativeInterface.default.getBLEPermissionsStatus();
|
|
101
102
|
} else {
|
|
102
103
|
return new Promise(resolve => {
|
|
103
|
-
resolve(
|
|
104
|
+
resolve('GRANTED');
|
|
104
105
|
});
|
|
105
106
|
}
|
|
106
107
|
}
|
|
@@ -136,11 +137,14 @@ function clearLocationWatch(watchID) {
|
|
|
136
137
|
const saved = subscriptionsLocation[watchID];
|
|
137
138
|
if (saved) {
|
|
138
139
|
const arg0 = saved[0];
|
|
139
|
-
|
|
140
|
+
arg0.remove();
|
|
141
|
+
//eventEmitter.removeListener('geolocationDidChange', arg0);
|
|
140
142
|
const arg1 = saved[1];
|
|
141
143
|
if (arg1) {
|
|
142
|
-
|
|
144
|
+
arg1.remove();
|
|
145
|
+
//eventEmitter.removeListener('geolocationError', arg1);
|
|
143
146
|
}
|
|
147
|
+
|
|
144
148
|
subscriptionsLocation[watchID] = undefined;
|
|
145
149
|
}
|
|
146
150
|
return _nativeInterface.default.clearLocationWatch(watchID);
|
|
@@ -178,11 +182,14 @@ function clearRegionsWatch(watchID) {
|
|
|
178
182
|
const saved = subscriptionsRegion[watchID];
|
|
179
183
|
if (saved) {
|
|
180
184
|
const arg0 = saved[0];
|
|
181
|
-
|
|
185
|
+
arg0.remove();
|
|
186
|
+
//eventEmitter.removeListener('woosmapgeofenceRegionDidChange', arg0);
|
|
182
187
|
const arg1 = saved[1];
|
|
183
188
|
if (arg1) {
|
|
184
|
-
|
|
189
|
+
arg1.remove();
|
|
190
|
+
//eventEmitter.removeListener('woosmapgeofenceRegionError', arg1);
|
|
185
191
|
}
|
|
192
|
+
|
|
186
193
|
subscriptionsRegion[watchID] = undefined;
|
|
187
194
|
}
|
|
188
195
|
return _nativeInterface.default.clearRegionsWatch(watchID);
|
|
@@ -324,7 +331,7 @@ function removePois() {
|
|
|
324
331
|
return _nativeInterface.default.removeAllPois();
|
|
325
332
|
}
|
|
326
333
|
/**
|
|
327
|
-
* if preset tracking profiles don’t fit with your use cases, you can build your own profile and uses the startCustomTracking() method.
|
|
334
|
+
* if preset tracking profiles don’t fit with your use cases, you can build your own profile and uses the startCustomTracking() method.
|
|
328
335
|
* There are two way to host the json file:
|
|
329
336
|
* - included in the client application (local)
|
|
330
337
|
* - hosted externally in a file folder in your information system (external)
|
|
@@ -335,6 +342,56 @@ function removePois() {
|
|
|
335
342
|
function startCustomTracking(sourceType, source) {
|
|
336
343
|
return _nativeInterface.default.startCustomTracking(sourceType, source);
|
|
337
344
|
}
|
|
345
|
+
|
|
346
|
+
/**
|
|
347
|
+
* Retrieve Beacon info for venue
|
|
348
|
+
* @param venueID - Optional venue id
|
|
349
|
+
* @param ref - Optional beacon id return by region event
|
|
350
|
+
* @returns promise with A callback that will be called on success or error.
|
|
351
|
+
*/
|
|
352
|
+
function getIndoorBeacons(venueID, ref) {
|
|
353
|
+
if (venueID == null) {
|
|
354
|
+
return _nativeInterface.default.getAllIndoorBeacons().then(result => {
|
|
355
|
+
var formatted = [];
|
|
356
|
+
result.forEach(item => {
|
|
357
|
+
if (ref !== undefined) {
|
|
358
|
+
if (item.identifier === ref) {
|
|
359
|
+
formatted.push(_IndoorBeacon.default.jsonToObj(item));
|
|
360
|
+
}
|
|
361
|
+
} else {
|
|
362
|
+
formatted.push(_IndoorBeacon.default.jsonToObj(item));
|
|
363
|
+
}
|
|
364
|
+
});
|
|
365
|
+
return Promise.resolve(formatted);
|
|
366
|
+
}).catch(e => {
|
|
367
|
+
return Promise.reject(e);
|
|
368
|
+
});
|
|
369
|
+
} else {
|
|
370
|
+
return _nativeInterface.default.getIndoorBeacons(venueID).then(result => {
|
|
371
|
+
var formatted = [];
|
|
372
|
+
result.forEach(item => {
|
|
373
|
+
if (ref !== undefined) {
|
|
374
|
+
if (item.identifier === ref) {
|
|
375
|
+
formatted.push(_IndoorBeacon.default.jsonToObj(item));
|
|
376
|
+
}
|
|
377
|
+
} else {
|
|
378
|
+
formatted.push(_IndoorBeacon.default.jsonToObj(item));
|
|
379
|
+
}
|
|
380
|
+
});
|
|
381
|
+
return Promise.resolve(formatted);
|
|
382
|
+
}).catch(e => {
|
|
383
|
+
return Promise.reject(e);
|
|
384
|
+
});
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
/**
|
|
389
|
+
* Remove saved POI info
|
|
390
|
+
* @returns promise with A callback that will be called on success or error.
|
|
391
|
+
*/
|
|
392
|
+
function removeIndoorBeacons() {
|
|
393
|
+
return _nativeInterface.default.removeIndoorBeacons();
|
|
394
|
+
}
|
|
338
395
|
const WoosmapGeofencing = {
|
|
339
396
|
initialize,
|
|
340
397
|
setWoosmapApiKey,
|
|
@@ -357,8 +414,9 @@ const WoosmapGeofencing = {
|
|
|
357
414
|
removeLocations,
|
|
358
415
|
getPois,
|
|
359
416
|
removePois,
|
|
360
|
-
startCustomTracking
|
|
417
|
+
startCustomTracking,
|
|
418
|
+
getIndoorBeacons,
|
|
419
|
+
removeIndoorBeacons
|
|
361
420
|
};
|
|
362
|
-
var _default = WoosmapGeofencing;
|
|
363
|
-
exports.default = _default;
|
|
421
|
+
var _default = exports.default = WoosmapGeofencing;
|
|
364
422
|
//# sourceMappingURL=index.js.map
|