@woosmap/react-native-plugin-geofencing 0.2.5 → 0.3.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 +84 -0
- package/android/src/main/java/com/reactnativeplugingeofencing/WoosmapMessageAndKey.java +2 -0
- package/ios/WoosmapGeofenceService.swift +61 -62
- package/lib/commonjs/index.js +31 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/index.js +32 -1
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/index.d.ts +13 -0
- package/package.json +1 -1
- 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'
|
|
@@ -9,6 +9,7 @@ import android.util.Log;
|
|
|
9
9
|
|
|
10
10
|
import androidx.annotation.NonNull;
|
|
11
11
|
import androidx.annotation.RequiresApi;
|
|
12
|
+
import androidx.appcompat.app.AppCompatActivity;
|
|
12
13
|
import androidx.core.app.ActivityCompat;
|
|
13
14
|
|
|
14
15
|
import com.facebook.react.bridge.Callback;
|
|
@@ -42,7 +43,9 @@ public class PluginGeofencingModule extends ReactContextBaseJavaModule implement
|
|
|
42
43
|
private ReactApplicationContext reactContext;
|
|
43
44
|
private Woosmap woosmap;
|
|
44
45
|
private static final int PERMISSIONS_REQUEST_CODE = 150; // random request code
|
|
46
|
+
private static final int BLE_PERMISSIONS_REQUEST_CODE = 160;
|
|
45
47
|
private Promise mPermissionsRequestPromise;
|
|
48
|
+
private Promise mBLEPermissionsRequestPromise;
|
|
46
49
|
private WoosLocationReadyListener locationReadyListener;
|
|
47
50
|
private WoosRegionReadyListener regionReadyListener;
|
|
48
51
|
|
|
@@ -88,6 +91,8 @@ public class PluginGeofencingModule extends ReactContextBaseJavaModule implement
|
|
|
88
91
|
trackingProfile = Woosmap.ConfigurationProfile.passiveTracking;
|
|
89
92
|
} else if (map.getString(WoosmapMessageAndKey.profileTrackingKey).equals(Woosmap.ConfigurationProfile.visitsTracking)) {
|
|
90
93
|
trackingProfile = Woosmap.ConfigurationProfile.visitsTracking;
|
|
94
|
+
} else if (map.getString(WoosmapMessageAndKey.profileTrackingKey).equals(Woosmap.ConfigurationProfile.beaconTracking)) {
|
|
95
|
+
trackingProfile = Woosmap.ConfigurationProfile.beaconTracking;
|
|
91
96
|
} else {
|
|
92
97
|
promise.reject(WoosmapMessageAndKey.errorCode, WoosmapMessageAndKey.invalidProfileTrackingError);
|
|
93
98
|
return;
|
|
@@ -165,6 +170,32 @@ public class PluginGeofencingModule extends ReactContextBaseJavaModule implement
|
|
|
165
170
|
}
|
|
166
171
|
}
|
|
167
172
|
|
|
173
|
+
/***
|
|
174
|
+
* Requests Bluetooth permissions.
|
|
175
|
+
* @param promise React native callback context.
|
|
176
|
+
*/
|
|
177
|
+
@ReactMethod
|
|
178
|
+
public void requestBLEPermissions(Promise promise){
|
|
179
|
+
try{
|
|
180
|
+
if (promise == null) {
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
PermissionAwareActivity activity = (PermissionAwareActivity) getCurrentActivity();
|
|
184
|
+
if (activity == null) {
|
|
185
|
+
promise.resolve(WoosmapMessageAndKey.unknownMessage);
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
|
189
|
+
mBLEPermissionsRequestPromise = promise;
|
|
190
|
+
activity.requestPermissions(new String[]{Manifest.permission.BLUETOOTH_SCAN, Manifest.permission.BLUETOOTH_ADMIN, Manifest.permission.BLUETOOTH}, BLE_PERMISSIONS_REQUEST_CODE, this);
|
|
191
|
+
}else{
|
|
192
|
+
promise.resolve(WoosmapMessageAndKey.backgroundPermissionGrantedMessage);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
catch (Exception ex){
|
|
196
|
+
promise.reject(WoosmapMessageAndKey.errorCode, ex.getMessage(), ex);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
168
199
|
|
|
169
200
|
@Override
|
|
170
201
|
public boolean onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
|
|
@@ -172,9 +203,50 @@ public class PluginGeofencingModule extends ReactContextBaseJavaModule implement
|
|
|
172
203
|
providePermissionStatus(mPermissionsRequestPromise);
|
|
173
204
|
mPermissionsRequestPromise = null;
|
|
174
205
|
}
|
|
206
|
+
if (requestCode == BLE_PERMISSIONS_REQUEST_CODE && mBLEPermissionsRequestPromise != null) {
|
|
207
|
+
provideBLEPermissionStatus(mBLEPermissionsRequestPromise);
|
|
208
|
+
mBLEPermissionsRequestPromise = null;
|
|
209
|
+
}
|
|
175
210
|
return true;
|
|
176
211
|
}
|
|
177
212
|
|
|
213
|
+
/***
|
|
214
|
+
* Provide status of bluetooth permission.
|
|
215
|
+
* @param promise React native callback context.
|
|
216
|
+
*/
|
|
217
|
+
private void provideBLEPermissionStatus(final Promise promise){
|
|
218
|
+
if (promise == null) {
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
Activity activity = getCurrentActivity();
|
|
222
|
+
if (activity == null) {
|
|
223
|
+
promise.resolve(WoosmapMessageAndKey.unknownMessage);
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
boolean granted = true;
|
|
227
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
|
228
|
+
granted = ActivityCompat.checkSelfPermission(activity, Manifest.permission.ACCESS_BACKGROUND_LOCATION) == PackageManager.PERMISSION_GRANTED;
|
|
229
|
+
}
|
|
230
|
+
if (granted){
|
|
231
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
|
232
|
+
granted = ActivityCompat.checkSelfPermission(activity, Manifest.permission.BLUETOOTH_SCAN) == PackageManager.PERMISSION_GRANTED;
|
|
233
|
+
}
|
|
234
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
|
235
|
+
if (granted){
|
|
236
|
+
granted = ActivityCompat.checkSelfPermission(activity, Manifest.permission.BLUETOOTH_ADMIN) == PackageManager.PERMISSION_GRANTED;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
if (granted) {
|
|
240
|
+
promise.resolve(WoosmapMessageAndKey.blePermissionGrantedMessage);
|
|
241
|
+
} else {
|
|
242
|
+
promise.resolve(WoosmapMessageAndKey.deniedPermissionMessage);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
else{
|
|
246
|
+
promise.resolve(WoosmapMessageAndKey.backgroundPermissionDeniedMessage);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
|
|
178
250
|
/***
|
|
179
251
|
* Provide status of foreground and background location permission.
|
|
180
252
|
* @param promise React native callback context.
|
|
@@ -224,6 +296,17 @@ public class PluginGeofencingModule extends ReactContextBaseJavaModule implement
|
|
|
224
296
|
providePermissionStatus(promise);
|
|
225
297
|
}
|
|
226
298
|
|
|
299
|
+
/***
|
|
300
|
+
* Checks if the required Bluetooth permissions are granted or not.
|
|
301
|
+
* Returns DENIED if no permissions are granted.
|
|
302
|
+
* Returns GRANTED if bluetooth permission is granted.
|
|
303
|
+
* Returns BACKGROUND_LOCATION_DENIED if background location permission is not granted.
|
|
304
|
+
*/
|
|
305
|
+
@ReactMethod
|
|
306
|
+
public void getBLEPermissionsStatus(final Promise promise){
|
|
307
|
+
provideBLEPermissionStatus(promise);
|
|
308
|
+
}
|
|
309
|
+
|
|
227
310
|
/***
|
|
228
311
|
* Check if the user has given location permission.
|
|
229
312
|
* @param isBackground Pass true if the background permission needs to be checked.
|
|
@@ -319,6 +402,7 @@ public class PluginGeofencingModule extends ReactContextBaseJavaModule implement
|
|
|
319
402
|
String trackingProfile = data.getString(0);
|
|
320
403
|
if (trackingProfile.equals(Woosmap.ConfigurationProfile.liveTracking) ||
|
|
321
404
|
trackingProfile.equals(Woosmap.ConfigurationProfile.passiveTracking) ||
|
|
405
|
+
trackingProfile.equals(Woosmap.ConfigurationProfile.beaconTracking) ||
|
|
322
406
|
trackingProfile.equals(Woosmap.ConfigurationProfile.visitsTracking)) {
|
|
323
407
|
woosmap.startTracking(trackingProfile);
|
|
324
408
|
promise.resolve(WoosmapMessageAndKey.successMessage);
|
|
@@ -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";
|
|
@@ -48,10 +48,10 @@ import WoosmapGeofencing
|
|
|
48
48
|
/// Status of search api On/Off
|
|
49
49
|
@objc public var searchAPIRequestEnable: Bool {
|
|
50
50
|
get {
|
|
51
|
-
return
|
|
51
|
+
return WoosmapGeofenceManager.shared.getSearchAPIRequestEnable()
|
|
52
52
|
}
|
|
53
53
|
set {
|
|
54
|
-
|
|
54
|
+
WoosmapGeofenceManager.shared.setSearchAPIRequestEnable(enable: newValue)
|
|
55
55
|
|
|
56
56
|
}
|
|
57
57
|
}
|
|
@@ -59,10 +59,10 @@ import WoosmapGeofencing
|
|
|
59
59
|
/// Status of distance api On/Off
|
|
60
60
|
@objc public var distanceAPIRequestEnable: Bool {
|
|
61
61
|
get {
|
|
62
|
-
return
|
|
62
|
+
return WoosmapGeofenceManager.shared.getDistanceAPIRequestEnable()
|
|
63
63
|
}
|
|
64
64
|
set {
|
|
65
|
-
|
|
65
|
+
WoosmapGeofenceManager.shared.setDistanceAPIRequestEnable(enable: newValue)
|
|
66
66
|
|
|
67
67
|
}
|
|
68
68
|
}
|
|
@@ -70,10 +70,10 @@ import WoosmapGeofencing
|
|
|
70
70
|
/// status of CreationRegionEnable. On/Off
|
|
71
71
|
@objc public var searchAPICreationRegionEnable: Bool {
|
|
72
72
|
get {
|
|
73
|
-
return
|
|
73
|
+
return WoosmapGeofenceManager.shared.getSearchAPICreationRegionEnable()
|
|
74
74
|
}
|
|
75
75
|
set {
|
|
76
|
-
|
|
76
|
+
WoosmapGeofenceManager.shared.setSearchAPICreationRegionEnable(enable: newValue)
|
|
77
77
|
|
|
78
78
|
}
|
|
79
79
|
}
|
|
@@ -81,20 +81,20 @@ import WoosmapGeofencing
|
|
|
81
81
|
/// Status of HighfrequencyLocation Mode. On/Off
|
|
82
82
|
@objc public var modeHighfrequencyLocation: Bool {
|
|
83
83
|
get {
|
|
84
|
-
return
|
|
84
|
+
return WoosmapGeofenceManager.shared.getModeHighfrequencyLocation()
|
|
85
85
|
}
|
|
86
86
|
set {
|
|
87
|
-
|
|
87
|
+
WoosmapGeofenceManager.shared.setModeHighfrequencyLocation(enable: newValue)
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
/// Status of tracking state. On/Off
|
|
92
92
|
@objc public var trackingState: Bool {
|
|
93
93
|
get {
|
|
94
|
-
return
|
|
94
|
+
return WoosmapGeofenceManager.shared.getTrackingState()
|
|
95
95
|
}
|
|
96
96
|
set {
|
|
97
|
-
|
|
97
|
+
WoosmapGeofenceManager.shared.setTrackingEnable(enable: newValue)
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
100
|
|
|
@@ -103,7 +103,7 @@ import WoosmapGeofencing
|
|
|
103
103
|
/// This callback received when application become active
|
|
104
104
|
@objc func appDidBecomeActive() {
|
|
105
105
|
DispatchQueue.main.async {
|
|
106
|
-
|
|
106
|
+
WoosmapGeofenceManager.shared.didBecomeActive()
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
109
|
|
|
@@ -111,14 +111,14 @@ import WoosmapGeofencing
|
|
|
111
111
|
@objc func appDidEnterBackground() {
|
|
112
112
|
if CLLocationManager.authorizationStatus() != .notDetermined {
|
|
113
113
|
DispatchQueue.main.async {
|
|
114
|
-
|
|
114
|
+
WoosmapGeofenceManager.shared.startMonitoringInBackground()
|
|
115
115
|
}
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
118
|
|
|
119
119
|
/// This callback received when application is terminated
|
|
120
120
|
@objc func appWillTerminate() {
|
|
121
|
-
|
|
121
|
+
WoosmapGeofenceManager.shared.setModeHighfrequencyLocation(enable: false)
|
|
122
122
|
}
|
|
123
123
|
// MARK: Init
|
|
124
124
|
|
|
@@ -203,7 +203,7 @@ import WoosmapGeofencing
|
|
|
203
203
|
let group = DispatchGroup()
|
|
204
204
|
group.enter()
|
|
205
205
|
DispatchQueue.main.async {
|
|
206
|
-
|
|
206
|
+
WoosmapGeofenceManager.shared.setWoosmapAPIKey(key: self.woosmapKey)
|
|
207
207
|
group.leave()
|
|
208
208
|
}
|
|
209
209
|
group.wait()
|
|
@@ -220,7 +220,7 @@ import WoosmapGeofencing
|
|
|
220
220
|
let group = DispatchGroup()
|
|
221
221
|
group.enter()
|
|
222
222
|
DispatchQueue.main.async {
|
|
223
|
-
|
|
223
|
+
WoosmapGeofenceManager.shared.startTracking(configurationProfile: savedProfile)
|
|
224
224
|
group.leave()
|
|
225
225
|
}
|
|
226
226
|
group.wait()
|
|
@@ -234,47 +234,47 @@ import WoosmapGeofencing
|
|
|
234
234
|
defaults.set(self.defaultProfile, forKey: "WoosmapGeofenceService.profile")
|
|
235
235
|
throw WoosGeofenceError(WoosmapGeofenceMessage.invalidProfile)
|
|
236
236
|
}
|
|
237
|
-
// print ("Highfrequency \(
|
|
237
|
+
// print ("Highfrequency \(WoosmapGeofenceManager.shared.getModeHighfrequencyLocation()) , TrackingState \(WoosmapGeofenceManager.shared.getTrackingState()) ")
|
|
238
238
|
}
|
|
239
239
|
|
|
240
240
|
/// Stop tracking
|
|
241
241
|
public func stopTracking() {
|
|
242
|
-
|
|
242
|
+
WoosmapGeofenceManager.shared.stopTracking()
|
|
243
243
|
}
|
|
244
244
|
|
|
245
245
|
/// activating WoosmapGeofencing with default parameters
|
|
246
246
|
private func activateGeofenceService() {
|
|
247
247
|
// Set private Woosmap key API
|
|
248
|
-
|
|
248
|
+
WoosmapGeofenceManager.shared.setWoosmapAPIKey(key: woosmapKey)
|
|
249
249
|
|
|
250
250
|
// Set delegate of protocol Location, POI and Distance
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
251
|
+
WoosmapGeofenceManager.shared.getLocationService().locationServiceDelegate = dataLocation
|
|
252
|
+
WoosmapGeofenceManager.shared.getLocationService().searchAPIDataDelegate = dataPOI
|
|
253
|
+
WoosmapGeofenceManager.shared.getLocationService().distanceAPIDataDelegate = dataDistance
|
|
254
|
+
WoosmapGeofenceManager.shared.getLocationService().regionDelegate = dataRegion
|
|
255
255
|
|
|
256
256
|
// Enable Visit and set delegate of protocol Visit
|
|
257
|
-
|
|
257
|
+
WoosmapGeofenceManager.shared.getLocationService().visitDelegate = dataVisit
|
|
258
258
|
if(self.enableAirshipCallback){
|
|
259
259
|
// Set delagate for Airship Cloud
|
|
260
|
-
|
|
260
|
+
WoosmapGeofenceManager.shared.getLocationService().airshipEventsDelegate = airshipEvents
|
|
261
261
|
}
|
|
262
262
|
|
|
263
263
|
// Set delagate for Marketing Cloud
|
|
264
|
-
|
|
264
|
+
WoosmapGeofenceManager.shared.getLocationService().marketingCloudEventsDelegate = marketingCloudEvents
|
|
265
265
|
if defaultPOIRadius != "" {
|
|
266
|
-
|
|
266
|
+
WoosmapGeofenceManager.shared.setPoiRadius(radius: formatedRadius(radius: defaultPOIRadius))
|
|
267
267
|
}
|
|
268
268
|
|
|
269
269
|
if let savedProfile = ConfigurationProfile(rawValue: defaultProfile) {
|
|
270
|
-
|
|
270
|
+
WoosmapGeofenceManager.shared.startTracking(configurationProfile: savedProfile)
|
|
271
271
|
}
|
|
272
272
|
// else{ //Default tracking
|
|
273
|
-
//
|
|
273
|
+
// WoosmapGeofenceManager.shared.startTracking(configurationProfile: ConfigurationProfile.passiveTracking)
|
|
274
274
|
// }
|
|
275
275
|
// Check if the authorization Status of location Manager
|
|
276
276
|
if CLLocationManager.authorizationStatus() != .notDetermined {
|
|
277
|
-
|
|
277
|
+
WoosmapGeofenceManager.shared.startMonitoringInBackground()
|
|
278
278
|
}
|
|
279
279
|
|
|
280
280
|
NotificationCenter.default.addObserver(self,
|
|
@@ -290,7 +290,7 @@ import WoosmapGeofencing
|
|
|
290
290
|
// self.searchAPIRequestEnable = true
|
|
291
291
|
// self.distanceAPIRequestEnable = true
|
|
292
292
|
// self.searchAPICreationRegionEnable = true
|
|
293
|
-
// print ("\(
|
|
293
|
+
// print ("\(WoosmapGeofenceManager.shared.getModeHighfrequencyLocation()) \(WoosmapGeofenceManager.shared.getTrackingState()) ")
|
|
294
294
|
}
|
|
295
295
|
|
|
296
296
|
/// Adding new region
|
|
@@ -301,19 +301,19 @@ import WoosmapGeofencing
|
|
|
301
301
|
/// - type: String circle/isochrone
|
|
302
302
|
/// - Returns: Status for reagion created or not and new region id from system
|
|
303
303
|
public func addRegion(identifier: String, center: CLLocationCoordinate2D, radius: Int, type: String) -> (isCreate: Bool, identifier: String) {
|
|
304
|
-
return
|
|
304
|
+
return WoosmapGeofenceManager.shared.locationService.addRegion(identifier: identifier, center: center, radius: radius, type:type)
|
|
305
305
|
}
|
|
306
306
|
|
|
307
307
|
/// Remove region from system
|
|
308
308
|
/// - Parameter center: geoLocation point of region
|
|
309
309
|
public func removeRegion(center: CLLocationCoordinate2D) {
|
|
310
|
-
return
|
|
310
|
+
return WoosmapGeofenceManager.shared.locationService.removeRegion(center: center)
|
|
311
311
|
}
|
|
312
312
|
|
|
313
313
|
/// Remove region from system
|
|
314
314
|
/// - Parameter identifier: region id assined for region
|
|
315
315
|
public func removeRegion(identifier: String) {
|
|
316
|
-
return
|
|
316
|
+
return WoosmapGeofenceManager.shared.locationService.removeRegion(identifier: identifier)
|
|
317
317
|
}
|
|
318
318
|
|
|
319
319
|
/// Get location information for geopoint from woos system
|
|
@@ -322,7 +322,7 @@ import WoosmapGeofencing
|
|
|
322
322
|
/// - locationId: id recorded for that location
|
|
323
323
|
public func searchAPIRequest(location: CLLocationCoordinate2D, locationId: String = "") {
|
|
324
324
|
// TODO: Missing implementation
|
|
325
|
-
//
|
|
325
|
+
//WoosmapGeofenceManager.shared.getLocationService().searchAPIRequest(location: CLLocation.init(latitude: location.latitude, longitude: location.longitude), locationId: locationId)
|
|
326
326
|
}
|
|
327
327
|
// TODO: Missing implementation
|
|
328
328
|
// /// Get distnce between location point and origin
|
|
@@ -335,7 +335,7 @@ import WoosmapGeofencing
|
|
|
335
335
|
// let lngDest = coordinatesDest.coordinate.longitude
|
|
336
336
|
// let originLocation = CLLocation.init(latitude: locationOrigin.latitude,
|
|
337
337
|
// longitude: locationOrigin.longitude)
|
|
338
|
-
//
|
|
338
|
+
// WoosmapGeofenceManager.shared.getLocationService().distanceAPIRequest(locationOrigin: originLocation,
|
|
339
339
|
// coordinatesDest: [(latDest, lngDest)],
|
|
340
340
|
// locationId: locationId)
|
|
341
341
|
// }
|
|
@@ -350,7 +350,7 @@ import WoosmapGeofencing
|
|
|
350
350
|
// let lngDest = poi.longitude
|
|
351
351
|
// let originLocation = CLLocation.init(latitude: locationOrigin.latitude,
|
|
352
352
|
// longitude: locationOrigin.longitude)
|
|
353
|
-
//
|
|
353
|
+
// WoosmapGeofenceManager.shared.getLocationService().distanceAPIRequest(locationOrigin: originLocation,
|
|
354
354
|
// coordinatesDest: [(latDest, lngDest)],
|
|
355
355
|
// locationId: locationId)
|
|
356
356
|
// }
|
|
@@ -396,28 +396,26 @@ import WoosmapGeofencing
|
|
|
396
396
|
var regions = DataRegion().readRegions()
|
|
397
397
|
let IsochroneRegion = DataRegion().readIsochroneRegions()
|
|
398
398
|
IsochroneRegion.forEach { item in
|
|
399
|
-
let customRegion = Region()
|
|
400
|
-
customRegion.identifier = item.identifier ?? "-"
|
|
401
|
-
customRegion.latitude = item.latitude
|
|
402
|
-
customRegion.longitude = item.longitude
|
|
403
|
-
customRegion.radius = Double(item.radius)
|
|
399
|
+
let customRegion = Region(latitude: item.latitude, longitude: item.latitude, radius: Double(item.radius), dateCaptured: Date(), identifier: item.identifier ?? "-", didEnter: false, fromPositionDetection: false, eventName: "")
|
|
404
400
|
customRegion.type = item.type
|
|
405
401
|
regions.append(customRegion)
|
|
406
402
|
}
|
|
407
403
|
|
|
408
|
-
if let locationService =
|
|
404
|
+
if let locationService = WoosmapGeofenceManager.shared.locationService{
|
|
409
405
|
if let customRegion = locationService.locationManager?.monitoredRegions{
|
|
410
406
|
customRegion.forEach { item in
|
|
411
407
|
if(locationService.getRegionType(identifier: item.identifier) == RegionType.custom){
|
|
412
|
-
|
|
413
|
-
|
|
408
|
+
|
|
409
|
+
let customRegionItem = Region(latitude: 0, longitude: 0, radius: 0, dateCaptured: Date(), identifier: item.identifier , didEnter: false, fromPositionDetection: false, eventName: "")
|
|
410
|
+
|
|
411
|
+
customRegionItem.identifier = item.identifier
|
|
414
412
|
if let circleRegion = item as? CLCircularRegion{
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
413
|
+
customRegionItem.latitude = circleRegion.center.latitude
|
|
414
|
+
customRegionItem.longitude = circleRegion.center.longitude
|
|
415
|
+
customRegionItem.radius = circleRegion.radius
|
|
416
|
+
customRegionItem.type = "circle"
|
|
419
417
|
}
|
|
420
|
-
regions.append(
|
|
418
|
+
regions.append(customRegionItem)
|
|
421
419
|
}
|
|
422
420
|
}
|
|
423
421
|
}
|
|
@@ -430,14 +428,15 @@ import WoosmapGeofencing
|
|
|
430
428
|
/// - Parameter id: region id
|
|
431
429
|
/// - Returns: Region
|
|
432
430
|
public func getRegions(id:String) -> Region? {
|
|
433
|
-
if let locationService =
|
|
431
|
+
if let locationService = WoosmapGeofenceManager.shared.locationService{
|
|
434
432
|
let regiontype = locationService.getRegionType(identifier: id)
|
|
435
433
|
if( regiontype == RegionType.custom){
|
|
436
434
|
if let customRegions = locationService.locationManager?.monitoredRegions{
|
|
437
435
|
if let watchRegion = customRegions.first(where: { item in
|
|
438
436
|
return item.identifier == id
|
|
439
437
|
}){
|
|
440
|
-
let customRegion = Region()
|
|
438
|
+
let customRegion = Region(latitude: 0, longitude: 0, radius: 0, dateCaptured: Date(), identifier: "-", didEnter: false, fromPositionDetection: false, eventName: "")
|
|
439
|
+
|
|
441
440
|
customRegion.identifier = watchRegion.identifier
|
|
442
441
|
if let circleRegion = watchRegion as? CLCircularRegion{
|
|
443
442
|
customRegion.latitude = circleRegion.center.latitude
|
|
@@ -456,7 +455,7 @@ import WoosmapGeofencing
|
|
|
456
455
|
}
|
|
457
456
|
if let regions = DataRegion().readIsochroneRegions(id: id){
|
|
458
457
|
|
|
459
|
-
let customRegion = Region()
|
|
458
|
+
let customRegion = Region(latitude: 0, longitude: 0, radius: 0, dateCaptured: Date(), identifier: "-", didEnter: false, fromPositionDetection: false, eventName: "")
|
|
460
459
|
customRegion.identifier = regions.identifier ?? "-"
|
|
461
460
|
customRegion.latitude = regions.latitude
|
|
462
461
|
customRegion.longitude = regions.longitude
|
|
@@ -498,12 +497,12 @@ import WoosmapGeofencing
|
|
|
498
497
|
|
|
499
498
|
/// Delete all ZOI regions
|
|
500
499
|
public func deleteAllZoiRegion() {
|
|
501
|
-
|
|
500
|
+
WoosmapGeofenceManager.shared.locationService.removeRegions(type: RegionType.custom)
|
|
502
501
|
}
|
|
503
502
|
|
|
504
503
|
/// Delete all POI regions
|
|
505
504
|
public func deleteAllPoiRegion() {
|
|
506
|
-
|
|
505
|
+
WoosmapGeofenceManager.shared.locationService.removeRegions(type: RegionType.poi)
|
|
507
506
|
}
|
|
508
507
|
|
|
509
508
|
/// Delete regions by id
|
|
@@ -512,7 +511,7 @@ import WoosmapGeofencing
|
|
|
512
511
|
public func deleteRegions(id:String) throws {
|
|
513
512
|
if isRegionIDExist(id: id){
|
|
514
513
|
DataRegion().eraseRegions(id: id)
|
|
515
|
-
|
|
514
|
+
WoosmapGeofenceManager.shared.locationService.removeRegion(identifier: id)
|
|
516
515
|
}
|
|
517
516
|
else{
|
|
518
517
|
throw WoosGeofenceError(WoosmapGeofenceMessage.regionid_notexist )
|
|
@@ -523,7 +522,7 @@ import WoosmapGeofencing
|
|
|
523
522
|
/// Delete all regions
|
|
524
523
|
public func deleteAllRegion() {
|
|
525
524
|
DataRegion().eraseRegions()
|
|
526
|
-
|
|
525
|
+
WoosmapGeofenceManager.shared.locationService.removeRegions(type: RegionType.none)
|
|
527
526
|
}
|
|
528
527
|
|
|
529
528
|
@objc static public func mockdata() {
|
|
@@ -559,7 +558,7 @@ import WoosmapGeofencing
|
|
|
559
558
|
throw WoosGeofenceError(WoosmapGeofenceMessage.required_contactKey)
|
|
560
559
|
}
|
|
561
560
|
if requiredSatisfied {
|
|
562
|
-
|
|
561
|
+
WoosmapGeofenceManager.shared.setSFMCCredentials(credentials: credentials)
|
|
563
562
|
}
|
|
564
563
|
}
|
|
565
564
|
|
|
@@ -567,7 +566,7 @@ import WoosmapGeofencing
|
|
|
567
566
|
/// - Parameter radius: integer or string for radius value
|
|
568
567
|
public func setPoiRadius(radius: String) {
|
|
569
568
|
self.defaultPOIRadius = radius
|
|
570
|
-
|
|
569
|
+
WoosmapGeofenceManager.shared.setPoiRadius(radius: formatedRadius(radius: radius))
|
|
571
570
|
}
|
|
572
571
|
|
|
573
572
|
/// Format String value to proper datatype
|
|
@@ -598,7 +597,7 @@ import WoosmapGeofencing
|
|
|
598
597
|
if(mode == "local"){
|
|
599
598
|
let bundle = Bundle.main //Bundle(for: Self.self)
|
|
600
599
|
if let url = bundle.url(forResource: source, withExtension: nil){
|
|
601
|
-
let (status,errors) =
|
|
600
|
+
let (status,errors) = WoosmapGeofenceManager.shared.startCustomTracking(url: url.absoluteString)
|
|
602
601
|
|
|
603
602
|
if(status == false){
|
|
604
603
|
completion(false,WoosGeofenceError(errors[0]))
|
|
@@ -612,7 +611,7 @@ import WoosmapGeofencing
|
|
|
612
611
|
}
|
|
613
612
|
}
|
|
614
613
|
else if(mode == "external"){
|
|
615
|
-
let (status,errors) =
|
|
614
|
+
let (status,errors) = WoosmapGeofenceManager.shared.startCustomTracking(url: source)
|
|
616
615
|
if(status == false){
|
|
617
616
|
completion(false,WoosGeofenceError(errors[0]))
|
|
618
617
|
}
|
|
@@ -632,7 +631,7 @@ import WoosmapGeofencing
|
|
|
632
631
|
if(mode == "local"){
|
|
633
632
|
let bundle = Bundle.main //Bundle(for: Self.self)
|
|
634
633
|
if let url = bundle.url(forResource: source, withExtension: nil){
|
|
635
|
-
let (status,errors) =
|
|
634
|
+
let (status,errors) = WoosmapGeofenceManager.shared.startCustomTracking(url: url.absoluteString)
|
|
636
635
|
if(status == false){
|
|
637
636
|
throw WoosGeofenceError(errors[0])
|
|
638
637
|
}
|
|
@@ -642,7 +641,7 @@ import WoosmapGeofencing
|
|
|
642
641
|
}
|
|
643
642
|
}
|
|
644
643
|
else if(mode == "external"){
|
|
645
|
-
let (status,errors) =
|
|
644
|
+
let (status,errors) = WoosmapGeofenceManager.shared.startCustomTracking(url: source)
|
|
646
645
|
if(status == false){
|
|
647
646
|
throw WoosGeofenceError(errors[0])
|
|
648
647
|
}
|
package/lib/commonjs/index.js
CHANGED
|
@@ -68,6 +68,21 @@ function requestPermissions(background) {
|
|
|
68
68
|
return _nativeInterface.default.requestPermissions([background]);
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
+
/**
|
|
72
|
+
* 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
|
+
* The plugin will return an object with either one of the messages - BACKGROUND_LOCATION_DENIED, GRANTED, DENIED
|
|
75
|
+
*/
|
|
76
|
+
function requestBLEPermissions() {
|
|
77
|
+
if (_reactNative.Platform.OS == 'android') {
|
|
78
|
+
return _nativeInterface.default.requestBLEPermissions();
|
|
79
|
+
} else {
|
|
80
|
+
return new Promise(resolve => {
|
|
81
|
+
resolve("GRANTED");
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
71
86
|
/**
|
|
72
87
|
* A method to check if the app has granted required permissions to track location.
|
|
73
88
|
* @returns A callback that will be called with the following status - GRANTED_BACKGROUND, GRANTED_FOREGROUND, DENIED
|
|
@@ -76,6 +91,20 @@ function getPermissionsStatus() {
|
|
|
76
91
|
return _nativeInterface.default.getPermissionsStatus();
|
|
77
92
|
}
|
|
78
93
|
|
|
94
|
+
/**
|
|
95
|
+
* A method to check if the app has granted required permissions to track location.
|
|
96
|
+
* @returns A callback that will be called with the following status - BACKGROUND_LOCATION_DENIED, GRANTED, DENIED
|
|
97
|
+
*/
|
|
98
|
+
function getBLEPermissionsStatus() {
|
|
99
|
+
if (_reactNative.Platform.OS == 'android') {
|
|
100
|
+
return _nativeInterface.default.getBLEPermissionsStatus();
|
|
101
|
+
} else {
|
|
102
|
+
return new Promise(resolve => {
|
|
103
|
+
resolve("GRANTED");
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
79
108
|
/**
|
|
80
109
|
* Method will
|
|
81
110
|
invoke callback and pass a location object as a parameter. Method will return a watchId . This id can be used to remove a callback.
|
|
@@ -311,7 +340,9 @@ const WoosmapGeofencing = {
|
|
|
311
340
|
setWoosmapApiKey,
|
|
312
341
|
startTracking,
|
|
313
342
|
requestPermissions,
|
|
343
|
+
requestBLEPermissions,
|
|
314
344
|
getPermissionsStatus,
|
|
345
|
+
getBLEPermissionsStatus,
|
|
315
346
|
stopTracking,
|
|
316
347
|
watchLocation,
|
|
317
348
|
clearLocationWatch,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNative","require","_reactNativeUuid","_interopRequireDefault","_nativeInterface","_Location","_Region","_Poi","obj","__esModule","default","eventEmitter","NativeEventEmitter","PluginGeofencing","subscriptionsLocation","subscriptionsRegion","initialize","arg0","setWoosmapApiKey","apiKey","startTracking","trackingProfile","stopTracking","requestPermissions","background","getPermissionsStatus","watchLocation","success","error","watchID","uuid","v1","toString","successCallback","result","Location","jsonToObj","addListener","clearLocationWatch","removeAllListeners","clearAllLocationWatch","saved","removeListener","arg1","undefined","watchRegions","Region","clearRegionsWatch","clearAllRegionsWatch","setSFMCCredentials","setPoiRadius","radius","addRegion","region","getRegions","regionID","getAllRegions","then","formatted","forEach","item","push","Promise","resolve","catch","e","reject","getLocations","locationID","getAllLocations","getLocation","getPois","poiID","getAllPois","Poi","getPoi","removeRegions","removeAllRegions","removeRegion","removeLocations","removeAllLocations","removePois","removeAllPois","startCustomTracking","sourceType","source","WoosmapGeofencing","_default","exports"],"sources":["index.tsx"],"sourcesContent":["import { NativeEventEmitter } from 'react-native';\nimport uuid from 'react-native-uuid';\nimport PluginGeofencing from './internal/nativeInterface';\nimport Location from './internal/Location';\nimport Region from './internal/Region';\nimport Poi from './internal/Poi';\nimport type {\n GeofenceRegion,\n RegionType,\n ProfileSource,\n} from './internal/types';\n\nconst eventEmitter = new NativeEventEmitter(PluginGeofencing);\n\nlet subscriptionsLocation: any = {};\nlet subscriptionsRegion: any = {};\n/**\n * Initializes the Woosmap object\n * @param arg0 A JSON object with Woosmap Key (optional) and tracking profile (`liveTracking`,`passiveTracking`,`visitsTracking`).\n * @returns promise:success - A callback function that will be called on success.\n error - A callback function that will be called on error.\n */\nfunction initialize(arg0?: any): Promise<string> {\n if (arg0 == null) {\n arg0 = {};\n }\n return PluginGeofencing.initialize(arg0);\n}\n\n/**\n * A method that sets Woosmap private API key\n * @param apiKey new API key.\n * @returns promise:success - A callback function that will be called on success.\n error - A callback function that will be called on error.\n */\nfunction setWoosmapApiKey(apiKey: string): Promise<string> {\n return PluginGeofencing.setWoosmapApiKey([apiKey]);\n}\n\n/**\n * A method to start tracking the user's location.\n * @param trackingProfile The configuration profile to use. Values could be anyone of the following: liveTracking, passiveTracking and visitsTracking.\n * @returns promise:success - A callback function that will be called on success.\n error - A callback function that will be called on error.\n */\nfunction startTracking(trackingProfile: string): Promise<string> {\n return PluginGeofencing.startTracking([trackingProfile]);\n}\n\n/**\n * Stops tracking the user's location.\n * @returns promise:success - A callback function that will be called on success.\n error - A callback function that will be called on error.\n */\nfunction stopTracking(): Promise<string> {\n return PluginGeofencing.stopTracking();\n}\n\n/**\n * A method to request the required permissions to collect locations.\n * @param background - A boolean value indicating whether the permissions to request is for background or foreground permission.\n * @returns A callback that will be called on successful authorization by the app. A callback that will be called when the app denies permission. The plugin will return an object with a message - 'Permission Denied'.\n */\nfunction requestPermissions(background?: boolean): Promise<string> {\n if (background == null) {\n background = false;\n }\n return PluginGeofencing.requestPermissions([background]);\n}\n\n/**\n * A method to check if the app has granted required permissions to track location.\n * @returns A callback that will be called with the following status - GRANTED_BACKGROUND, GRANTED_FOREGROUND, DENIED\n */\nfunction getPermissionsStatus(): Promise<string> {\n return PluginGeofencing.getPermissionsStatus();\n}\n\n/**\n * Method will\ninvoke callback and pass a location object as a parameter. Method will return a watchId . This id can be used to remove a callback.\n * @param success new location found callback\n * @param error error status callback\n * @returns watchid\n */\nfunction watchLocation(\n success: (result: Location) => any,\n error?: any\n): Promise<string> {\n const watchID = uuid.v1().toString();\n\n const successCallback = (result: any) => {\n success(Location.jsonToObj(result));\n };\n\n subscriptionsLocation[watchID] = [\n eventEmitter.addListener('geolocationDidChange', successCallback),\n error ? eventEmitter.addListener('geolocationError', error) : null,\n ];\n return PluginGeofencing.watchLocation(watchID);\n}\n\n/**\n * A method to stop tracking location for a specified watch. If watchId is null or undefined the plugin will clear all watches.\n * @param watchID Reference ID.\n * @returns return promise with same id back in case of success otherwise error info\n */\nfunction clearLocationWatch(watchID?: string): Promise<string> {\n if (watchID == null) {\n eventEmitter.removeAllListeners('geolocationDidChange');\n eventEmitter.removeAllListeners('geolocationError');\n subscriptionsLocation = {};\n return PluginGeofencing.clearAllLocationWatch();\n } else {\n const saved = subscriptionsLocation[watchID];\n if (saved) {\n const arg0 = saved[0];\n eventEmitter.removeListener('geolocationDidChange', arg0);\n const arg1 = saved[1];\n if (arg1) {\n eventEmitter.removeListener('geolocationError', arg1);\n }\n subscriptionsLocation[watchID] = undefined;\n }\n return PluginGeofencing.clearLocationWatch(watchID);\n }\n}\n\n/**\n * A method to to track Regions. Method will invoke a callback with Region object. Method will return\na watch id which can be used later to remove the callback.\n * @param success new location found callback\n * @param error error status callback\n * @returns watchid\n */\nfunction watchRegions(\n success: (result: Region) => any,\n error?: any\n): Promise<string> {\n const watchID = uuid.v1().toString();\n\n const successCallback = (result: any) => {\n success(Region.jsonToObj(result));\n };\n\n subscriptionsRegion[watchID] = [\n eventEmitter.addListener('woosmapgeofenceRegionDidChange', successCallback),\n error\n ? eventEmitter.addListener('woosmapgeofenceRegionError', error)\n : null,\n ];\n return PluginGeofencing.watchRegions(watchID);\n}\n\n/**\n * A method to clear the specified watch tracing the regions. If the watchId is null or undefined then it will clear all the watches tracking the regions.\n * @param watchID Reference ID.\n * @returns return promise with same id back in case of success otherwise error info\n */\nfunction clearRegionsWatch(watchID: string): Promise<string> {\n if (watchID == null) {\n eventEmitter.removeAllListeners('woosmapgeofenceRegionDidChange');\n eventEmitter.removeAllListeners('woosmapgeofenceRegionError');\n subscriptionsRegion = {};\n return PluginGeofencing.clearAllRegionsWatch();\n } else {\n const saved = subscriptionsRegion[watchID];\n if (saved) {\n const arg0 = saved[0];\n eventEmitter.removeListener('woosmapgeofenceRegionDidChange', arg0);\n const arg1 = saved[1];\n if (arg1) {\n eventEmitter.removeListener('woosmapgeofenceRegionError', arg1);\n }\n subscriptionsRegion[watchID] = undefined;\n }\n return PluginGeofencing.clearRegionsWatch(watchID);\n }\n}\n/**\n * Sets Sales Force Marketing Cloud (SFMC) credentials\n * @param arg0 A JSON object with SFMC credentials. Keys authenticationBaseURI, restBaseURI, client_id, client_secret and contactKey are required.\n * @returns promise with A callback that will be called on success or error.\n */\nfunction setSFMCCredentials(arg0: Object): Promise<string> {\n return PluginGeofencing.setSFMCCredentials(arg0);\n}\n\n/**\n * When you create a geofence around a POI, manually define the radius value (100.0) or choose the user_properties subfield that corresponds to radius value of the geofence (\"radiusPOI\").\n * @param radius can be integer or string.\n * @returns promise with A callback that will be called on success or error.\n */\nfunction setPoiRadius(radius: string): Promise<string> {\n return PluginGeofencing.setPoiRadius(radius);\n}\n/**\n * Adds a custom region that you want to monitor.\n * @param region A GeofenceRegion object with latitude, longitude, radius and type.\n * @returns promise with A callback that will be called on success or error.\n */\n\nfunction addRegion(region: GeofenceRegion): Promise<string> {\n return PluginGeofencing.addRegion(region);\n}\n/**\n * Retrieve saved region info\n * @param regionID If it pass return info for given region or return all region info\n * @returns promise with A callback that will be called on success or error.\n */\nfunction getRegions(regionID?: string): Promise<Region[]> {\n if (regionID == null) {\n return PluginGeofencing.getAllRegions()\n .then((result: any[]) => {\n var formatted: Region[] = [];\n result.forEach((item) => {\n formatted.push(Region.jsonToObj(item));\n });\n return Promise.resolve(formatted);\n })\n .catch((e: any) => {\n return Promise.reject(e);\n });\n } else {\n return PluginGeofencing.getRegions(regionID)\n .then((result: any) => {\n var formatted: Region[] = [];\n formatted.push(Region.jsonToObj(result));\n return Promise.resolve(formatted);\n })\n .catch((e: any) => {\n return Promise.reject(e);\n });\n }\n}\n\n/**\n * Retrieve saved location info\n * @param locationID - Optional in case of location id pass it return only that location info\n * @returns promise with A callback that will be called on success or error.\n */\nfunction getLocations(locationID?: string): Promise<Location[]> {\n if (locationID == null) {\n return PluginGeofencing.getAllLocations()\n .then((result: any[]) => {\n var formatted: Location[] = [];\n result.forEach((item) => {\n formatted.push(Location.jsonToObj(item));\n });\n return Promise.resolve(formatted);\n })\n .catch((e: any) => {\n return Promise.reject(e);\n });\n } else {\n return PluginGeofencing.getLocation(locationID)\n .then((result: any) => {\n var formatted: Location[] = [];\n formatted.push(Location.jsonToObj(result));\n return Promise.resolve(formatted);\n })\n .catch((e: any) => {\n return Promise.reject(e);\n });\n }\n}\n\n/**\n * Retrieve saved POI info\n * @param poiID - Optional in case of poi id (LocationID or StoreID) pass it return only that POI info\n * @returns promise with A callback that will be called on success or error.\n */\nfunction getPois(poiID?: string): Promise<Poi[]> {\n if (poiID == null) {\n return PluginGeofencing.getAllPois()\n .then((result: any[]) => {\n var formatted: Poi[] = [];\n result.forEach((item) => {\n formatted.push(Poi.jsonToObj(item));\n });\n return Promise.resolve(formatted);\n })\n .catch((e: any) => {\n return Promise.reject(e);\n });\n } else {\n return PluginGeofencing.getPoi(poiID)\n .then((result: any) => {\n var formatted: Poi[] = [];\n formatted.push(Poi.jsonToObj(result));\n return Promise.resolve(formatted);\n })\n .catch((e: any) => {\n return Promise.reject(e);\n });\n }\n}\n\n/**\n * Remove saved region info\n * @param regionID If it pass remove info for given region or removes all region info\n * @returns promise with A callback that will be called on success or error.\n */\nfunction removeRegions(regionID?: string): Promise<string> {\n if (regionID == null) {\n return PluginGeofencing.removeAllRegions();\n } else {\n return PluginGeofencing.removeRegion(regionID);\n }\n}\n\n/**\n * Remove saved location info\n * @returns promise with A callback that will be called on success or error.\n */\nfunction removeLocations(): Promise<string> {\n return PluginGeofencing.removeAllLocations();\n}\n\n/**\n * Remove saved POI info\n * @returns promise with A callback that will be called on success or error.\n */\nfunction removePois(): Promise<string> {\n return PluginGeofencing.removeAllPois();\n}\n/**\n * if preset tracking profiles don’t fit with your use cases, you can build your own profile and uses the startCustomTracking() method. \n * There are two way to host the json file:\n * - included in the client application (local)\n * - hosted externally in a file folder in your information system (external)\n * @param sourceType local/external\n * @param source location of profile to be fetch\n * @returns promise with A callback that will be called on success or error.\n */\nfunction startCustomTracking(\n sourceType: ProfileSource,\n source: string\n): Promise<string> {\n return PluginGeofencing.startCustomTracking(sourceType, source);\n}\n\nexport type {\n RegionType,\n GeofenceRegion,\n Region,\n Location,\n Poi,\n ProfileSource,\n};\n\nconst WoosmapGeofencing = {\n initialize,\n setWoosmapApiKey,\n startTracking,\n requestPermissions,\n getPermissionsStatus,\n stopTracking,\n watchLocation,\n clearLocationWatch,\n watchRegions,\n clearRegionsWatch,\n setSFMCCredentials,\n setPoiRadius,\n addRegion,\n getRegions,\n removeRegions,\n getLocations,\n removeLocations,\n getPois,\n removePois,\n startCustomTracking,\n};\n\nexport default WoosmapGeofencing;\n"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,gBAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,gBAAA,GAAAD,sBAAA,CAAAF,OAAA;AACA,IAAAI,SAAA,GAAAF,sBAAA,CAAAF,OAAA;AACA,IAAAK,OAAA,GAAAH,sBAAA,CAAAF,OAAA;AACA,IAAAM,IAAA,GAAAJ,sBAAA,CAAAF,OAAA;AAAiC,SAAAE,uBAAAK,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAOjC,MAAMG,YAAY,GAAG,IAAIC,+BAAkB,CAACC,wBAAgB,CAAC;AAE7D,IAAIC,qBAA0B,GAAG,CAAC,CAAC;AACnC,IAAIC,mBAAwB,GAAG,CAAC,CAAC;AACjC;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,UAAUA,CAACC,IAAU,EAAmB;EAC/C,IAAIA,IAAI,IAAI,IAAI,EAAE;IAChBA,IAAI,GAAG,CAAC,CAAC;EACX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AS;EACTE,UAAU;EACVsB,aAAa;EACbT,YAAY;EACZY,eAAe;EACfR,OAAO;EACPU,UAAU;EACVE;AACF,CAAC;AAAC,IAAAI,QAAA,GAEaD,iBAAiB;AAAAE,OAAA,CAAA9E,OAAA,GAAA6E,QAAA"}
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_reactNativeUuid","_interopRequireDefault","_nativeInterface","_Location","_Region","_Poi","obj","__esModule","default","eventEmitter","NativeEventEmitter","PluginGeofencing","subscriptionsLocation","subscriptionsRegion","initialize","arg0","setWoosmapApiKey","apiKey","startTracking","trackingProfile","stopTracking","requestPermissions","background","requestBLEPermissions","Platform","OS","Promise","resolve","getPermissionsStatus","getBLEPermissionsStatus","watchLocation","success","error","watchID","uuid","v1","toString","successCallback","result","Location","jsonToObj","addListener","clearLocationWatch","removeAllListeners","clearAllLocationWatch","saved","removeListener","arg1","undefined","watchRegions","Region","clearRegionsWatch","clearAllRegionsWatch","setSFMCCredentials","setPoiRadius","radius","addRegion","region","getRegions","regionID","getAllRegions","then","formatted","forEach","item","push","catch","e","reject","getLocations","locationID","getAllLocations","getLocation","getPois","poiID","getAllPois","Poi","getPoi","removeRegions","removeAllRegions","removeRegion","removeLocations","removeAllLocations","removePois","removeAllPois","startCustomTracking","sourceType","source","WoosmapGeofencing","_default","exports"],"sources":["index.tsx"],"sourcesContent":["import { NativeEventEmitter, Platform } from 'react-native';\nimport uuid from 'react-native-uuid';\nimport PluginGeofencing from './internal/nativeInterface';\nimport Location from './internal/Location';\nimport Region from './internal/Region';\nimport Poi from './internal/Poi';\nimport type {\n GeofenceRegion,\n RegionType,\n ProfileSource,\n} from './internal/types';\n\nconst eventEmitter = new NativeEventEmitter(PluginGeofencing);\n\nlet subscriptionsLocation: any = {};\nlet subscriptionsRegion: any = {};\n/**\n * Initializes the Woosmap object\n * @param arg0 A JSON object with Woosmap Key (optional) and tracking profile (`liveTracking`,`passiveTracking`,`visitsTracking`).\n * @returns promise:success - A callback function that will be called on success.\n error - A callback function that will be called on error.\n */\nfunction initialize(arg0?: any): Promise<string> {\n if (arg0 == null) {\n arg0 = {};\n }\n return PluginGeofencing.initialize(arg0);\n}\n\n/**\n * A method that sets Woosmap private API key\n * @param apiKey new API key.\n * @returns promise:success - A callback function that will be called on success.\n error - A callback function that will be called on error.\n */\nfunction setWoosmapApiKey(apiKey: string): Promise<string> {\n return PluginGeofencing.setWoosmapApiKey([apiKey]);\n}\n\n/**\n * A method to start tracking the user's location.\n * @param trackingProfile The configuration profile to use. Values could be anyone of the following: liveTracking, passiveTracking and visitsTracking.\n * @returns promise:success - A callback function that will be called on success.\n error - A callback function that will be called on error.\n */\nfunction startTracking(trackingProfile: string): Promise<string> {\n return PluginGeofencing.startTracking([trackingProfile]);\n}\n\n/**\n * Stops tracking the user's location.\n * @returns promise:success - A callback function that will be called on success.\n error - A callback function that will be called on error.\n */\nfunction stopTracking(): Promise<string> {\n return PluginGeofencing.stopTracking();\n}\n\n/**\n * A method to request the required permissions to collect locations.\n * @param background - A boolean value indicating whether the permissions to request is for background or foreground permission.\n * @returns A callback that will be called on successful authorization by the app. A callback that will be called when the app denies permission. The plugin will return an object with a message - 'Permission Denied'.\n */\nfunction requestPermissions(background?: boolean): Promise<string> {\n if (background == null) {\n background = false;\n }\n return PluginGeofencing.requestPermissions([background]);\n}\n\n/**\n * A method to request the required permissions to collect locations.\n * @returns A callback that will be called on successful authorization by the app. A callback that will be called when the app denies permission. \n * The plugin will return an object with either one of the messages - BACKGROUND_LOCATION_DENIED, GRANTED, DENIED\n */\nfunction requestBLEPermissions(): Promise<string> {\n if (Platform.OS == 'android'){\n return PluginGeofencing.requestBLEPermissions();\n }\n else{\n return new Promise((resolve) => {\n resolve(\"GRANTED\");\n });\n }\n}\n\n/**\n * A method to check if the app has granted required permissions to track location.\n * @returns A callback that will be called with the following status - GRANTED_BACKGROUND, GRANTED_FOREGROUND, DENIED\n */\nfunction getPermissionsStatus(): Promise<string> {\n return PluginGeofencing.getPermissionsStatus();\n}\n\n/**\n * A method to check if the app has granted required permissions to track location.\n * @returns A callback that will be called with the following status - BACKGROUND_LOCATION_DENIED, GRANTED, DENIED\n */\nfunction getBLEPermissionsStatus(): Promise<string> {\n if (Platform.OS == 'android'){\n return PluginGeofencing.getBLEPermissionsStatus();\n }\n else{\n return new Promise((resolve) => {\n resolve(\"GRANTED\");\n });\n }\n}\n\n/**\n * Method will\ninvoke callback and pass a location object as a parameter. Method will return a watchId . This id can be used to remove a callback.\n * @param success new location found callback\n * @param error error status callback\n * @returns watchid\n */\nfunction watchLocation(\n success: (result: Location) => any,\n error?: any\n): Promise<string> {\n const watchID = uuid.v1().toString();\n\n const successCallback = (result: any) => {\n success(Location.jsonToObj(result));\n };\n\n subscriptionsLocation[watchID] = [\n eventEmitter.addListener('geolocationDidChange', successCallback),\n error ? eventEmitter.addListener('geolocationError', error) : null,\n ];\n return PluginGeofencing.watchLocation(watchID);\n}\n\n/**\n * A method to stop tracking location for a specified watch. If watchId is null or undefined the plugin will clear all watches.\n * @param watchID Reference ID.\n * @returns return promise with same id back in case of success otherwise error info\n */\nfunction clearLocationWatch(watchID?: string): Promise<string> {\n if (watchID == null) {\n eventEmitter.removeAllListeners('geolocationDidChange');\n eventEmitter.removeAllListeners('geolocationError');\n subscriptionsLocation = {};\n return PluginGeofencing.clearAllLocationWatch();\n } else {\n const saved = subscriptionsLocation[watchID];\n if (saved) {\n const arg0 = saved[0];\n eventEmitter.removeListener('geolocationDidChange', arg0);\n const arg1 = saved[1];\n if (arg1) {\n eventEmitter.removeListener('geolocationError', arg1);\n }\n subscriptionsLocation[watchID] = undefined;\n }\n return PluginGeofencing.clearLocationWatch(watchID);\n }\n}\n\n/**\n * A method to to track Regions. Method will invoke a callback with Region object. Method will return\na watch id which can be used later to remove the callback.\n * @param success new location found callback\n * @param error error status callback\n * @returns watchid\n */\nfunction watchRegions(\n success: (result: Region) => any,\n error?: any\n): Promise<string> {\n const watchID = uuid.v1().toString();\n\n const successCallback = (result: any) => {\n success(Region.jsonToObj(result));\n };\n\n subscriptionsRegion[watchID] = [\n eventEmitter.addListener('woosmapgeofenceRegionDidChange', successCallback),\n error\n ? eventEmitter.addListener('woosmapgeofenceRegionError', error)\n : null,\n ];\n return PluginGeofencing.watchRegions(watchID);\n}\n\n/**\n * A method to clear the specified watch tracing the regions. If the watchId is null or undefined then it will clear all the watches tracking the regions.\n * @param watchID Reference ID.\n * @returns return promise with same id back in case of success otherwise error info\n */\nfunction clearRegionsWatch(watchID: string): Promise<string> {\n if (watchID == null) {\n eventEmitter.removeAllListeners('woosmapgeofenceRegionDidChange');\n eventEmitter.removeAllListeners('woosmapgeofenceRegionError');\n subscriptionsRegion = {};\n return PluginGeofencing.clearAllRegionsWatch();\n } else {\n const saved = subscriptionsRegion[watchID];\n if (saved) {\n const arg0 = saved[0];\n eventEmitter.removeListener('woosmapgeofenceRegionDidChange', arg0);\n const arg1 = saved[1];\n if (arg1) {\n eventEmitter.removeListener('woosmapgeofenceRegionError', arg1);\n }\n subscriptionsRegion[watchID] = undefined;\n }\n return PluginGeofencing.clearRegionsWatch(watchID);\n }\n}\n/**\n * Sets Sales Force Marketing Cloud (SFMC) credentials\n * @param arg0 A JSON object with SFMC credentials. Keys authenticationBaseURI, restBaseURI, client_id, client_secret and contactKey are required.\n * @returns promise with A callback that will be called on success or error.\n */\nfunction setSFMCCredentials(arg0: Object): Promise<string> {\n return PluginGeofencing.setSFMCCredentials(arg0);\n}\n\n/**\n * When you create a geofence around a POI, manually define the radius value (100.0) or choose the user_properties subfield that corresponds to radius value of the geofence (\"radiusPOI\").\n * @param radius can be integer or string.\n * @returns promise with A callback that will be called on success or error.\n */\nfunction setPoiRadius(radius: string): Promise<string> {\n return PluginGeofencing.setPoiRadius(radius);\n}\n/**\n * Adds a custom region that you want to monitor.\n * @param region A GeofenceRegion object with latitude, longitude, radius and type.\n * @returns promise with A callback that will be called on success or error.\n */\n\nfunction addRegion(region: GeofenceRegion): Promise<string> {\n return PluginGeofencing.addRegion(region);\n}\n/**\n * Retrieve saved region info\n * @param regionID If it pass return info for given region or return all region info\n * @returns promise with A callback that will be called on success or error.\n */\nfunction getRegions(regionID?: string): Promise<Region[]> {\n if (regionID == null) {\n return PluginGeofencing.getAllRegions()\n .then((result: any[]) => {\n var formatted: Region[] = [];\n result.forEach((item) => {\n formatted.push(Region.jsonToObj(item));\n });\n return Promise.resolve(formatted);\n })\n .catch((e: any) => {\n return Promise.reject(e);\n });\n } else {\n return PluginGeofencing.getRegions(regionID)\n .then((result: any) => {\n var formatted: Region[] = [];\n formatted.push(Region.jsonToObj(result));\n return Promise.resolve(formatted);\n })\n .catch((e: any) => {\n return Promise.reject(e);\n });\n }\n}\n\n/**\n * Retrieve saved location info\n * @param locationID - Optional in case of location id pass it return only that location info\n * @returns promise with A callback that will be called on success or error.\n */\nfunction getLocations(locationID?: string): Promise<Location[]> {\n if (locationID == null) {\n return PluginGeofencing.getAllLocations()\n .then((result: any[]) => {\n var formatted: Location[] = [];\n result.forEach((item) => {\n formatted.push(Location.jsonToObj(item));\n });\n return Promise.resolve(formatted);\n })\n .catch((e: any) => {\n return Promise.reject(e);\n });\n } else {\n return PluginGeofencing.getLocation(locationID)\n .then((result: any) => {\n var formatted: Location[] = [];\n formatted.push(Location.jsonToObj(result));\n return Promise.resolve(formatted);\n })\n .catch((e: any) => {\n return Promise.reject(e);\n });\n }\n}\n\n/**\n * Retrieve saved POI info\n * @param poiID - Optional in case of poi id (LocationID or StoreID) pass it return only that POI info\n * @returns promise with A callback that will be called on success or error.\n */\nfunction getPois(poiID?: string): Promise<Poi[]> {\n if (poiID == null) {\n return PluginGeofencing.getAllPois()\n .then((result: any[]) => {\n var formatted: Poi[] = [];\n result.forEach((item) => {\n formatted.push(Poi.jsonToObj(item));\n });\n return Promise.resolve(formatted);\n })\n .catch((e: any) => {\n return Promise.reject(e);\n });\n } else {\n return PluginGeofencing.getPoi(poiID)\n .then((result: any) => {\n var formatted: Poi[] = [];\n formatted.push(Poi.jsonToObj(result));\n return Promise.resolve(formatted);\n })\n .catch((e: any) => {\n return Promise.reject(e);\n });\n }\n}\n\n/**\n * Remove saved region info\n * @param regionID If it pass remove info for given region or removes all region info\n * @returns promise with A callback that will be called on success or error.\n */\nfunction removeRegions(regionID?: string): Promise<string> {\n if (regionID == null) {\n return PluginGeofencing.removeAllRegions();\n } else {\n return PluginGeofencing.removeRegion(regionID);\n }\n}\n\n/**\n * Remove saved location info\n * @returns promise with A callback that will be called on success or error.\n */\nfunction removeLocations(): Promise<string> {\n return PluginGeofencing.removeAllLocations();\n}\n\n/**\n * Remove saved POI info\n * @returns promise with A callback that will be called on success or error.\n */\nfunction removePois(): Promise<string> {\n return PluginGeofencing.removeAllPois();\n}\n/**\n * if preset tracking profiles don’t fit with your use cases, you can build your own profile and uses the startCustomTracking() method. \n * There are two way to host the json file:\n * - included in the client application (local)\n * - hosted externally in a file folder in your information system (external)\n * @param sourceType local/external\n * @param source location of profile to be fetch\n * @returns promise with A callback that will be called on success or error.\n */\nfunction startCustomTracking(\n sourceType: ProfileSource,\n source: string\n): Promise<string> {\n return PluginGeofencing.startCustomTracking(sourceType, source);\n}\n\nexport type {\n RegionType,\n GeofenceRegion,\n Region,\n Location,\n Poi,\n ProfileSource,\n};\n\nconst WoosmapGeofencing = {\n initialize,\n setWoosmapApiKey,\n startTracking,\n requestPermissions,\n requestBLEPermissions,\n getPermissionsStatus,\n getBLEPermissionsStatus,\n stopTracking,\n watchLocation,\n clearLocationWatch,\n watchRegions,\n clearRegionsWatch,\n setSFMCCredentials,\n setPoiRadius,\n addRegion,\n getRegions,\n removeRegions,\n getLocations,\n removeLocations,\n getPois,\n removePois,\n startCustomTracking,\n};\n\nexport default WoosmapGeofencing;\n"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,gBAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,gBAAA,GAAAD,sBAAA,CAAAF,OAAA;AACA,IAAAI,SAAA,GAAAF,sBAAA,CAAA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AEaD,iBAAiB;AAAAE,OAAA,CAAAlF,OAAA,GAAAiF,QAAA"}
|
package/lib/module/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { NativeEventEmitter } from 'react-native';
|
|
1
|
+
import { NativeEventEmitter, Platform } from 'react-native';
|
|
2
2
|
import uuid from 'react-native-uuid';
|
|
3
3
|
import PluginGeofencing from './internal/nativeInterface';
|
|
4
4
|
import Location from './internal/Location';
|
|
@@ -61,6 +61,21 @@ function requestPermissions(background) {
|
|
|
61
61
|
return PluginGeofencing.requestPermissions([background]);
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
+
/**
|
|
65
|
+
* A method to request the required permissions to collect locations.
|
|
66
|
+
* @returns A callback that will be called on successful authorization by the app. A callback that will be called when the app denies permission.
|
|
67
|
+
* The plugin will return an object with either one of the messages - BACKGROUND_LOCATION_DENIED, GRANTED, DENIED
|
|
68
|
+
*/
|
|
69
|
+
function requestBLEPermissions() {
|
|
70
|
+
if (Platform.OS == 'android') {
|
|
71
|
+
return PluginGeofencing.requestBLEPermissions();
|
|
72
|
+
} else {
|
|
73
|
+
return new Promise(resolve => {
|
|
74
|
+
resolve("GRANTED");
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
64
79
|
/**
|
|
65
80
|
* A method to check if the app has granted required permissions to track location.
|
|
66
81
|
* @returns A callback that will be called with the following status - GRANTED_BACKGROUND, GRANTED_FOREGROUND, DENIED
|
|
@@ -69,6 +84,20 @@ function getPermissionsStatus() {
|
|
|
69
84
|
return PluginGeofencing.getPermissionsStatus();
|
|
70
85
|
}
|
|
71
86
|
|
|
87
|
+
/**
|
|
88
|
+
* A method to check if the app has granted required permissions to track location.
|
|
89
|
+
* @returns A callback that will be called with the following status - BACKGROUND_LOCATION_DENIED, GRANTED, DENIED
|
|
90
|
+
*/
|
|
91
|
+
function getBLEPermissionsStatus() {
|
|
92
|
+
if (Platform.OS == 'android') {
|
|
93
|
+
return PluginGeofencing.getBLEPermissionsStatus();
|
|
94
|
+
} else {
|
|
95
|
+
return new Promise(resolve => {
|
|
96
|
+
resolve("GRANTED");
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
72
101
|
/**
|
|
73
102
|
* Method will
|
|
74
103
|
invoke callback and pass a location object as a parameter. Method will return a watchId . This id can be used to remove a callback.
|
|
@@ -304,7 +333,9 @@ const WoosmapGeofencing = {
|
|
|
304
333
|
setWoosmapApiKey,
|
|
305
334
|
startTracking,
|
|
306
335
|
requestPermissions,
|
|
336
|
+
requestBLEPermissions,
|
|
307
337
|
getPermissionsStatus,
|
|
338
|
+
getBLEPermissionsStatus,
|
|
308
339
|
stopTracking,
|
|
309
340
|
watchLocation,
|
|
310
341
|
clearLocationWatch,
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["NativeEventEmitter","uuid","PluginGeofencing","Location","Region","Poi","eventEmitter","subscriptionsLocation","subscriptionsRegion","initialize","arg0","setWoosmapApiKey","apiKey","startTracking","trackingProfile","stopTracking","requestPermissions","background","getPermissionsStatus","watchLocation","success","error","watchID","v1","toString","successCallback","result","jsonToObj","addListener","clearLocationWatch","removeAllListeners","clearAllLocationWatch","saved","removeListener","arg1","undefined","watchRegions","clearRegionsWatch","clearAllRegionsWatch","setSFMCCredentials","setPoiRadius","radius","addRegion","region","getRegions","regionID","getAllRegions","then","formatted","forEach","item","push","Promise","resolve","catch","e","reject","getLocations","locationID","getAllLocations","getLocation","getPois","poiID","getAllPois","getPoi","removeRegions","removeAllRegions","removeRegion","removeLocations","removeAllLocations","removePois","removeAllPois","startCustomTracking","sourceType","source","WoosmapGeofencing"],"sources":["index.tsx"],"sourcesContent":["import { NativeEventEmitter } from 'react-native';\nimport uuid from 'react-native-uuid';\nimport PluginGeofencing from './internal/nativeInterface';\nimport Location from './internal/Location';\nimport Region from './internal/Region';\nimport Poi from './internal/Poi';\nimport type {\n GeofenceRegion,\n RegionType,\n ProfileSource,\n} from './internal/types';\n\nconst eventEmitter = new NativeEventEmitter(PluginGeofencing);\n\nlet subscriptionsLocation: any = {};\nlet subscriptionsRegion: any = {};\n/**\n * Initializes the Woosmap object\n * @param arg0 A JSON object with Woosmap Key (optional) and tracking profile (`liveTracking`,`passiveTracking`,`visitsTracking`).\n * @returns promise:success - A callback function that will be called on success.\n error - A callback function that will be called on error.\n */\nfunction initialize(arg0?: any): Promise<string> {\n if (arg0 == null) {\n arg0 = {};\n }\n return PluginGeofencing.initialize(arg0);\n}\n\n/**\n * A method that sets Woosmap private API key\n * @param apiKey new API key.\n * @returns promise:success - A callback function that will be called on success.\n error - A callback function that will be called on error.\n */\nfunction setWoosmapApiKey(apiKey: string): Promise<string> {\n return PluginGeofencing.setWoosmapApiKey([apiKey]);\n}\n\n/**\n * A method to start tracking the user's location.\n * @param trackingProfile The configuration profile to use. Values could be anyone of the following: liveTracking, passiveTracking and visitsTracking.\n * @returns promise:success - A callback function that will be called on success.\n error - A callback function that will be called on error.\n */\nfunction startTracking(trackingProfile: string): Promise<string> {\n return PluginGeofencing.startTracking([trackingProfile]);\n}\n\n/**\n * Stops tracking the user's location.\n * @returns promise:success - A callback function that will be called on success.\n error - A callback function that will be called on error.\n */\nfunction stopTracking(): Promise<string> {\n return PluginGeofencing.stopTracking();\n}\n\n/**\n * A method to request the required permissions to collect locations.\n * @param background - A boolean value indicating whether the permissions to request is for background or foreground permission.\n * @returns A callback that will be called on successful authorization by the app. A callback that will be called when the app denies permission. The plugin will return an object with a message - 'Permission Denied'.\n */\nfunction requestPermissions(background?: boolean): Promise<string> {\n if (background == null) {\n background = false;\n }\n return PluginGeofencing.requestPermissions([background]);\n}\n\n/**\n * A method to check if the app has granted required permissions to track location.\n * @returns A callback that will be called with the following status - GRANTED_BACKGROUND, GRANTED_FOREGROUND, DENIED\n */\nfunction getPermissionsStatus(): Promise<string> {\n return PluginGeofencing.getPermissionsStatus();\n}\n\n/**\n * Method will\ninvoke callback and pass a location object as a parameter. Method will return a watchId . This id can be used to remove a callback.\n * @param success new location found callback\n * @param error error status callback\n * @returns watchid\n */\nfunction watchLocation(\n success: (result: Location) => any,\n error?: any\n): Promise<string> {\n const watchID = uuid.v1().toString();\n\n const successCallback = (result: any) => {\n success(Location.jsonToObj(result));\n };\n\n subscriptionsLocation[watchID] = [\n eventEmitter.addListener('geolocationDidChange', successCallback),\n error ? eventEmitter.addListener('geolocationError', error) : null,\n ];\n return PluginGeofencing.watchLocation(watchID);\n}\n\n/**\n * A method to stop tracking location for a specified watch. If watchId is null or undefined the plugin will clear all watches.\n * @param watchID Reference ID.\n * @returns return promise with same id back in case of success otherwise error info\n */\nfunction clearLocationWatch(watchID?: string): Promise<string> {\n if (watchID == null) {\n eventEmitter.removeAllListeners('geolocationDidChange');\n eventEmitter.removeAllListeners('geolocationError');\n subscriptionsLocation = {};\n return PluginGeofencing.clearAllLocationWatch();\n } else {\n const saved = subscriptionsLocation[watchID];\n if (saved) {\n const arg0 = saved[0];\n eventEmitter.removeListener('geolocationDidChange', arg0);\n const arg1 = saved[1];\n if (arg1) {\n eventEmitter.removeListener('geolocationError', arg1);\n }\n subscriptionsLocation[watchID] = undefined;\n }\n return PluginGeofencing.clearLocationWatch(watchID);\n }\n}\n\n/**\n * A method to to track Regions. Method will invoke a callback with Region object. Method will return\na watch id which can be used later to remove the callback.\n * @param success new location found callback\n * @param error error status callback\n * @returns watchid\n */\nfunction watchRegions(\n success: (result: Region) => any,\n error?: any\n): Promise<string> {\n const watchID = uuid.v1().toString();\n\n const successCallback = (result: any) => {\n success(Region.jsonToObj(result));\n };\n\n subscriptionsRegion[watchID] = [\n eventEmitter.addListener('woosmapgeofenceRegionDidChange', successCallback),\n error\n ? eventEmitter.addListener('woosmapgeofenceRegionError', error)\n : null,\n ];\n return PluginGeofencing.watchRegions(watchID);\n}\n\n/**\n * A method to clear the specified watch tracing the regions. If the watchId is null or undefined then it will clear all the watches tracking the regions.\n * @param watchID Reference ID.\n * @returns return promise with same id back in case of success otherwise error info\n */\nfunction clearRegionsWatch(watchID: string): Promise<string> {\n if (watchID == null) {\n eventEmitter.removeAllListeners('woosmapgeofenceRegionDidChange');\n eventEmitter.removeAllListeners('woosmapgeofenceRegionError');\n subscriptionsRegion = {};\n return PluginGeofencing.clearAllRegionsWatch();\n } else {\n const saved = subscriptionsRegion[watchID];\n if (saved) {\n const arg0 = saved[0];\n eventEmitter.removeListener('woosmapgeofenceRegionDidChange', arg0);\n const arg1 = saved[1];\n if (arg1) {\n eventEmitter.removeListener('woosmapgeofenceRegionError', arg1);\n }\n subscriptionsRegion[watchID] = undefined;\n }\n return PluginGeofencing.clearRegionsWatch(watchID);\n }\n}\n/**\n * Sets Sales Force Marketing Cloud (SFMC) credentials\n * @param arg0 A JSON object with SFMC credentials. Keys authenticationBaseURI, restBaseURI, client_id, client_secret and contactKey are required.\n * @returns promise with A callback that will be called on success or error.\n */\nfunction setSFMCCredentials(arg0: Object): Promise<string> {\n return PluginGeofencing.setSFMCCredentials(arg0);\n}\n\n/**\n * When you create a geofence around a POI, manually define the radius value (100.0) or choose the user_properties subfield that corresponds to radius value of the geofence (\"radiusPOI\").\n * @param radius can be integer or string.\n * @returns promise with A callback that will be called on success or error.\n */\nfunction setPoiRadius(radius: string): Promise<string> {\n return PluginGeofencing.setPoiRadius(radius);\n}\n/**\n * Adds a custom region that you want to monitor.\n * @param region A GeofenceRegion object with latitude, longitude, radius and type.\n * @returns promise with A callback that will be called on success or error.\n */\n\nfunction addRegion(region: GeofenceRegion): Promise<string> {\n return PluginGeofencing.addRegion(region);\n}\n/**\n * Retrieve saved region info\n * @param regionID If it pass return info for given region or return all region info\n * @returns promise with A callback that will be called on success or error.\n */\nfunction getRegions(regionID?: string): Promise<Region[]> {\n if (regionID == null) {\n return PluginGeofencing.getAllRegions()\n .then((result: any[]) => {\n var formatted: Region[] = [];\n result.forEach((item) => {\n formatted.push(Region.jsonToObj(item));\n });\n return Promise.resolve(formatted);\n })\n .catch((e: any) => {\n return Promise.reject(e);\n });\n } else {\n return PluginGeofencing.getRegions(regionID)\n .then((result: any) => {\n var formatted: Region[] = [];\n formatted.push(Region.jsonToObj(result));\n return Promise.resolve(formatted);\n })\n .catch((e: any) => {\n return Promise.reject(e);\n });\n }\n}\n\n/**\n * Retrieve saved location info\n * @param locationID - Optional in case of location id pass it return only that location info\n * @returns promise with A callback that will be called on success or error.\n */\nfunction getLocations(locationID?: string): Promise<Location[]> {\n if (locationID == null) {\n return PluginGeofencing.getAllLocations()\n .then((result: any[]) => {\n var formatted: Location[] = [];\n result.forEach((item) => {\n formatted.push(Location.jsonToObj(item));\n });\n return Promise.resolve(formatted);\n })\n .catch((e: any) => {\n return Promise.reject(e);\n });\n } else {\n return PluginGeofencing.getLocation(locationID)\n .then((result: any) => {\n var formatted: Location[] = [];\n formatted.push(Location.jsonToObj(result));\n return Promise.resolve(formatted);\n })\n .catch((e: any) => {\n return Promise.reject(e);\n });\n }\n}\n\n/**\n * Retrieve saved POI info\n * @param poiID - Optional in case of poi id (LocationID or StoreID) pass it return only that POI info\n * @returns promise with A callback that will be called on success or error.\n */\nfunction getPois(poiID?: string): Promise<Poi[]> {\n if (poiID == null) {\n return PluginGeofencing.getAllPois()\n .then((result: any[]) => {\n var formatted: Poi[] = [];\n result.forEach((item) => {\n formatted.push(Poi.jsonToObj(item));\n });\n return Promise.resolve(formatted);\n })\n .catch((e: any) => {\n return Promise.reject(e);\n });\n } else {\n return PluginGeofencing.getPoi(poiID)\n .then((result: any) => {\n var formatted: Poi[] = [];\n formatted.push(Poi.jsonToObj(result));\n return Promise.resolve(formatted);\n })\n .catch((e: any) => {\n return Promise.reject(e);\n });\n }\n}\n\n/**\n * Remove saved region info\n * @param regionID If it pass remove info for given region or removes all region info\n * @returns promise with A callback that will be called on success or error.\n */\nfunction removeRegions(regionID?: string): Promise<string> {\n if (regionID == null) {\n return PluginGeofencing.removeAllRegions();\n } else {\n return PluginGeofencing.removeRegion(regionID);\n }\n}\n\n/**\n * Remove saved location info\n * @returns promise with A callback that will be called on success or error.\n */\nfunction removeLocations(): Promise<string> {\n return PluginGeofencing.removeAllLocations();\n}\n\n/**\n * Remove saved POI info\n * @returns promise with A callback that will be called on success or error.\n */\nfunction removePois(): Promise<string> {\n return PluginGeofencing.removeAllPois();\n}\n/**\n * if preset tracking profiles don’t fit with your use cases, you can build your own profile and uses the startCustomTracking() method. \n * There are two way to host the json file:\n * - included in the client application (local)\n * - hosted externally in a file folder in your information system (external)\n * @param sourceType local/external\n * @param source location of profile to be fetch\n * @returns promise with A callback that will be called on success or error.\n */\nfunction startCustomTracking(\n sourceType: ProfileSource,\n source: string\n): Promise<string> {\n return PluginGeofencing.startCustomTracking(sourceType, source);\n}\n\nexport type {\n RegionType,\n GeofenceRegion,\n Region,\n Location,\n Poi,\n ProfileSource,\n};\n\nconst WoosmapGeofencing = {\n initialize,\n setWoosmapApiKey,\n startTracking,\n requestPermissions,\n getPermissionsStatus,\n stopTracking,\n watchLocation,\n clearLocationWatch,\n watchRegions,\n clearRegionsWatch,\n setSFMCCredentials,\n setPoiRadius,\n addRegion,\n getRegions,\n removeRegions,\n getLocations,\n removeLocations,\n getPois,\n removePois,\n startCustomTracking,\n};\n\nexport default WoosmapGeofencing;\n"],"mappings":"AAAA,SAASA,kBAAkB,QAAQ,cAAc;AACjD,OAAOC,IAAI,MAAM,mBAAmB;AACpC,OAAOC,gBAAgB,MAAM,4BAA4B;AACzD,OAAOC,QAAQ,MAAM,qBAAqB;AAC1C,OAAOC,MAAM,MAAM,mBAAmB;AACtC,OAAOC,GAAG,MAAM,gBAAgB;AAOhC,MAAMC,YAAY,GAAG,IAAIN,kBAAkB,CAACE,gBAAgB,CAAC;AAE7D,IAAIK,qBAA0B,GAAG,CAAC,CAAC;AACnC,IAAIC,mBAAwB,GAAG,CAAC,CAAC;AACjC;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,UAAUA,CAACC,IAAU,EAAmB;EAC/C,IAAIA,IAAI,IAAI,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,iBAAiB;EACjBE,kBAAkB;EAClBC,YAAY;EACZE,SAAS;EACTE,UAAU;EACVqB,aAAa;EACbR,YAAY;EACZW,eAAe;EACfP,OAAO;EACPS,UAAU;EACVE;AACF,CAAC;AAED,eAAeG,iBAAiB"}
|
|
1
|
+
{"version":3,"names":["NativeEventEmitter","Platform","uuid","PluginGeofencing","Location","Region","Poi","eventEmitter","subscriptionsLocation","subscriptionsRegion","initialize","arg0","setWoosmapApiKey","apiKey","startTracking","trackingProfile","stopTracking","requestPermissions","background","requestBLEPermissions","OS","Promise","resolve","getPermissionsStatus","getBLEPermissionsStatus","watchLocation","success","error","watchID","v1","toString","successCallback","result","jsonToObj","addListener","clearLocationWatch","removeAllListeners","clearAllLocationWatch","saved","removeListener","arg1","undefined","watchRegions","clearRegionsWatch","clearAllRegionsWatch","setSFMCCredentials","setPoiRadius","radius","addRegion","region","getRegions","regionID","getAllRegions","then","formatted","forEach","item","push","catch","e","reject","getLocations","locationID","getAllLocations","getLocation","getPois","poiID","getAllPois","getPoi","removeRegions","removeAllRegions","removeRegion","removeLocations","removeAllLocations","removePois","removeAllPois","startCustomTracking","sourceType","source","WoosmapGeofencing"],"sources":["index.tsx"],"sourcesContent":["import { NativeEventEmitter, Platform } from 'react-native';\nimport uuid from 'react-native-uuid';\nimport PluginGeofencing from './internal/nativeInterface';\nimport Location from './internal/Location';\nimport Region from './internal/Region';\nimport Poi from './internal/Poi';\nimport type {\n GeofenceRegion,\n RegionType,\n ProfileSource,\n} from './internal/types';\n\nconst eventEmitter = new NativeEventEmitter(PluginGeofencing);\n\nlet subscriptionsLocation: any = {};\nlet subscriptionsRegion: any = {};\n/**\n * Initializes the Woosmap object\n * @param arg0 A JSON object with Woosmap Key (optional) and tracking profile (`liveTracking`,`passiveTracking`,`visitsTracking`).\n * @returns promise:success - A callback function that will be called on success.\n error - A callback function that will be called on error.\n */\nfunction initialize(arg0?: any): Promise<string> {\n if (arg0 == null) {\n arg0 = {};\n }\n return PluginGeofencing.initialize(arg0);\n}\n\n/**\n * A method that sets Woosmap private API key\n * @param apiKey new API key.\n * @returns promise:success - A callback function that will be called on success.\n error - A callback function that will be called on error.\n */\nfunction setWoosmapApiKey(apiKey: string): Promise<string> {\n return PluginGeofencing.setWoosmapApiKey([apiKey]);\n}\n\n/**\n * A method to start tracking the user's location.\n * @param trackingProfile The configuration profile to use. Values could be anyone of the following: liveTracking, passiveTracking and visitsTracking.\n * @returns promise:success - A callback function that will be called on success.\n error - A callback function that will be called on error.\n */\nfunction startTracking(trackingProfile: string): Promise<string> {\n return PluginGeofencing.startTracking([trackingProfile]);\n}\n\n/**\n * Stops tracking the user's location.\n * @returns promise:success - A callback function that will be called on success.\n error - A callback function that will be called on error.\n */\nfunction stopTracking(): Promise<string> {\n return PluginGeofencing.stopTracking();\n}\n\n/**\n * A method to request the required permissions to collect locations.\n * @param background - A boolean value indicating whether the permissions to request is for background or foreground permission.\n * @returns A callback that will be called on successful authorization by the app. A callback that will be called when the app denies permission. The plugin will return an object with a message - 'Permission Denied'.\n */\nfunction requestPermissions(background?: boolean): Promise<string> {\n if (background == null) {\n background = false;\n }\n return PluginGeofencing.requestPermissions([background]);\n}\n\n/**\n * A method to request the required permissions to collect locations.\n * @returns A callback that will be called on successful authorization by the app. A callback that will be called when the app denies permission. \n * The plugin will return an object with either one of the messages - BACKGROUND_LOCATION_DENIED, GRANTED, DENIED\n */\nfunction requestBLEPermissions(): Promise<string> {\n if (Platform.OS == 'android'){\n return PluginGeofencing.requestBLEPermissions();\n }\n else{\n return new Promise((resolve) => {\n resolve(\"GRANTED\");\n });\n }\n}\n\n/**\n * A method to check if the app has granted required permissions to track location.\n * @returns A callback that will be called with the following status - GRANTED_BACKGROUND, GRANTED_FOREGROUND, DENIED\n */\nfunction getPermissionsStatus(): Promise<string> {\n return PluginGeofencing.getPermissionsStatus();\n}\n\n/**\n * A method to check if the app has granted required permissions to track location.\n * @returns A callback that will be called with the following status - BACKGROUND_LOCATION_DENIED, GRANTED, DENIED\n */\nfunction getBLEPermissionsStatus(): Promise<string> {\n if (Platform.OS == 'android'){\n return PluginGeofencing.getBLEPermissionsStatus();\n }\n else{\n return new Promise((resolve) => {\n resolve(\"GRANTED\");\n });\n }\n}\n\n/**\n * Method will\ninvoke callback and pass a location object as a parameter. Method will return a watchId . This id can be used to remove a callback.\n * @param success new location found callback\n * @param error error status callback\n * @returns watchid\n */\nfunction watchLocation(\n success: (result: Location) => any,\n error?: any\n): Promise<string> {\n const watchID = uuid.v1().toString();\n\n const successCallback = (result: any) => {\n success(Location.jsonToObj(result));\n };\n\n subscriptionsLocation[watchID] = [\n eventEmitter.addListener('geolocationDidChange', successCallback),\n error ? eventEmitter.addListener('geolocationError', error) : null,\n ];\n return PluginGeofencing.watchLocation(watchID);\n}\n\n/**\n * A method to stop tracking location for a specified watch. If watchId is null or undefined the plugin will clear all watches.\n * @param watchID Reference ID.\n * @returns return promise with same id back in case of success otherwise error info\n */\nfunction clearLocationWatch(watchID?: string): Promise<string> {\n if (watchID == null) {\n eventEmitter.removeAllListeners('geolocationDidChange');\n eventEmitter.removeAllListeners('geolocationError');\n subscriptionsLocation = {};\n return PluginGeofencing.clearAllLocationWatch();\n } else {\n const saved = subscriptionsLocation[watchID];\n if (saved) {\n const arg0 = saved[0];\n eventEmitter.removeListener('geolocationDidChange', arg0);\n const arg1 = saved[1];\n if (arg1) {\n eventEmitter.removeListener('geolocationError', arg1);\n }\n subscriptionsLocation[watchID] = undefined;\n }\n return PluginGeofencing.clearLocationWatch(watchID);\n }\n}\n\n/**\n * A method to to track Regions. Method will invoke a callback with Region object. Method will return\na watch id which can be used later to remove the callback.\n * @param success new location found callback\n * @param error error status callback\n * @returns watchid\n */\nfunction watchRegions(\n success: (result: Region) => any,\n error?: any\n): Promise<string> {\n const watchID = uuid.v1().toString();\n\n const successCallback = (result: any) => {\n success(Region.jsonToObj(result));\n };\n\n subscriptionsRegion[watchID] = [\n eventEmitter.addListener('woosmapgeofenceRegionDidChange', successCallback),\n error\n ? eventEmitter.addListener('woosmapgeofenceRegionError', error)\n : null,\n ];\n return PluginGeofencing.watchRegions(watchID);\n}\n\n/**\n * A method to clear the specified watch tracing the regions. If the watchId is null or undefined then it will clear all the watches tracking the regions.\n * @param watchID Reference ID.\n * @returns return promise with same id back in case of success otherwise error info\n */\nfunction clearRegionsWatch(watchID: string): Promise<string> {\n if (watchID == null) {\n eventEmitter.removeAllListeners('woosmapgeofenceRegionDidChange');\n eventEmitter.removeAllListeners('woosmapgeofenceRegionError');\n subscriptionsRegion = {};\n return PluginGeofencing.clearAllRegionsWatch();\n } else {\n const saved = subscriptionsRegion[watchID];\n if (saved) {\n const arg0 = saved[0];\n eventEmitter.removeListener('woosmapgeofenceRegionDidChange', arg0);\n const arg1 = saved[1];\n if (arg1) {\n eventEmitter.removeListener('woosmapgeofenceRegionError', arg1);\n }\n subscriptionsRegion[watchID] = undefined;\n }\n return PluginGeofencing.clearRegionsWatch(watchID);\n }\n}\n/**\n * Sets Sales Force Marketing Cloud (SFMC) credentials\n * @param arg0 A JSON object with SFMC credentials. Keys authenticationBaseURI, restBaseURI, client_id, client_secret and contactKey are required.\n * @returns promise with A callback that will be called on success or error.\n */\nfunction setSFMCCredentials(arg0: Object): Promise<string> {\n return PluginGeofencing.setSFMCCredentials(arg0);\n}\n\n/**\n * When you create a geofence around a POI, manually define the radius value (100.0) or choose the user_properties subfield that corresponds to radius value of the geofence (\"radiusPOI\").\n * @param radius can be integer or string.\n * @returns promise with A callback that will be called on success or error.\n */\nfunction setPoiRadius(radius: string): Promise<string> {\n return PluginGeofencing.setPoiRadius(radius);\n}\n/**\n * Adds a custom region that you want to monitor.\n * @param region A GeofenceRegion object with latitude, longitude, radius and type.\n * @returns promise with A callback that will be called on success or error.\n */\n\nfunction addRegion(region: GeofenceRegion): Promise<string> {\n return PluginGeofencing.addRegion(region);\n}\n/**\n * Retrieve saved region info\n * @param regionID If it pass return info for given region or return all region info\n * @returns promise with A callback that will be called on success or error.\n */\nfunction getRegions(regionID?: string): Promise<Region[]> {\n if (regionID == null) {\n return PluginGeofencing.getAllRegions()\n .then((result: any[]) => {\n var formatted: Region[] = [];\n result.forEach((item) => {\n formatted.push(Region.jsonToObj(item));\n });\n return Promise.resolve(formatted);\n })\n .catch((e: any) => {\n return Promise.reject(e);\n });\n } else {\n return PluginGeofencing.getRegions(regionID)\n .then((result: any) => {\n var formatted: Region[] = [];\n formatted.push(Region.jsonToObj(result));\n return Promise.resolve(formatted);\n })\n .catch((e: any) => {\n return Promise.reject(e);\n });\n }\n}\n\n/**\n * Retrieve saved location info\n * @param locationID - Optional in case of location id pass it return only that location info\n * @returns promise with A callback that will be called on success or error.\n */\nfunction getLocations(locationID?: string): Promise<Location[]> {\n if (locationID == null) {\n return PluginGeofencing.getAllLocations()\n .then((result: any[]) => {\n var formatted: Location[] = [];\n result.forEach((item) => {\n formatted.push(Location.jsonToObj(item));\n });\n return Promise.resolve(formatted);\n })\n .catch((e: any) => {\n return Promise.reject(e);\n });\n } else {\n return PluginGeofencing.getLocation(locationID)\n .then((result: any) => {\n var formatted: Location[] = [];\n formatted.push(Location.jsonToObj(result));\n return Promise.resolve(formatted);\n })\n .catch((e: any) => {\n return Promise.reject(e);\n });\n }\n}\n\n/**\n * Retrieve saved POI info\n * @param poiID - Optional in case of poi id (LocationID or StoreID) pass it return only that POI info\n * @returns promise with A callback that will be called on success or error.\n */\nfunction getPois(poiID?: string): Promise<Poi[]> {\n if (poiID == null) {\n return PluginGeofencing.getAllPois()\n .then((result: any[]) => {\n var formatted: Poi[] = [];\n result.forEach((item) => {\n formatted.push(Poi.jsonToObj(item));\n });\n return Promise.resolve(formatted);\n })\n .catch((e: any) => {\n return Promise.reject(e);\n });\n } else {\n return PluginGeofencing.getPoi(poiID)\n .then((result: any) => {\n var formatted: Poi[] = [];\n formatted.push(Poi.jsonToObj(result));\n return Promise.resolve(formatted);\n })\n .catch((e: any) => {\n return Promise.reject(e);\n });\n }\n}\n\n/**\n * Remove saved region info\n * @param regionID If it pass remove info for given region or removes all region info\n * @returns promise with A callback that will be called on success or error.\n */\nfunction removeRegions(regionID?: string): Promise<string> {\n if (regionID == null) {\n return PluginGeofencing.removeAllRegions();\n } else {\n return PluginGeofencing.removeRegion(regionID);\n }\n}\n\n/**\n * Remove saved location info\n * @returns promise with A callback that will be called on success or error.\n */\nfunction removeLocations(): Promise<string> {\n return PluginGeofencing.removeAllLocations();\n}\n\n/**\n * Remove saved POI info\n * @returns promise with A callback that will be called on success or error.\n */\nfunction removePois(): Promise<string> {\n return PluginGeofencing.removeAllPois();\n}\n/**\n * if preset tracking profiles don’t fit with your use cases, you can build your own profile and uses the startCustomTracking() method. \n * There are two way to host the json file:\n * - included in the client application (local)\n * - hosted externally in a file folder in your information system (external)\n * @param sourceType local/external\n * @param source location of profile to be fetch\n * @returns promise with A callback that will be called on success or error.\n */\nfunction startCustomTracking(\n sourceType: ProfileSource,\n source: string\n): Promise<string> {\n return PluginGeofencing.startCustomTracking(sourceType, source);\n}\n\nexport type {\n RegionType,\n GeofenceRegion,\n Region,\n Location,\n Poi,\n ProfileSource,\n};\n\nconst WoosmapGeofencing = {\n initialize,\n setWoosmapApiKey,\n startTracking,\n requestPermissions,\n requestBLEPermissions,\n getPermissionsStatus,\n getBLEPermissionsStatus,\n stopTracking,\n watchLocation,\n clearLocationWatch,\n watchRegions,\n clearRegionsWatch,\n setSFMCCredentials,\n setPoiRadius,\n addRegion,\n getRegions,\n removeRegions,\n getLocations,\n removeLocations,\n getPois,\n removePois,\n startCustomTracking,\n};\n\nexport default WoosmapGeofencing;\n"],"mappings":"AAAA,SAASA,kBAAkB,EAAEC,QAAQ,QAAQ,cAAc;AAC3D,OAAOC,IAAI,MAAM,mBAAmB;AACpC,OAAOC,gBAAgB,MAAM,4BAA4B;AACzD,OAAOC,QAAQ,MAAM,qBAAqB;AAC1C,OAAOC,MAAM,MAAM,mBAAmB;AACtC,OAAOC,GAAG,MAAM,gBAAgB;AAOhC,MAAMC,YAAY,GAAG,IAAIP,k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,CAAC;EACN;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA,SAASU,aAAaA,CAAClB,QAAiB,EAAmB;EACzD,IAAIA,QAAQ,IAAI,IAAI,EAAE;IACpB,OAAOhD,gBAAgB,CAACmE,gBAAgB,CAAC,CAAC;EAC5C,CAAC,MAAM;IACL,OAAOnE,gBAAgB,CAACoE,YAAY,CAACpB,QAAQ,CAAC;EAChD;AACF;;AAEA;AACA;AACA;AACA;AACA,SAASqB,eAAeA,CAAA,EAAoB;EAC1C,OAAOrE,gBAAgB,CAACsE,kBAAkB,CAAC,CAAC;AAC9C;;AAEA;AACA;AACA;AACA;AACA,SAASC,UAAUA,CAAA,EAAoB;EACrC,OAAOvE,gBAAgB,CAACwE,aAAa,CAAC,CAAC;AACzC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,mBAAmBA,CAC1BC,UAAyB,EACzBC,MAAc,EACG;EACjB,OAAO3E,gBAAgB,CAACyE,mBAAmB,CAACC,UAAU,EAAEC,MAAM,CAAC;AACjE;AAWA,MAAMC,iBAAiB,GAAG;EACxBrE,UAAU;EACVE,gBAAgB;EAChBE,aAAa;EACbG,kBAAkB;EAClBE,qBAAqB;EACrBI,oBAAoB;EACpBC,uBAAuB;EACvBR,YAAY;EACZS,aAAa;EACbU,kBAAkB;EAClBO,YAAY;EACZC,iBAAiB;EACjBE,kBAAkB;EAClBC,YAAY;EACZE,SAAS;EACTE,UAAU;EACVmB,aAAa;EACbR,YAAY;EACZW,eAAe;EACfP,OAAO;EACPS,UAAU;EACVE;AACF,CAAC;AAED,eAAeG,iBAAiB"}
|
|
@@ -35,11 +35,22 @@ declare function stopTracking(): Promise<string>;
|
|
|
35
35
|
* @returns A callback that will be called on successful authorization by the app. A callback that will be called when the app denies permission. The plugin will return an object with a message - 'Permission Denied'.
|
|
36
36
|
*/
|
|
37
37
|
declare function requestPermissions(background?: boolean): Promise<string>;
|
|
38
|
+
/**
|
|
39
|
+
* A method to request the required permissions to collect locations.
|
|
40
|
+
* @returns A callback that will be called on successful authorization by the app. A callback that will be called when the app denies permission.
|
|
41
|
+
* The plugin will return an object with either one of the messages - BACKGROUND_LOCATION_DENIED, GRANTED, DENIED
|
|
42
|
+
*/
|
|
43
|
+
declare function requestBLEPermissions(): Promise<string>;
|
|
38
44
|
/**
|
|
39
45
|
* A method to check if the app has granted required permissions to track location.
|
|
40
46
|
* @returns A callback that will be called with the following status - GRANTED_BACKGROUND, GRANTED_FOREGROUND, DENIED
|
|
41
47
|
*/
|
|
42
48
|
declare function getPermissionsStatus(): Promise<string>;
|
|
49
|
+
/**
|
|
50
|
+
* A method to check if the app has granted required permissions to track location.
|
|
51
|
+
* @returns A callback that will be called with the following status - BACKGROUND_LOCATION_DENIED, GRANTED, DENIED
|
|
52
|
+
*/
|
|
53
|
+
declare function getBLEPermissionsStatus(): Promise<string>;
|
|
43
54
|
/**
|
|
44
55
|
* Method will
|
|
45
56
|
invoke callback and pass a location object as a parameter. Method will return a watchId . This id can be used to remove a callback.
|
|
@@ -136,7 +147,9 @@ declare const WoosmapGeofencing: {
|
|
|
136
147
|
setWoosmapApiKey: typeof setWoosmapApiKey;
|
|
137
148
|
startTracking: typeof startTracking;
|
|
138
149
|
requestPermissions: typeof requestPermissions;
|
|
150
|
+
requestBLEPermissions: typeof requestBLEPermissions;
|
|
139
151
|
getPermissionsStatus: typeof getPermissionsStatus;
|
|
152
|
+
getBLEPermissionsStatus: typeof getBLEPermissionsStatus;
|
|
140
153
|
stopTracking: typeof stopTracking;
|
|
141
154
|
watchLocation: typeof watchLocation;
|
|
142
155
|
clearLocationWatch: typeof clearLocationWatch;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@woosmap/react-native-plugin-geofencing",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "This react-native plugin extends the functionality offered by the Woosmap Geofencing Mobile SDKs. Find more about the Woosmap Geofencing SDK",
|
|
5
5
|
"main": "lib/commonjs/index",
|
|
6
6
|
"module": "lib/module/index",
|
|
@@ -16,7 +16,7 @@ Pod::Spec.new do |s|
|
|
|
16
16
|
s.source_files = "ios/**/*.{h,m,mm,swift}"
|
|
17
17
|
|
|
18
18
|
s.dependency "React-Core"
|
|
19
|
-
s.dependency "WoosmapGeofencing"
|
|
19
|
+
s.dependency "WoosmapGeofencing", '~> 4.0.0'
|
|
20
20
|
s.default_subspec = :default
|
|
21
21
|
|
|
22
22
|
s.subspec "default" do |spec|
|