@woosmap/react-native-plugin-geofencing 0.2.5 → 0.4.0
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/build.gradle +1 -1
- package/android/src/main/java/com/reactnativeplugingeofencing/PluginGeofencingModule.java +135 -5
- package/android/src/main/java/com/reactnativeplugingeofencing/WoosmapMessageAndKey.java +3 -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 +6 -0
- package/ios/PluginGeofencing.m +10 -0
- package/ios/PluginGeofencing.swift +88 -0
- package/ios/WoosmapGeofenceMessage.swift +2 -0
- package/ios/WoosmapGeofenceService.swift +98 -68
- package/lib/commonjs/index.js +97 -8
- 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 +97 -7
- 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 +29 -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
package/android/build.gradle
CHANGED
|
@@ -60,7 +60,7 @@ dependencies {
|
|
|
60
60
|
implementation 'com.google.android.gms:play-services-location:21.0.1'
|
|
61
61
|
implementation 'com.google.code.gson:gson:2.8.8'
|
|
62
62
|
implementation "com.github.woosmap:geofencing-core-android-sdk:core_geofence_2.+"
|
|
63
|
-
implementation("com.webgeoservices.woosmapgeofencing:woosmap-mobile-sdk:
|
|
63
|
+
implementation("com.webgeoservices.woosmapgeofencing:woosmap-mobile-sdk:4.+")
|
|
64
64
|
implementation 'com.google.android.gms:play-services-maps:18.1.0'
|
|
65
65
|
implementation 'androidx.room:room-runtime:2.2.4'
|
|
66
66
|
annotationProcessor 'androidx.room:room-compiler:2.2.4'
|
|
@@ -4,14 +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
11
|
import androidx.core.app.ActivityCompat;
|
|
13
12
|
|
|
14
|
-
import com.facebook.react.bridge.Callback;
|
|
15
13
|
import com.facebook.react.bridge.LifecycleEventListener;
|
|
16
14
|
import com.facebook.react.bridge.Promise;
|
|
17
15
|
import com.facebook.react.bridge.ReactApplicationContext;
|
|
@@ -19,7 +17,6 @@ import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
|
|
19
17
|
import com.facebook.react.bridge.ReactMethod;
|
|
20
18
|
import com.facebook.react.bridge.ReadableArray;
|
|
21
19
|
import com.facebook.react.bridge.ReadableMap;
|
|
22
|
-
import com.facebook.react.bridge.WritableMap;
|
|
23
20
|
import com.facebook.react.module.annotations.ReactModule;
|
|
24
21
|
import com.facebook.react.modules.core.PermissionAwareActivity;
|
|
25
22
|
import com.facebook.react.modules.core.PermissionListener;
|
|
@@ -27,8 +24,6 @@ import com.webgeoservices.woosmapgeofencing.Woosmap;
|
|
|
27
24
|
import com.webgeoservices.woosmapgeofencing.WoosmapSettings;
|
|
28
25
|
import com.webgeoservices.woosmapgeofencingcore.database.Region;
|
|
29
26
|
|
|
30
|
-
import java.lang.reflect.Array;
|
|
31
|
-
import java.util.ArrayList;
|
|
32
27
|
import java.util.HashMap;
|
|
33
28
|
import java.util.Iterator;
|
|
34
29
|
|
|
@@ -42,7 +37,9 @@ public class PluginGeofencingModule extends ReactContextBaseJavaModule implement
|
|
|
42
37
|
private ReactApplicationContext reactContext;
|
|
43
38
|
private Woosmap woosmap;
|
|
44
39
|
private static final int PERMISSIONS_REQUEST_CODE = 150; // random request code
|
|
40
|
+
private static final int BLE_PERMISSIONS_REQUEST_CODE = 160;
|
|
45
41
|
private Promise mPermissionsRequestPromise;
|
|
42
|
+
private Promise mBLEPermissionsRequestPromise;
|
|
46
43
|
private WoosLocationReadyListener locationReadyListener;
|
|
47
44
|
private WoosRegionReadyListener regionReadyListener;
|
|
48
45
|
|
|
@@ -88,6 +85,8 @@ public class PluginGeofencingModule extends ReactContextBaseJavaModule implement
|
|
|
88
85
|
trackingProfile = Woosmap.ConfigurationProfile.passiveTracking;
|
|
89
86
|
} else if (map.getString(WoosmapMessageAndKey.profileTrackingKey).equals(Woosmap.ConfigurationProfile.visitsTracking)) {
|
|
90
87
|
trackingProfile = Woosmap.ConfigurationProfile.visitsTracking;
|
|
88
|
+
} else if (map.getString(WoosmapMessageAndKey.profileTrackingKey).equals(Woosmap.ConfigurationProfile.beaconTracking)) {
|
|
89
|
+
trackingProfile = Woosmap.ConfigurationProfile.beaconTracking;
|
|
91
90
|
} else {
|
|
92
91
|
promise.reject(WoosmapMessageAndKey.errorCode, WoosmapMessageAndKey.invalidProfileTrackingError);
|
|
93
92
|
return;
|
|
@@ -165,6 +164,32 @@ public class PluginGeofencingModule extends ReactContextBaseJavaModule implement
|
|
|
165
164
|
}
|
|
166
165
|
}
|
|
167
166
|
|
|
167
|
+
/***
|
|
168
|
+
* Requests Bluetooth permissions.
|
|
169
|
+
* @param promise React native callback context.
|
|
170
|
+
*/
|
|
171
|
+
@ReactMethod
|
|
172
|
+
public void requestBLEPermissions(Promise promise){
|
|
173
|
+
try{
|
|
174
|
+
if (promise == null) {
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
PermissionAwareActivity activity = (PermissionAwareActivity) getCurrentActivity();
|
|
178
|
+
if (activity == null) {
|
|
179
|
+
promise.resolve(WoosmapMessageAndKey.unknownMessage);
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
|
183
|
+
mBLEPermissionsRequestPromise = promise;
|
|
184
|
+
activity.requestPermissions(new String[]{Manifest.permission.BLUETOOTH_SCAN, Manifest.permission.BLUETOOTH_ADMIN, Manifest.permission.BLUETOOTH}, BLE_PERMISSIONS_REQUEST_CODE, this);
|
|
185
|
+
}else{
|
|
186
|
+
promise.resolve(WoosmapMessageAndKey.backgroundPermissionGrantedMessage);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
catch (Exception ex){
|
|
190
|
+
promise.reject(WoosmapMessageAndKey.errorCode, ex.getMessage(), ex);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
168
193
|
|
|
169
194
|
@Override
|
|
170
195
|
public boolean onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
|
|
@@ -172,9 +197,50 @@ public class PluginGeofencingModule extends ReactContextBaseJavaModule implement
|
|
|
172
197
|
providePermissionStatus(mPermissionsRequestPromise);
|
|
173
198
|
mPermissionsRequestPromise = null;
|
|
174
199
|
}
|
|
200
|
+
if (requestCode == BLE_PERMISSIONS_REQUEST_CODE && mBLEPermissionsRequestPromise != null) {
|
|
201
|
+
provideBLEPermissionStatus(mBLEPermissionsRequestPromise);
|
|
202
|
+
mBLEPermissionsRequestPromise = null;
|
|
203
|
+
}
|
|
175
204
|
return true;
|
|
176
205
|
}
|
|
177
206
|
|
|
207
|
+
/***
|
|
208
|
+
* Provide status of bluetooth permission.
|
|
209
|
+
* @param promise React native callback context.
|
|
210
|
+
*/
|
|
211
|
+
private void provideBLEPermissionStatus(final Promise promise){
|
|
212
|
+
if (promise == null) {
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
Activity activity = getCurrentActivity();
|
|
216
|
+
if (activity == null) {
|
|
217
|
+
promise.resolve(WoosmapMessageAndKey.unknownMessage);
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
boolean granted = true;
|
|
221
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
|
222
|
+
granted = ActivityCompat.checkSelfPermission(activity, Manifest.permission.ACCESS_BACKGROUND_LOCATION) == PackageManager.PERMISSION_GRANTED;
|
|
223
|
+
}
|
|
224
|
+
if (granted){
|
|
225
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
|
226
|
+
granted = ActivityCompat.checkSelfPermission(activity, Manifest.permission.BLUETOOTH_SCAN) == PackageManager.PERMISSION_GRANTED;
|
|
227
|
+
}
|
|
228
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
|
229
|
+
if (granted){
|
|
230
|
+
granted = ActivityCompat.checkSelfPermission(activity, Manifest.permission.BLUETOOTH_ADMIN) == PackageManager.PERMISSION_GRANTED;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
if (granted) {
|
|
234
|
+
promise.resolve(WoosmapMessageAndKey.blePermissionGrantedMessage);
|
|
235
|
+
} else {
|
|
236
|
+
promise.resolve(WoosmapMessageAndKey.deniedPermissionMessage);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
else{
|
|
240
|
+
promise.resolve(WoosmapMessageAndKey.backgroundPermissionDeniedMessage);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
|
|
178
244
|
/***
|
|
179
245
|
* Provide status of foreground and background location permission.
|
|
180
246
|
* @param promise React native callback context.
|
|
@@ -224,6 +290,17 @@ public class PluginGeofencingModule extends ReactContextBaseJavaModule implement
|
|
|
224
290
|
providePermissionStatus(promise);
|
|
225
291
|
}
|
|
226
292
|
|
|
293
|
+
/***
|
|
294
|
+
* Checks if the required Bluetooth permissions are granted or not.
|
|
295
|
+
* Returns DENIED if no permissions are granted.
|
|
296
|
+
* Returns GRANTED if bluetooth permission is granted.
|
|
297
|
+
* Returns BACKGROUND_LOCATION_DENIED if background location permission is not granted.
|
|
298
|
+
*/
|
|
299
|
+
@ReactMethod
|
|
300
|
+
public void getBLEPermissionsStatus(final Promise promise){
|
|
301
|
+
provideBLEPermissionStatus(promise);
|
|
302
|
+
}
|
|
303
|
+
|
|
227
304
|
/***
|
|
228
305
|
* Check if the user has given location permission.
|
|
229
306
|
* @param isBackground Pass true if the background permission needs to be checked.
|
|
@@ -319,6 +396,7 @@ public class PluginGeofencingModule extends ReactContextBaseJavaModule implement
|
|
|
319
396
|
String trackingProfile = data.getString(0);
|
|
320
397
|
if (trackingProfile.equals(Woosmap.ConfigurationProfile.liveTracking) ||
|
|
321
398
|
trackingProfile.equals(Woosmap.ConfigurationProfile.passiveTracking) ||
|
|
399
|
+
trackingProfile.equals(Woosmap.ConfigurationProfile.beaconTracking) ||
|
|
322
400
|
trackingProfile.equals(Woosmap.ConfigurationProfile.visitsTracking)) {
|
|
323
401
|
woosmap.startTracking(trackingProfile);
|
|
324
402
|
promise.resolve(WoosmapMessageAndKey.successMessage);
|
|
@@ -834,5 +912,57 @@ public class PluginGeofencingModule extends ReactContextBaseJavaModule implement
|
|
|
834
912
|
}
|
|
835
913
|
}
|
|
836
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
|
+
}
|
|
837
967
|
|
|
838
968
|
}
|
|
@@ -13,6 +13,8 @@ public class WoosmapMessageAndKey {
|
|
|
13
13
|
protected static String deniedPermissionMessage="DENIED";
|
|
14
14
|
protected static String foregroundPermissionGrantedMessage="GRANTED_FOREGROUND";
|
|
15
15
|
protected static String backgroundPermissionGrantedMessage="GRANTED_BACKGROUND";
|
|
16
|
+
protected static String backgroundPermissionDeniedMessage="BACKGROUND_LOCATION_DENIED";
|
|
17
|
+
protected static String blePermissionGrantedMessage="GRANTED";
|
|
16
18
|
protected static String woosmapKeyNotProvide="Woosmap API Key not provided";
|
|
17
19
|
protected static String woosmapNotInitialized="Woosmap not initialized";
|
|
18
20
|
protected static String trackingProfileNotProvided="Tracking profile is missing";
|
|
@@ -38,6 +40,7 @@ public class WoosmapMessageAndKey {
|
|
|
38
40
|
protected static String isochroneTypeKey="isochrone";
|
|
39
41
|
protected static String validRegionTypeMessage="Provide valid region type (circle/isochrone)";
|
|
40
42
|
protected static String requiredRegionid="Region id cannot be empty or null";
|
|
43
|
+
protected static String requiredVenueId="Venue id cannot be empty";
|
|
41
44
|
protected static String requiredLocationid="Location id cannot be empty or null";
|
|
42
45
|
protected static String invalidRegionid="Unable to fetch region info";
|
|
43
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
|
@@ -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"
|