@woosmap/react-native-plugin-geofencing 1.0.0-beta.1 → 1.0.0-beta.3
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/CHANGELOG.md +1 -2
- package/README.md +0 -9
- package/android/build.gradle +1 -1
- package/android/src/main/java/com/{reactnativeplugingeofencing → woosmap/reactnativeplugingeofencing}/AbstractPushHelper.java +1 -1
- package/android/src/main/java/com/{reactnativeplugingeofencing → woosmap/reactnativeplugingeofencing}/AirshipPushHelper.java +1 -1
- package/android/src/main/java/com/{reactnativeplugingeofencing → woosmap/reactnativeplugingeofencing}/WoosLocationReadyListener.java +1 -1
- package/android/src/main/java/com/{reactnativeplugingeofencing → woosmap/reactnativeplugingeofencing}/WoosRegionReadyListener.java +1 -1
- package/android/src/main/java/com/woosmap/reactnativeplugingeofencing/WoosmapGeofencingTurboModule.java +1025 -0
- package/android/src/main/java/com/{reactnativeplugingeofencing → woosmap/reactnativeplugingeofencing}/WoosmapGeofencingTurboPackage.java +3 -7
- package/android/src/main/java/com/{reactnativeplugingeofencing → woosmap/reactnativeplugingeofencing}/WoosmapMessageAndKey.java +2 -3
- package/android/src/main/java/com/{reactnativeplugingeofencing → woosmap/reactnativeplugingeofencing}/WoosmapTask.java +34 -128
- package/android/src/main/java/com/{reactnativeplugingeofencing → woosmap/reactnativeplugingeofencing}/WoosmapUtil.java +1 -1
- package/ios/WoosmapGeofenceMessage.swift +1 -0
- package/ios/WoosmapGeofencingTurbo.mm +110 -10
- package/ios/WoosmapGeofencingTurbo.swift +873 -11
- package/lib/commonjs/NativeWoosmapGeofencingTurbo.js +6 -3
- package/lib/commonjs/NativeWoosmapGeofencingTurbo.js.map +1 -1
- package/lib/commonjs/index.js +37 -131
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/NativeWoosmapGeofencingTurbo.js +6 -3
- package/lib/module/NativeWoosmapGeofencingTurbo.js.map +1 -1
- package/lib/module/index.js +37 -131
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/src/NativeWoosmapGeofencingTurbo.d.ts +37 -3
- package/lib/typescript/src/NativeWoosmapGeofencingTurbo.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +3 -3
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/package.json +2 -1
- package/src/NativeWoosmapGeofencingTurbo.ts +109 -0
- package/android/src/main/java/com/reactnativeplugingeofencing/PluginGeofencingModule.java +0 -1204
- package/android/src/main/java/com/reactnativeplugingeofencing/PluginGeofencingPackage.java +0 -28
- package/android/src/main/java/com/reactnativeplugingeofencing/WoosmapGeofencingTurboModule.java +0 -185
- package/ios/PluginGeofencing.mm +0 -123
- package/ios/PluginGeofencing.swift +0 -1243
- package/lib/commonjs/internal/nativeInterface.js +0 -13
- package/lib/commonjs/internal/nativeInterface.js.map +0 -1
- package/lib/module/internal/nativeInterface.js +0 -9
- package/lib/module/internal/nativeInterface.js.map +0 -1
- package/lib/typescript/src/internal/nativeInterface.d.ts +0 -3
- package/lib/typescript/src/internal/nativeInterface.d.ts.map +0 -1
- /package/ios/{PluginGeofencing-Bridging-Header.h → WoosmapGeofencing-Bridging-Header.h} +0 -0
|
@@ -1,1204 +0,0 @@
|
|
|
1
|
-
package com.reactnativeplugingeofencing;
|
|
2
|
-
|
|
3
|
-
import android.Manifest;
|
|
4
|
-
import android.app.Activity;
|
|
5
|
-
import android.content.pm.PackageManager;
|
|
6
|
-
import android.os.Build;
|
|
7
|
-
import android.util.Log;
|
|
8
|
-
|
|
9
|
-
import androidx.annotation.NonNull;
|
|
10
|
-
import androidx.annotation.RequiresApi;
|
|
11
|
-
import androidx.core.app.ActivityCompat;
|
|
12
|
-
import androidx.core.app.NotificationManagerCompat;
|
|
13
|
-
|
|
14
|
-
import com.facebook.react.bridge.LifecycleEventListener;
|
|
15
|
-
import com.facebook.react.bridge.Promise;
|
|
16
|
-
import com.facebook.react.bridge.ReactApplicationContext;
|
|
17
|
-
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
|
18
|
-
import com.facebook.react.bridge.ReactMethod;
|
|
19
|
-
import com.facebook.react.bridge.ReadableArray;
|
|
20
|
-
import com.facebook.react.bridge.ReadableMap;
|
|
21
|
-
import com.facebook.react.module.annotations.ReactModule;
|
|
22
|
-
import com.facebook.react.modules.core.PermissionAwareActivity;
|
|
23
|
-
import com.facebook.react.modules.core.PermissionListener;
|
|
24
|
-
import com.webgeoservices.woosmapgeofencing.NotificationIconProvider;
|
|
25
|
-
import com.webgeoservices.woosmapgeofencing.Woosmap;
|
|
26
|
-
import com.webgeoservices.woosmapgeofencing.WoosmapSettings;
|
|
27
|
-
import com.webgeoservices.woosmapgeofencingcore.database.Region;
|
|
28
|
-
|
|
29
|
-
import java.util.HashMap;
|
|
30
|
-
import java.util.Iterator;
|
|
31
|
-
import java.util.concurrent.ExecutorService;
|
|
32
|
-
import java.util.concurrent.Executors;
|
|
33
|
-
import java.io.File;
|
|
34
|
-
import java.io.FileOutputStream;
|
|
35
|
-
import java.io.InputStream;
|
|
36
|
-
import java.net.HttpURLConnection;
|
|
37
|
-
import java.net.URL;
|
|
38
|
-
|
|
39
|
-
@ReactModule(name = PluginGeofencingModule.NAME)
|
|
40
|
-
public class PluginGeofencingModule extends ReactContextBaseJavaModule implements PermissionListener, LifecycleEventListener {
|
|
41
|
-
public static final String NAME = "PluginGeofencing";
|
|
42
|
-
|
|
43
|
-
private ReactApplicationContext reactContext;
|
|
44
|
-
private Woosmap woosmap;
|
|
45
|
-
private static final int PERMISSIONS_REQUEST_CODE = 150; // random request code
|
|
46
|
-
private static final int BLE_PERMISSIONS_REQUEST_CODE = 160;
|
|
47
|
-
private static final int NOTIF_PERMISSIONS_REQUEST_CODE = 170;
|
|
48
|
-
private Promise mPermissionsRequestPromise;
|
|
49
|
-
private Promise mBLEPermissionsRequestPromise;
|
|
50
|
-
private WoosLocationReadyListener locationReadyListener;
|
|
51
|
-
private WoosRegionReadyListener regionReadyListener;
|
|
52
|
-
private Promise mNotificationPermissionsRequestPromise;
|
|
53
|
-
private final ExecutorService ioPool = Executors.newSingleThreadExecutor();
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
public PluginGeofencingModule(ReactApplicationContext reactContext) {
|
|
57
|
-
super(reactContext);
|
|
58
|
-
this.reactContext = reactContext;
|
|
59
|
-
this.reactContext.addLifecycleEventListener(this);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
/***
|
|
63
|
-
* Return plugin name.
|
|
64
|
-
* @return woosmap native plugin name.which is constant for android and ios.
|
|
65
|
-
*/
|
|
66
|
-
@Override
|
|
67
|
-
@NonNull
|
|
68
|
-
public String getName() {
|
|
69
|
-
return NAME;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
/***
|
|
74
|
-
* Initializes Woosmap object with given parameters.
|
|
75
|
-
* @param map ReadableMap may contain privateKeyWoosmapAPI with Woosmap API key,
|
|
76
|
-
* trackingProfile with tracking profile info.
|
|
77
|
-
* @param promise React native callback context.
|
|
78
|
-
*/
|
|
79
|
-
@ReactMethod
|
|
80
|
-
public void initialize(ReadableMap map, Promise promise) {
|
|
81
|
-
String trackingProfile = "";
|
|
82
|
-
try {
|
|
83
|
-
if (map.hasKey(WoosmapMessageAndKey.profileTrackingKey)) {
|
|
84
|
-
if (map.getString(WoosmapMessageAndKey.profileTrackingKey).equals(Woosmap.ConfigurationProfile.liveTracking)) {
|
|
85
|
-
trackingProfile = Woosmap.ConfigurationProfile.liveTracking;
|
|
86
|
-
} else if (map.getString(WoosmapMessageAndKey.profileTrackingKey).equals(Woosmap.ConfigurationProfile.passiveTracking)) {
|
|
87
|
-
trackingProfile = Woosmap.ConfigurationProfile.passiveTracking;
|
|
88
|
-
} else if (map.getString(WoosmapMessageAndKey.profileTrackingKey).equals(Woosmap.ConfigurationProfile.optimalPassiveTracking)) {
|
|
89
|
-
trackingProfile = Woosmap.ConfigurationProfile.optimalPassiveTracking;
|
|
90
|
-
} else if (map.getString(WoosmapMessageAndKey.profileTrackingKey).equals(Woosmap.ConfigurationProfile.visitsTracking)) {
|
|
91
|
-
trackingProfile = Woosmap.ConfigurationProfile.visitsTracking;
|
|
92
|
-
} else if (map.getString(WoosmapMessageAndKey.profileTrackingKey).equals(Woosmap.ConfigurationProfile.beaconTracking)) {
|
|
93
|
-
trackingProfile = Woosmap.ConfigurationProfile.beaconTracking;
|
|
94
|
-
} else {
|
|
95
|
-
promise.reject(WoosmapMessageAndKey.errorCode, WoosmapMessageAndKey.invalidProfileTrackingError);
|
|
96
|
-
return;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
woosmap = Woosmap.getInstance().initializeWoosmap(reactContext);
|
|
100
|
-
if (map.hasKey(WoosmapMessageAndKey.woosmapPrivateKeyString)) {
|
|
101
|
-
WoosmapSettings.privateKeyWoosmapAPI = map.getString(WoosmapMessageAndKey.woosmapPrivateKeyString);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
if (map.hasKey(WoosmapMessageAndKey.androidNotificationText)) {
|
|
105
|
-
WoosmapSettings.updateServiceNotificationText = map.getString(WoosmapMessageAndKey.androidNotificationText);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
if (map.hasKey(WoosmapMessageAndKey.androidNotificationTitle)) {
|
|
109
|
-
WoosmapSettings.updateServiceNotificationTitle = map.getString(WoosmapMessageAndKey.androidNotificationTitle);
|
|
110
|
-
}
|
|
111
|
-
if (map.hasKey(WoosmapMessageAndKey.androidNotificationIconName)) {
|
|
112
|
-
NotificationIconProvider.clearRuntimeOverrides(getReactApplicationContext());
|
|
113
|
-
setNotificationSmallIconByName(map.getString(WoosmapMessageAndKey.androidNotificationIconName), promise);
|
|
114
|
-
}
|
|
115
|
-
if (map.hasKey(WoosmapMessageAndKey.androidNotificationIconUrl)) {
|
|
116
|
-
NotificationIconProvider.clearRuntimeOverrides(getReactApplicationContext());
|
|
117
|
-
setNotificationSmallIconByUrl(map.getString(WoosmapMessageAndKey.androidNotificationIconUrl), promise);
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
if (map.hasKey(WoosmapMessageAndKey.enableAirshipConnectorKey)){
|
|
121
|
-
WoosmapUtil.setEnableAishipConnector(map.getBoolean(WoosmapMessageAndKey.enableAirshipConnectorKey), getReactApplicationContext());
|
|
122
|
-
}
|
|
123
|
-
// Set the Delay of Duration data
|
|
124
|
-
WoosmapSettings.numberOfDayDataDuration = 30;
|
|
125
|
-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
|
126
|
-
this.woosmap.createWoosmapNotifChannel();
|
|
127
|
-
}
|
|
128
|
-
this.woosmap.onResume();
|
|
129
|
-
//Add region listener
|
|
130
|
-
regionReadyListener = new WoosRegionReadyListener(reactContext);
|
|
131
|
-
woosmap.setRegionLogReadyListener(regionReadyListener);
|
|
132
|
-
woosmap.setRegionReadyListener(regionReadyListener);
|
|
133
|
-
if (!trackingProfile.isEmpty()) {
|
|
134
|
-
woosmap.startTracking(trackingProfile);
|
|
135
|
-
}
|
|
136
|
-
promise.resolve(WoosmapMessageAndKey.successMessage);
|
|
137
|
-
/* if (hasPermission(false)) {
|
|
138
|
-
//check required permission first
|
|
139
|
-
|
|
140
|
-
} else {
|
|
141
|
-
promise.reject(WoosmapMessageAndKey.errorCode, WoosmapMessageAndKey.permissionNotGrantedMessage);
|
|
142
|
-
}*/
|
|
143
|
-
} catch (Exception ex) {
|
|
144
|
-
promise.reject(WoosmapMessageAndKey.errorCode, ex.getMessage());
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
/***
|
|
150
|
-
* Checks if Woosmap object is instantiated.
|
|
151
|
-
* @return true if woosmap sdk is initialized else false.
|
|
152
|
-
*/
|
|
153
|
-
private boolean isWoosmapInitialized() {
|
|
154
|
-
if (woosmap == null) {
|
|
155
|
-
return false;
|
|
156
|
-
}
|
|
157
|
-
return true;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
private void setNotificationSmallIconByName(String name, Promise promise) {
|
|
161
|
-
try {
|
|
162
|
-
NotificationIconProvider.setRuntimeSmallIconByName(getReactApplicationContext(), name);
|
|
163
|
-
} catch (Throwable ex) {
|
|
164
|
-
promise.reject("EICON", ex);
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
private void setNotificationSmallIconByUrl(String url, Promise promise) {
|
|
169
|
-
try {
|
|
170
|
-
//NotificationIconProvider.setRuntimeSmallIconFromUri(getReactApplicationContext(), url);
|
|
171
|
-
ioPool.execute(() -> {
|
|
172
|
-
try {
|
|
173
|
-
Log.d(NAME, "Saving icon file to local file path");
|
|
174
|
-
String filePath = materializeToCache(url);
|
|
175
|
-
if (filePath == null) {
|
|
176
|
-
Log.e(NAME, "Failed to download/ copy icon");
|
|
177
|
-
promise.reject(WoosmapMessageAndKey.errorCode, "Failed to copy/download icon: " + url);
|
|
178
|
-
return;
|
|
179
|
-
}
|
|
180
|
-
Log.d(NAME, "Saved file path is: " + filePath);
|
|
181
|
-
NotificationIconProvider.setRuntimeSmallIconFromFile(getReactApplicationContext(), filePath);
|
|
182
|
-
promise.resolve(WoosmapMessageAndKey.successMessage);
|
|
183
|
-
} catch (Throwable t) {
|
|
184
|
-
promise.reject(WoosmapMessageAndKey.errorCode, t.toString());
|
|
185
|
-
}
|
|
186
|
-
});
|
|
187
|
-
} catch (Throwable ex) {
|
|
188
|
-
Log.e(NAME, ex.toString());
|
|
189
|
-
promise.reject(WoosmapMessageAndKey.errorCode, ex.toString());
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
private String materializeToCache(String uriString) throws Exception {
|
|
194
|
-
if (uriString == null || uriString.trim().isEmpty()) return null;
|
|
195
|
-
|
|
196
|
-
// destination file
|
|
197
|
-
File dest = new File(getReactApplicationContext().getCacheDir(), "woosmap_notif_icon.png");
|
|
198
|
-
|
|
199
|
-
if (uriString.startsWith("http://") || uriString.startsWith("https://")) {
|
|
200
|
-
// Download Metro/remote URL
|
|
201
|
-
URL url = new URL(uriString);
|
|
202
|
-
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
|
|
203
|
-
conn.setConnectTimeout(4000);
|
|
204
|
-
conn.setReadTimeout(4000);
|
|
205
|
-
conn.connect();
|
|
206
|
-
try (InputStream is = conn.getInputStream();
|
|
207
|
-
FileOutputStream os = new FileOutputStream(dest)) {
|
|
208
|
-
byte[] buf = new byte[8192];
|
|
209
|
-
int n;
|
|
210
|
-
while ((n = is.read(buf)) > 0) os.write(buf, 0, n);
|
|
211
|
-
} finally {
|
|
212
|
-
conn.disconnect();
|
|
213
|
-
}
|
|
214
|
-
return dest.getAbsolutePath();
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
if (uriString.startsWith("file://")) {
|
|
218
|
-
// Copy from local file to our cache (optional: could use as-is)
|
|
219
|
-
java.nio.file.Files.copy(
|
|
220
|
-
new File(uriString.substring("file://".length())).toPath(),
|
|
221
|
-
dest.toPath(),
|
|
222
|
-
java.nio.file.StandardCopyOption.REPLACE_EXISTING
|
|
223
|
-
);
|
|
224
|
-
return dest.getAbsolutePath();
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
// content:// and other schemes
|
|
228
|
-
android.net.Uri uri = android.net.Uri.parse(uriString);
|
|
229
|
-
try (InputStream is = getReactApplicationContext().getContentResolver().openInputStream(uri);
|
|
230
|
-
FileOutputStream os = new FileOutputStream(dest)) {
|
|
231
|
-
if (is == null) return null;
|
|
232
|
-
byte[] buf = new byte[8192];
|
|
233
|
-
int n;
|
|
234
|
-
while ((n = is.read(buf)) > 0) os.write(buf, 0, n);
|
|
235
|
-
return dest.getAbsolutePath();
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
/***
|
|
240
|
-
* Requests permissions. If the background permission is required then ACCESS_BACKGROUND_LOCATION is requested for devices above Android 9.
|
|
241
|
-
* @param data Readable Array containing a boolean parameter to check if the background permission is required.
|
|
242
|
-
*/
|
|
243
|
-
@ReactMethod
|
|
244
|
-
private void requestPermissions(ReadableArray data, Promise promise) {
|
|
245
|
-
try {
|
|
246
|
-
if (data.isNull(0)) {
|
|
247
|
-
promise.reject(WoosmapMessageAndKey.errorCode, WoosmapMessageAndKey.permissionValueNotProvided);
|
|
248
|
-
}
|
|
249
|
-
boolean isBackground = data.getBoolean(0);
|
|
250
|
-
PermissionAwareActivity activity = (PermissionAwareActivity) getReactApplicationContext().getCurrentActivity();
|
|
251
|
-
mPermissionsRequestPromise = promise;
|
|
252
|
-
if (activity != null) {
|
|
253
|
-
if (Build.VERSION.SDK_INT >= 23) {
|
|
254
|
-
if (isBackground && Build.VERSION.SDK_INT >= 29) {
|
|
255
|
-
activity.requestPermissions(new String[]{Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_BACKGROUND_LOCATION}, PERMISSIONS_REQUEST_CODE, this);
|
|
256
|
-
} else {
|
|
257
|
-
activity.requestPermissions(new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, PERMISSIONS_REQUEST_CODE, this);
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
} catch (Exception ex) {
|
|
262
|
-
promise.reject(WoosmapMessageAndKey.errorCode, ex.getMessage());
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
/***
|
|
267
|
-
* Requests Bluetooth permissions.
|
|
268
|
-
* @param promise React native callback context.
|
|
269
|
-
*/
|
|
270
|
-
@ReactMethod
|
|
271
|
-
public void requestBLEPermissions(Promise promise){
|
|
272
|
-
try{
|
|
273
|
-
if (promise == null) {
|
|
274
|
-
return;
|
|
275
|
-
}
|
|
276
|
-
PermissionAwareActivity activity = (PermissionAwareActivity) getReactApplicationContext().getCurrentActivity();
|
|
277
|
-
if (activity == null) {
|
|
278
|
-
promise.resolve(WoosmapMessageAndKey.unknownMessage);
|
|
279
|
-
return;
|
|
280
|
-
}
|
|
281
|
-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
|
282
|
-
mBLEPermissionsRequestPromise = promise;
|
|
283
|
-
activity.requestPermissions(new String[]{Manifest.permission.BLUETOOTH_SCAN, Manifest.permission.BLUETOOTH_ADMIN, Manifest.permission.BLUETOOTH}, BLE_PERMISSIONS_REQUEST_CODE, this);
|
|
284
|
-
}else{
|
|
285
|
-
promise.resolve(WoosmapMessageAndKey.backgroundPermissionGrantedMessage);
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
catch (Exception ex){
|
|
289
|
-
promise.reject(WoosmapMessageAndKey.errorCode, ex.getMessage(), ex);
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
@Override
|
|
294
|
-
public boolean onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
|
|
295
|
-
if (requestCode == PERMISSIONS_REQUEST_CODE && mPermissionsRequestPromise != null) {
|
|
296
|
-
providePermissionStatus(mPermissionsRequestPromise);
|
|
297
|
-
mPermissionsRequestPromise = null;
|
|
298
|
-
}
|
|
299
|
-
if (requestCode == BLE_PERMISSIONS_REQUEST_CODE && mBLEPermissionsRequestPromise != null) {
|
|
300
|
-
provideBLEPermissionStatus(mBLEPermissionsRequestPromise);
|
|
301
|
-
mBLEPermissionsRequestPromise = null;
|
|
302
|
-
}
|
|
303
|
-
if (requestCode == NOTIF_PERMISSIONS_REQUEST_CODE && mNotificationPermissionsRequestPromise != null) {
|
|
304
|
-
provideNotificationPermissionStatus(mNotificationPermissionsRequestPromise);
|
|
305
|
-
mNotificationPermissionsRequestPromise = null;
|
|
306
|
-
}
|
|
307
|
-
return true;
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
/***
|
|
311
|
-
* Provide status of bluetooth permission.
|
|
312
|
-
* @param promise React native callback context.
|
|
313
|
-
*/
|
|
314
|
-
private void provideBLEPermissionStatus(final Promise promise){
|
|
315
|
-
if (promise == null) {
|
|
316
|
-
return;
|
|
317
|
-
}
|
|
318
|
-
Activity activity = getReactApplicationContext().getCurrentActivity();
|
|
319
|
-
if (activity == null) {
|
|
320
|
-
promise.resolve(WoosmapMessageAndKey.unknownMessage);
|
|
321
|
-
return;
|
|
322
|
-
}
|
|
323
|
-
boolean granted = true;
|
|
324
|
-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
|
325
|
-
granted = ActivityCompat.checkSelfPermission(activity, Manifest.permission.ACCESS_BACKGROUND_LOCATION) == PackageManager.PERMISSION_GRANTED;
|
|
326
|
-
}
|
|
327
|
-
if (granted){
|
|
328
|
-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
|
329
|
-
granted = ActivityCompat.checkSelfPermission(activity, Manifest.permission.BLUETOOTH_SCAN) == PackageManager.PERMISSION_GRANTED;
|
|
330
|
-
}
|
|
331
|
-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
|
332
|
-
if (granted){
|
|
333
|
-
granted = ActivityCompat.checkSelfPermission(activity, Manifest.permission.BLUETOOTH_ADMIN) == PackageManager.PERMISSION_GRANTED;
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
if (granted) {
|
|
337
|
-
promise.resolve(WoosmapMessageAndKey.blePermissionGrantedMessage);
|
|
338
|
-
} else {
|
|
339
|
-
promise.resolve(WoosmapMessageAndKey.deniedPermissionMessage);
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
else{
|
|
343
|
-
promise.resolve(WoosmapMessageAndKey.backgroundPermissionDeniedMessage);
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
/***
|
|
348
|
-
* Provide status of foreground and background location permission.
|
|
349
|
-
* @param promise React native callback context.
|
|
350
|
-
*/
|
|
351
|
-
private void providePermissionStatus(final Promise promise) {
|
|
352
|
-
try {
|
|
353
|
-
if (promise == null) {
|
|
354
|
-
return;
|
|
355
|
-
}
|
|
356
|
-
Activity activity = getReactApplicationContext().getCurrentActivity();
|
|
357
|
-
if (activity == null) {
|
|
358
|
-
promise.resolve(WoosmapMessageAndKey.unknownMessage);
|
|
359
|
-
return;
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
boolean foreground = ActivityCompat.checkSelfPermission(activity, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED;
|
|
363
|
-
boolean background = foreground;
|
|
364
|
-
boolean denied = ActivityCompat.shouldShowRequestPermissionRationale(activity, Manifest.permission.ACCESS_FINE_LOCATION);
|
|
365
|
-
|
|
366
|
-
if (Build.VERSION.SDK_INT >= 29) {
|
|
367
|
-
background = ActivityCompat.checkSelfPermission(activity, Manifest.permission.ACCESS_BACKGROUND_LOCATION) == PackageManager.PERMISSION_GRANTED;
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
if (background) {
|
|
371
|
-
promise.resolve(WoosmapMessageAndKey.backgroundPermissionGrantedMessage);
|
|
372
|
-
} else if (foreground) {
|
|
373
|
-
promise.resolve(WoosmapMessageAndKey.foregroundPermissionGrantedMessage);
|
|
374
|
-
} else if (denied) {
|
|
375
|
-
promise.resolve(WoosmapMessageAndKey.deniedPermissionMessage);
|
|
376
|
-
} else {
|
|
377
|
-
promise.resolve(WoosmapMessageAndKey.unknownMessage);
|
|
378
|
-
}
|
|
379
|
-
} catch (Exception ex) {
|
|
380
|
-
promise.resolve(WoosmapMessageAndKey.unknownMessage);
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
/***
|
|
385
|
-
* Checks if the required location permissions are granted or not.
|
|
386
|
-
* Returns DENIED if no permissions are granted.
|
|
387
|
-
* Returns GRANTED_FOREGROUND if foreground location permission is granted.
|
|
388
|
-
* Returns GRANTED_BACKGROUND if background location permission is granted.
|
|
389
|
-
* Returns UNKNOWN if plugin is unable to determine or asking for permission without providing any permission.
|
|
390
|
-
*/
|
|
391
|
-
@ReactMethod
|
|
392
|
-
public void getPermissionsStatus(final Promise promise) {
|
|
393
|
-
providePermissionStatus(promise);
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
/***
|
|
397
|
-
* Checks if the required Bluetooth permissions are granted or not.
|
|
398
|
-
* Returns DENIED if no permissions are granted.
|
|
399
|
-
* Returns GRANTED if bluetooth permission is granted.
|
|
400
|
-
* Returns BACKGROUND_LOCATION_DENIED if background location permission is not granted.
|
|
401
|
-
*/
|
|
402
|
-
@ReactMethod
|
|
403
|
-
public void getBLEPermissionsStatus(final Promise promise){
|
|
404
|
-
provideBLEPermissionStatus(promise);
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
/***
|
|
408
|
-
* Check if the user has given location permission.
|
|
409
|
-
* @param isBackground Pass true if the background permission needs to be checked.
|
|
410
|
-
* @return boolean
|
|
411
|
-
*/
|
|
412
|
-
private boolean hasPermission(boolean isBackground) {
|
|
413
|
-
try {
|
|
414
|
-
Activity activity = getReactApplicationContext().getCurrentActivity();
|
|
415
|
-
if (activity == null) {
|
|
416
|
-
return false;
|
|
417
|
-
}
|
|
418
|
-
if (!isBackground) {
|
|
419
|
-
return ActivityCompat.checkSelfPermission(activity, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED;
|
|
420
|
-
}
|
|
421
|
-
if (isBackground && Build.VERSION.SDK_INT >= 29) {
|
|
422
|
-
return ActivityCompat.checkSelfPermission(activity, Manifest.permission.ACCESS_BACKGROUND_LOCATION) == PackageManager.PERMISSION_GRANTED;
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
} catch (Exception ex) {
|
|
426
|
-
Log.e(NAME, ex.toString());
|
|
427
|
-
}
|
|
428
|
-
return false;
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
@Override
|
|
433
|
-
public void onHostResume() {
|
|
434
|
-
if (woosmap != null) {
|
|
435
|
-
woosmap.onResume();
|
|
436
|
-
}
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
@Override
|
|
440
|
-
public void onHostPause() {
|
|
441
|
-
if (woosmap != null) {
|
|
442
|
-
woosmap.onPause();
|
|
443
|
-
}
|
|
444
|
-
}
|
|
445
|
-
|
|
446
|
-
@Override
|
|
447
|
-
public void onHostDestroy() {
|
|
448
|
-
if(profileReadyListener!=null){
|
|
449
|
-
woosmap.setProfileReadyListener(null);
|
|
450
|
-
profileReadyListener=null;
|
|
451
|
-
}
|
|
452
|
-
if (woosmap != null) {
|
|
453
|
-
woosmap.onDestroy();
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
}
|
|
457
|
-
|
|
458
|
-
/***
|
|
459
|
-
* Sets the Woosmap private API key for calling Woosmap APIs.
|
|
460
|
-
* @param data accepts Woosmap API key in a Readable array.
|
|
461
|
-
* @param promise React native callback context.
|
|
462
|
-
*/
|
|
463
|
-
// implemented in turbo (WoosmapGeofencingTurbo)
|
|
464
|
-
@Deprecated
|
|
465
|
-
@ReactMethod
|
|
466
|
-
public void setWoosmapApiKey(ReadableArray data, Promise promise) {
|
|
467
|
-
try {
|
|
468
|
-
if (isWoosmapInitialized()) {
|
|
469
|
-
String apiKey = "";
|
|
470
|
-
if (!data.isNull(0)) {
|
|
471
|
-
apiKey = data.getString(0);
|
|
472
|
-
}
|
|
473
|
-
if (!apiKey.isEmpty()) {
|
|
474
|
-
WoosmapSettings.privateKeyWoosmapAPI = apiKey;
|
|
475
|
-
promise.resolve(WoosmapMessageAndKey.successMessage);
|
|
476
|
-
} else {
|
|
477
|
-
promise.reject(WoosmapMessageAndKey.errorCode, WoosmapMessageAndKey.woosmapKeyNotProvide);
|
|
478
|
-
}
|
|
479
|
-
} else {
|
|
480
|
-
promise.reject(WoosmapMessageAndKey.errorCode, WoosmapMessageAndKey.woosmapNotInitialized);
|
|
481
|
-
}
|
|
482
|
-
|
|
483
|
-
} catch (Exception ex) {
|
|
484
|
-
promise.reject(WoosmapMessageAndKey.errorCode, ex.getMessage());
|
|
485
|
-
}
|
|
486
|
-
}
|
|
487
|
-
|
|
488
|
-
/***
|
|
489
|
-
* Starts Woosmap Geofencing tracking.
|
|
490
|
-
* @param data Accepts tracking profile. Value can be either liveTracking, passiveTracking or stopsTracking.
|
|
491
|
-
* @param promise React native callback context.
|
|
492
|
-
*/
|
|
493
|
-
@ReactMethod
|
|
494
|
-
public void startTracking(ReadableArray data, Promise promise) {
|
|
495
|
-
try {
|
|
496
|
-
if (isWoosmapInitialized()) {
|
|
497
|
-
if (data.isNull(0)) {
|
|
498
|
-
promise.reject(WoosmapMessageAndKey.errorCode, WoosmapMessageAndKey.trackingProfileNotProvided);
|
|
499
|
-
}
|
|
500
|
-
|
|
501
|
-
String trackingProfile = data.getString(0);
|
|
502
|
-
if (trackingProfile.equals(Woosmap.ConfigurationProfile.liveTracking) ||
|
|
503
|
-
trackingProfile.equals(Woosmap.ConfigurationProfile.passiveTracking) ||
|
|
504
|
-
trackingProfile.equals(Woosmap.ConfigurationProfile.optimalPassiveTracking) ||
|
|
505
|
-
trackingProfile.equals(Woosmap.ConfigurationProfile.beaconTracking) ||
|
|
506
|
-
trackingProfile.equals(Woosmap.ConfigurationProfile.visitsTracking)) {
|
|
507
|
-
woosmap.startTracking(trackingProfile);
|
|
508
|
-
promise.resolve(WoosmapMessageAndKey.successMessage);
|
|
509
|
-
} else {
|
|
510
|
-
promise.reject(WoosmapMessageAndKey.errorCode, WoosmapMessageAndKey.invalidProfileTrackingError);
|
|
511
|
-
}
|
|
512
|
-
} else {
|
|
513
|
-
promise.reject(WoosmapMessageAndKey.errorCode, WoosmapMessageAndKey.woosmapNotInitialized);
|
|
514
|
-
}
|
|
515
|
-
} catch (Exception ex) {
|
|
516
|
-
promise.reject(WoosmapMessageAndKey.errorCode, ex.getMessage());
|
|
517
|
-
}
|
|
518
|
-
}
|
|
519
|
-
|
|
520
|
-
/***
|
|
521
|
-
* Stops tracking
|
|
522
|
-
* @param promise React native callback context.
|
|
523
|
-
*/
|
|
524
|
-
@ReactMethod
|
|
525
|
-
public void stopTracking(Promise promise) {
|
|
526
|
-
try {
|
|
527
|
-
if (isWoosmapInitialized()) {
|
|
528
|
-
woosmap.stopTracking();
|
|
529
|
-
promise.resolve(WoosmapMessageAndKey.successMessage);
|
|
530
|
-
} else {
|
|
531
|
-
promise.reject(WoosmapMessageAndKey.errorCode, WoosmapMessageAndKey.woosmapNotInitialized);
|
|
532
|
-
}
|
|
533
|
-
|
|
534
|
-
} catch (Exception ex) {
|
|
535
|
-
promise.reject(WoosmapMessageAndKey.errorCode, ex.getMessage());
|
|
536
|
-
}
|
|
537
|
-
}
|
|
538
|
-
|
|
539
|
-
/***
|
|
540
|
-
* Add watch to woosmap location data.
|
|
541
|
-
* @param watchID Unique String value for location listener.
|
|
542
|
-
* @param promise React native callback context.
|
|
543
|
-
*/
|
|
544
|
-
@ReactMethod
|
|
545
|
-
public void watchLocation(String watchID, Promise promise) {
|
|
546
|
-
try {
|
|
547
|
-
if (isWoosmapInitialized()) {
|
|
548
|
-
if (locationReadyListener == null) {
|
|
549
|
-
locationReadyListener = new WoosLocationReadyListener(reactContext);
|
|
550
|
-
woosmap.setLocationReadyListener(locationReadyListener);
|
|
551
|
-
promise.resolve(watchID);
|
|
552
|
-
} else {
|
|
553
|
-
promise.reject(WoosmapMessageAndKey.errorCode, WoosmapMessageAndKey.locationWatchAlreadyStarted);
|
|
554
|
-
}
|
|
555
|
-
} else {
|
|
556
|
-
promise.reject(WoosmapMessageAndKey.errorCode, WoosmapMessageAndKey.woosmapNotInitialized);
|
|
557
|
-
}
|
|
558
|
-
} catch (Exception ex) {
|
|
559
|
-
promise.reject(WoosmapMessageAndKey.errorCode, ex.getMessage());
|
|
560
|
-
}
|
|
561
|
-
}
|
|
562
|
-
|
|
563
|
-
/***
|
|
564
|
-
* Clear woosmap location watch.
|
|
565
|
-
* @param watchID Unique String value for location listener.
|
|
566
|
-
* @param promise React native callback context.
|
|
567
|
-
*/
|
|
568
|
-
@ReactMethod
|
|
569
|
-
public void clearLocationWatch(String watchID, Promise promise) {
|
|
570
|
-
try {
|
|
571
|
-
if (locationReadyListener != null) {
|
|
572
|
-
woosmap.setLocationReadyListener(null);
|
|
573
|
-
locationReadyListener = null;
|
|
574
|
-
promise.resolve(watchID);
|
|
575
|
-
} else {
|
|
576
|
-
promise.reject(WoosmapMessageAndKey.errorCode, WoosmapMessageAndKey.locationWatchNotStarted);
|
|
577
|
-
}
|
|
578
|
-
} catch (Exception ex) {
|
|
579
|
-
promise.reject(WoosmapMessageAndKey.errorCode, ex.getMessage());
|
|
580
|
-
}
|
|
581
|
-
}
|
|
582
|
-
|
|
583
|
-
/***
|
|
584
|
-
* Sets Sales Force Marketing Cloud credentials.
|
|
585
|
-
* @param map accepts Sales Force Marketing Cloud credentials key in a ReadableMap.
|
|
586
|
-
* @param promise React native callback context.
|
|
587
|
-
*/
|
|
588
|
-
@ReactMethod
|
|
589
|
-
private void setSFMCCredentials(ReadableMap map, Promise promise) {
|
|
590
|
-
try {
|
|
591
|
-
if (isWoosmapInitialized()) {
|
|
592
|
-
if (!map.toHashMap().isEmpty()) {
|
|
593
|
-
HashMap<String, String> SFMCInfo = new HashMap<>();
|
|
594
|
-
String key;
|
|
595
|
-
if (!map.hasKey(WoosmapMessageAndKey.SMFCauthenticationBaseURIkey)) {
|
|
596
|
-
throw new Exception(WoosmapMessageAndKey.keyMissingMessage + ": " + WoosmapMessageAndKey.SMFCauthenticationBaseURIkey);
|
|
597
|
-
}
|
|
598
|
-
if (!map.hasKey(WoosmapMessageAndKey.SMFCrestBaseURIkey)) {
|
|
599
|
-
throw new Exception(WoosmapMessageAndKey.keyMissingMessage + ": " + WoosmapMessageAndKey.SMFCrestBaseURIkey);
|
|
600
|
-
}
|
|
601
|
-
if (!map.hasKey(WoosmapMessageAndKey.SMFCclient_idkey)) {
|
|
602
|
-
throw new Exception(WoosmapMessageAndKey.keyMissingMessage + ": " + WoosmapMessageAndKey.SMFCclient_idkey);
|
|
603
|
-
}
|
|
604
|
-
if (!map.hasKey(WoosmapMessageAndKey.SMFCclient_secretkey)) {
|
|
605
|
-
throw new Exception(WoosmapMessageAndKey.keyMissingMessage + ": " + WoosmapMessageAndKey.SMFCclient_secretkey);
|
|
606
|
-
}
|
|
607
|
-
if (!map.hasKey(WoosmapMessageAndKey.SMFCcontactKey)) {
|
|
608
|
-
throw new Exception(WoosmapMessageAndKey.keyMissingMessage + ": " + WoosmapMessageAndKey.SMFCcontactKey);
|
|
609
|
-
}
|
|
610
|
-
|
|
611
|
-
Iterator<String> keys = map.toHashMap().keySet().iterator();
|
|
612
|
-
|
|
613
|
-
while (keys.hasNext()) {
|
|
614
|
-
key = keys.next();
|
|
615
|
-
SFMCInfo.put(key, map.getString(key));
|
|
616
|
-
}
|
|
617
|
-
WoosmapSettings.SFMCCredentials = SFMCInfo;
|
|
618
|
-
promise.resolve(WoosmapMessageAndKey.successMessage);
|
|
619
|
-
} else {
|
|
620
|
-
promise.reject(WoosmapMessageAndKey.errorCode, WoosmapMessageAndKey.credentialEmptyMessage);
|
|
621
|
-
}
|
|
622
|
-
} else {
|
|
623
|
-
promise.reject(WoosmapMessageAndKey.errorCode, WoosmapMessageAndKey.woosmapNotInitialized);
|
|
624
|
-
}
|
|
625
|
-
|
|
626
|
-
} catch (Exception ex) {
|
|
627
|
-
promise.reject(WoosmapMessageAndKey.errorCode, ex.getMessage());
|
|
628
|
-
}
|
|
629
|
-
}
|
|
630
|
-
|
|
631
|
-
/***
|
|
632
|
-
* Add watch to woosmap region data.
|
|
633
|
-
* @param watchID Unique String value for region listener.
|
|
634
|
-
* @param promise React native callback context.
|
|
635
|
-
*/
|
|
636
|
-
@ReactMethod
|
|
637
|
-
public void watchRegions(String watchID, Promise promise) {
|
|
638
|
-
try {
|
|
639
|
-
if (isWoosmapInitialized()) {
|
|
640
|
-
if (!regionReadyListener.getIsRegionWatchEnabled()) {
|
|
641
|
-
regionReadyListener.setIsRegionWatchEnabled(true);
|
|
642
|
-
promise.resolve(watchID);
|
|
643
|
-
} else {
|
|
644
|
-
promise.reject(WoosmapMessageAndKey.errorCode, WoosmapMessageAndKey.regionWatchAlreadyStarted);
|
|
645
|
-
}
|
|
646
|
-
} else {
|
|
647
|
-
promise.reject(WoosmapMessageAndKey.errorCode, WoosmapMessageAndKey.woosmapNotInitialized);
|
|
648
|
-
}
|
|
649
|
-
} catch (Exception ex) {
|
|
650
|
-
promise.reject(WoosmapMessageAndKey.errorCode, ex.getMessage());
|
|
651
|
-
}
|
|
652
|
-
}
|
|
653
|
-
|
|
654
|
-
/***
|
|
655
|
-
* Clear woosmap region watch.
|
|
656
|
-
* @param watchID Unique String value for region listener.Which is getting
|
|
657
|
-
* @param promise React native callback context.
|
|
658
|
-
*/
|
|
659
|
-
|
|
660
|
-
@ReactMethod
|
|
661
|
-
public void clearRegionsWatch(String watchID, Promise promise) {
|
|
662
|
-
try {
|
|
663
|
-
if (regionReadyListener.getIsRegionWatchEnabled()) {
|
|
664
|
-
regionReadyListener.setIsRegionWatchEnabled(false);
|
|
665
|
-
promise.resolve(watchID);
|
|
666
|
-
} else {
|
|
667
|
-
promise.reject(WoosmapMessageAndKey.errorCode, WoosmapMessageAndKey.regionWatchNotStarted);
|
|
668
|
-
}
|
|
669
|
-
} catch (Exception ex) {
|
|
670
|
-
promise.reject(WoosmapMessageAndKey.errorCode, ex.getMessage());
|
|
671
|
-
}
|
|
672
|
-
}
|
|
673
|
-
|
|
674
|
-
/***
|
|
675
|
-
* Set radius of POI
|
|
676
|
-
* @param radius A string containing POI radius value in number,string,double format.
|
|
677
|
-
* @param promise React native callback context.
|
|
678
|
-
*/
|
|
679
|
-
// implemented in turbo (WoosmapGeofencingTurbo)
|
|
680
|
-
@Deprecated
|
|
681
|
-
@ReactMethod
|
|
682
|
-
public void setPoiRadius(String radius, Promise promise) {
|
|
683
|
-
try {
|
|
684
|
-
if (isWoosmapInitialized()) {
|
|
685
|
-
if (radius.isEmpty()) {
|
|
686
|
-
throw new Exception(WoosmapMessageAndKey.radiusEmptyMessage);
|
|
687
|
-
}
|
|
688
|
-
if (onlyContainsNumbers(radius)) {
|
|
689
|
-
WoosmapSettings.poiRadius = Integer.parseInt(radius);
|
|
690
|
-
promise.resolve(WoosmapMessageAndKey.successMessage);
|
|
691
|
-
} else if (onlyContainsDouble(radius)) {
|
|
692
|
-
double d = Double.parseDouble(radius);
|
|
693
|
-
WoosmapSettings.poiRadius = (int) Math.round(d);
|
|
694
|
-
promise.resolve(WoosmapMessageAndKey.successMessage);
|
|
695
|
-
} else {
|
|
696
|
-
WoosmapSettings.poiRadiusNameFromResponse = radius;
|
|
697
|
-
promise.resolve(WoosmapMessageAndKey.successMessage);
|
|
698
|
-
}
|
|
699
|
-
} else {
|
|
700
|
-
promise.reject(WoosmapMessageAndKey.errorCode, WoosmapMessageAndKey.woosmapNotInitialized);
|
|
701
|
-
}
|
|
702
|
-
} catch (Exception ex) {
|
|
703
|
-
promise.reject(WoosmapMessageAndKey.errorCode, ex.getMessage());
|
|
704
|
-
}
|
|
705
|
-
}
|
|
706
|
-
|
|
707
|
-
/***
|
|
708
|
-
* Its check string is integer or not.
|
|
709
|
-
* @param text string for checking if it contains only number or not.
|
|
710
|
-
* @return true boolean value if string is only number else false.
|
|
711
|
-
*/
|
|
712
|
-
private boolean onlyContainsNumbers(String text) {
|
|
713
|
-
try {
|
|
714
|
-
Long.parseLong(text);
|
|
715
|
-
return true;
|
|
716
|
-
} catch (NumberFormatException ex) {
|
|
717
|
-
return false;
|
|
718
|
-
}
|
|
719
|
-
}
|
|
720
|
-
|
|
721
|
-
/***
|
|
722
|
-
* Its check string is double or not.
|
|
723
|
-
* @param text String for checking if it contain double or not.
|
|
724
|
-
* @return true boolean value if string is double else false.
|
|
725
|
-
*/
|
|
726
|
-
private boolean onlyContainsDouble(String text) {
|
|
727
|
-
try {
|
|
728
|
-
Double.parseDouble(text);
|
|
729
|
-
return true;
|
|
730
|
-
} catch (NumberFormatException ex) {
|
|
731
|
-
return false;
|
|
732
|
-
}
|
|
733
|
-
}
|
|
734
|
-
|
|
735
|
-
/**
|
|
736
|
-
* Adds/updates a region in DB as well as geofence collection
|
|
737
|
-
* @param map Readable map with region detail.
|
|
738
|
-
* @param promise React native callback context.
|
|
739
|
-
*/
|
|
740
|
-
// implemented in turbo (WoosmapGeofencingTurbo)
|
|
741
|
-
@Deprecated
|
|
742
|
-
@RequiresApi(api = Build.VERSION_CODES.N)
|
|
743
|
-
@ReactMethod
|
|
744
|
-
public void addRegion(ReadableMap map, Promise promise) {
|
|
745
|
-
try {
|
|
746
|
-
Region region;
|
|
747
|
-
if (isWoosmapInitialized()) {
|
|
748
|
-
if (map.toHashMap().isEmpty()) {
|
|
749
|
-
throw new Exception(WoosmapMessageAndKey.regionInfoEmptyMessage);
|
|
750
|
-
}
|
|
751
|
-
region = new Region();
|
|
752
|
-
region.identifier = map.getString("regionId");
|
|
753
|
-
region.idStore = map.hasKey("idStore") ? map.getString("idStore") : "";
|
|
754
|
-
region.lat = map.getDouble("lat");
|
|
755
|
-
region.lng = map.getDouble("lng");
|
|
756
|
-
region.type = map.hasKey("type") ? map.getString("type") : "";
|
|
757
|
-
region.radius = map.getDouble("radius");
|
|
758
|
-
|
|
759
|
-
WoosmapTask.getInstance(reactContext).addRegion(region, promise);
|
|
760
|
-
} else {
|
|
761
|
-
promise.reject(WoosmapMessageAndKey.errorCode, WoosmapMessageAndKey.woosmapNotInitialized);
|
|
762
|
-
}
|
|
763
|
-
} catch (Exception ex) {
|
|
764
|
-
promise.reject(WoosmapMessageAndKey.errorCode, ex.getMessage());
|
|
765
|
-
}
|
|
766
|
-
}
|
|
767
|
-
|
|
768
|
-
/**
|
|
769
|
-
* Gets saved region from the database.
|
|
770
|
-
* @param regionid A string unique value for region.
|
|
771
|
-
* @param promise React native callback context.
|
|
772
|
-
*/
|
|
773
|
-
// implemented in turbo (WoosmapGeofencingTurbo)
|
|
774
|
-
@Deprecated
|
|
775
|
-
@RequiresApi(api = Build.VERSION_CODES.N)
|
|
776
|
-
@ReactMethod
|
|
777
|
-
public void getRegions(String regionid, Promise promise){
|
|
778
|
-
try{
|
|
779
|
-
if (isWoosmapInitialized()){
|
|
780
|
-
if(!regionid.isEmpty()){
|
|
781
|
-
WoosmapTask.getInstance(reactContext).enqueGetRegionsRequest(regionid,promise);
|
|
782
|
-
|
|
783
|
-
}else {
|
|
784
|
-
promise.reject(WoosmapMessageAndKey.errorCode,WoosmapMessageAndKey.requiredRegionid);
|
|
785
|
-
}
|
|
786
|
-
|
|
787
|
-
}else {
|
|
788
|
-
promise.reject(WoosmapMessageAndKey.errorCode,WoosmapMessageAndKey.woosmapNotInitialized);
|
|
789
|
-
}
|
|
790
|
-
}
|
|
791
|
-
catch (Exception ex){
|
|
792
|
-
promise.reject(WoosmapMessageAndKey.errorCode,ex.getMessage());
|
|
793
|
-
}
|
|
794
|
-
}
|
|
795
|
-
|
|
796
|
-
/**
|
|
797
|
-
* Gets all saved region from the database.
|
|
798
|
-
* @param promise React native callback context.
|
|
799
|
-
*/
|
|
800
|
-
// implemented in turbo (WoosmapGeofencingTurbo — getRegions handles all + single)
|
|
801
|
-
@Deprecated
|
|
802
|
-
@RequiresApi(api = Build.VERSION_CODES.N)
|
|
803
|
-
@ReactMethod
|
|
804
|
-
public void getAllRegions(Promise promise){
|
|
805
|
-
try{
|
|
806
|
-
if (isWoosmapInitialized()){
|
|
807
|
-
WoosmapTask.getInstance(reactContext).enqueGetRegionsRequest(promise);
|
|
808
|
-
}else {
|
|
809
|
-
promise.reject(WoosmapMessageAndKey.errorCode,WoosmapMessageAndKey.woosmapNotInitialized);
|
|
810
|
-
}
|
|
811
|
-
}
|
|
812
|
-
catch (Exception ex){
|
|
813
|
-
promise.reject(WoosmapMessageAndKey.errorCode,ex.getMessage());
|
|
814
|
-
}
|
|
815
|
-
}
|
|
816
|
-
|
|
817
|
-
/***
|
|
818
|
-
* Removes the region by given region id.
|
|
819
|
-
* @param regionid A unique string region id which is to be removed.
|
|
820
|
-
* @param promise React native callback context.
|
|
821
|
-
*/
|
|
822
|
-
// implemented in turbo (WoosmapGeofencingTurbo)
|
|
823
|
-
@Deprecated
|
|
824
|
-
@RequiresApi(api = Build.VERSION_CODES.N)
|
|
825
|
-
@ReactMethod
|
|
826
|
-
private void removeRegion(String regionid, Promise promise){
|
|
827
|
-
try{
|
|
828
|
-
if (isWoosmapInitialized()){
|
|
829
|
-
if(!regionid.isEmpty()){
|
|
830
|
-
WoosmapTask.getInstance(reactContext).removeRegion(regionid,promise);
|
|
831
|
-
}else {
|
|
832
|
-
promise.reject(WoosmapMessageAndKey.errorCode,WoosmapMessageAndKey.requiredRegionid);
|
|
833
|
-
}
|
|
834
|
-
}else {
|
|
835
|
-
promise.reject(WoosmapMessageAndKey.errorCode,WoosmapMessageAndKey.woosmapNotInitialized);
|
|
836
|
-
}
|
|
837
|
-
}
|
|
838
|
-
catch (Exception ex){
|
|
839
|
-
promise.reject(WoosmapMessageAndKey.errorCode,ex.getMessage());
|
|
840
|
-
}
|
|
841
|
-
}
|
|
842
|
-
|
|
843
|
-
/***
|
|
844
|
-
* Removes all region from saved database.
|
|
845
|
-
* @param promise React native callback context.
|
|
846
|
-
*/
|
|
847
|
-
// implemented in turbo (WoosmapGeofencingTurbo)
|
|
848
|
-
@Deprecated
|
|
849
|
-
@RequiresApi(api = Build.VERSION_CODES.N)
|
|
850
|
-
@ReactMethod
|
|
851
|
-
private void removeAllRegions(Promise promise){
|
|
852
|
-
try{
|
|
853
|
-
if (isWoosmapInitialized()){
|
|
854
|
-
WoosmapTask.getInstance(reactContext).removeRegion("",promise);
|
|
855
|
-
}else {
|
|
856
|
-
promise.reject(WoosmapMessageAndKey.errorCode,WoosmapMessageAndKey.woosmapNotInitialized);
|
|
857
|
-
}
|
|
858
|
-
}
|
|
859
|
-
catch (Exception ex){
|
|
860
|
-
promise.reject(WoosmapMessageAndKey.errorCode,ex.getMessage());
|
|
861
|
-
}
|
|
862
|
-
}
|
|
863
|
-
|
|
864
|
-
/***
|
|
865
|
-
* Removes all POI from saved database.
|
|
866
|
-
* @param promise React native callback context.
|
|
867
|
-
*/
|
|
868
|
-
@RequiresApi(api = Build.VERSION_CODES.N)
|
|
869
|
-
@ReactMethod
|
|
870
|
-
private void removeAllPois(Promise promise){
|
|
871
|
-
try{
|
|
872
|
-
if (isWoosmapInitialized()){
|
|
873
|
-
WoosmapTask.getInstance(reactContext).removeAllPois(promise);
|
|
874
|
-
}else {
|
|
875
|
-
promise.reject(WoosmapMessageAndKey.errorCode,WoosmapMessageAndKey.woosmapNotInitialized);
|
|
876
|
-
}
|
|
877
|
-
}
|
|
878
|
-
catch (Exception ex){
|
|
879
|
-
promise.reject(WoosmapMessageAndKey.errorCode,ex.getMessage());
|
|
880
|
-
}
|
|
881
|
-
}
|
|
882
|
-
|
|
883
|
-
/**
|
|
884
|
-
* Gets all saved POIs from the database.
|
|
885
|
-
* @param promise React native callback context.
|
|
886
|
-
*/
|
|
887
|
-
@RequiresApi(api = Build.VERSION_CODES.N)
|
|
888
|
-
@ReactMethod
|
|
889
|
-
public void getAllPois(Promise promise){
|
|
890
|
-
try{
|
|
891
|
-
if (isWoosmapInitialized()){
|
|
892
|
-
WoosmapTask.getInstance(reactContext).enqueGetAllPoiRequest(promise);
|
|
893
|
-
}else {
|
|
894
|
-
promise.reject(WoosmapMessageAndKey.errorCode,WoosmapMessageAndKey.woosmapNotInitialized);
|
|
895
|
-
}
|
|
896
|
-
}
|
|
897
|
-
catch (Exception ex){
|
|
898
|
-
promise.reject(WoosmapMessageAndKey.errorCode,ex.getMessage());
|
|
899
|
-
}
|
|
900
|
-
}
|
|
901
|
-
|
|
902
|
-
/**
|
|
903
|
-
* Gets saved POI info from the database.
|
|
904
|
-
* @param poiID A unique string value of locationID/StoreID for POI which user want to fetch.
|
|
905
|
-
* @param promise React native callback context.
|
|
906
|
-
*/
|
|
907
|
-
@RequiresApi(api = Build.VERSION_CODES.N)
|
|
908
|
-
@ReactMethod
|
|
909
|
-
public void getPoi(String poiID, Promise promise){
|
|
910
|
-
try{
|
|
911
|
-
if (isWoosmapInitialized()){
|
|
912
|
-
if(!poiID.isEmpty()){
|
|
913
|
-
WoosmapTask.getInstance(reactContext).enqueGetPOIRequest(poiID,promise);
|
|
914
|
-
|
|
915
|
-
}else {
|
|
916
|
-
promise.reject(WoosmapMessageAndKey.errorCode,WoosmapMessageAndKey.requiredLocationid);
|
|
917
|
-
}
|
|
918
|
-
|
|
919
|
-
}else {
|
|
920
|
-
promise.reject(WoosmapMessageAndKey.errorCode,WoosmapMessageAndKey.woosmapNotInitialized);
|
|
921
|
-
}
|
|
922
|
-
}
|
|
923
|
-
catch (Exception ex){
|
|
924
|
-
promise.reject(WoosmapMessageAndKey.errorCode,ex.getMessage());
|
|
925
|
-
}
|
|
926
|
-
}
|
|
927
|
-
|
|
928
|
-
/**
|
|
929
|
-
* Gets saved location from the database.
|
|
930
|
-
* @param locationid A string unique value for location.
|
|
931
|
-
* @param promise React native callback context.
|
|
932
|
-
*/
|
|
933
|
-
@RequiresApi(api = Build.VERSION_CODES.N)
|
|
934
|
-
@ReactMethod
|
|
935
|
-
private void getLocation(String locationid, Promise promise){
|
|
936
|
-
try{
|
|
937
|
-
if (isWoosmapInitialized()){
|
|
938
|
-
if(!locationid.isEmpty()){
|
|
939
|
-
WoosmapTask.getInstance(reactContext).enqueueGetLocationRequest(locationid,promise);
|
|
940
|
-
|
|
941
|
-
}else {
|
|
942
|
-
promise.reject(WoosmapMessageAndKey.errorCode,WoosmapMessageAndKey.requiredLocationID);
|
|
943
|
-
}
|
|
944
|
-
|
|
945
|
-
}else {
|
|
946
|
-
promise.reject(WoosmapMessageAndKey.errorCode,WoosmapMessageAndKey.woosmapNotInitialized);
|
|
947
|
-
}
|
|
948
|
-
}
|
|
949
|
-
catch (Exception ex){
|
|
950
|
-
promise.reject(WoosmapMessageAndKey.errorCode,ex.getMessage());
|
|
951
|
-
}
|
|
952
|
-
}
|
|
953
|
-
|
|
954
|
-
/**
|
|
955
|
-
* Gets all saved location from the database.
|
|
956
|
-
* @param promise React native callback context.
|
|
957
|
-
*/
|
|
958
|
-
@RequiresApi(api = Build.VERSION_CODES.N)
|
|
959
|
-
@ReactMethod
|
|
960
|
-
private void getAllLocations(Promise promise){
|
|
961
|
-
try{
|
|
962
|
-
if (isWoosmapInitialized()){
|
|
963
|
-
WoosmapTask.getInstance(reactContext).enqueueGetLocationRequest(promise);
|
|
964
|
-
}else {
|
|
965
|
-
promise.reject(WoosmapMessageAndKey.errorCode,WoosmapMessageAndKey.woosmapNotInitialized);
|
|
966
|
-
}
|
|
967
|
-
}
|
|
968
|
-
catch (Exception ex){
|
|
969
|
-
promise.reject(WoosmapMessageAndKey.errorCode,ex.getMessage());
|
|
970
|
-
}
|
|
971
|
-
}
|
|
972
|
-
|
|
973
|
-
/***
|
|
974
|
-
* Removes all location from saved database.
|
|
975
|
-
* @param promise React native callback context.
|
|
976
|
-
*/
|
|
977
|
-
@RequiresApi(api = Build.VERSION_CODES.N)
|
|
978
|
-
@ReactMethod
|
|
979
|
-
private void removeAllLocations(Promise promise){
|
|
980
|
-
try{
|
|
981
|
-
if (isWoosmapInitialized()){
|
|
982
|
-
WoosmapTask.getInstance(reactContext).removeAllLocation(promise);
|
|
983
|
-
}else {
|
|
984
|
-
promise.reject(WoosmapMessageAndKey.errorCode,WoosmapMessageAndKey.woosmapNotInitialized);
|
|
985
|
-
}
|
|
986
|
-
}
|
|
987
|
-
catch (Exception ex){
|
|
988
|
-
promise.reject(WoosmapMessageAndKey.errorCode,ex.getMessage());
|
|
989
|
-
}
|
|
990
|
-
}
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
private Woosmap.ProfileReadyListener profileReadyListener;
|
|
994
|
-
|
|
995
|
-
/***
|
|
996
|
-
* Set custom tracking profile if preset tracking profile don't match your requirement.
|
|
997
|
-
* @param mode A string value which can be local or external.
|
|
998
|
-
* @param source Location of file in json format.
|
|
999
|
-
* 1.Local mode put json file in assets folder and provide file name as source.
|
|
1000
|
-
* 2.External mode put json file in server and provide file url as source.
|
|
1001
|
-
* @param promise React native callback context.
|
|
1002
|
-
*/
|
|
1003
|
-
@ReactMethod
|
|
1004
|
-
public void startCustomTracking(String mode,String source, Promise promise){
|
|
1005
|
-
try{
|
|
1006
|
-
if (isWoosmapInitialized()){
|
|
1007
|
-
profileReadyListener= (status, errors) -> {
|
|
1008
|
-
try {
|
|
1009
|
-
if(status){
|
|
1010
|
-
promise.resolve(WoosmapMessageAndKey.successMessage);
|
|
1011
|
-
}else {
|
|
1012
|
-
promise.reject(WoosmapMessageAndKey.errorCode,errors.get(0));
|
|
1013
|
-
}
|
|
1014
|
-
}catch (Exception ex){
|
|
1015
|
-
promise.reject(WoosmapMessageAndKey.errorCode,ex.getMessage());
|
|
1016
|
-
}
|
|
1017
|
-
};
|
|
1018
|
-
woosmap.setProfileReadyListener(profileReadyListener);
|
|
1019
|
-
if(mode.equalsIgnoreCase(WoosmapMessageAndKey.localMode)||mode.equalsIgnoreCase(WoosmapMessageAndKey.externalMode)){
|
|
1020
|
-
woosmap.startCustomTracking(source);
|
|
1021
|
-
}else {
|
|
1022
|
-
promise.reject(WoosmapMessageAndKey.errorCode,WoosmapMessageAndKey.invalidProfileSourceType);
|
|
1023
|
-
}
|
|
1024
|
-
}else {
|
|
1025
|
-
promise.reject(WoosmapMessageAndKey.errorCode,WoosmapMessageAndKey.woosmapNotInitialized);
|
|
1026
|
-
}
|
|
1027
|
-
}
|
|
1028
|
-
catch (Exception ex){
|
|
1029
|
-
promise.reject(WoosmapMessageAndKey.errorCode,ex.getMessage());
|
|
1030
|
-
}
|
|
1031
|
-
}
|
|
1032
|
-
|
|
1033
|
-
/***
|
|
1034
|
-
* Fetches all indoor beacons from the local database.
|
|
1035
|
-
* @param promise React native callback context.
|
|
1036
|
-
*/
|
|
1037
|
-
@RequiresApi(api = Build.VERSION_CODES.N)
|
|
1038
|
-
@ReactMethod
|
|
1039
|
-
public void getAllIndoorBeacons(final Promise promise){
|
|
1040
|
-
getIndoorBeacons(null, promise);
|
|
1041
|
-
}
|
|
1042
|
-
|
|
1043
|
-
/***
|
|
1044
|
-
* Fetches all indoor beacons from the local database for the given venue id.
|
|
1045
|
-
* @param venueId The venue id
|
|
1046
|
-
* @param promise React native callback context.
|
|
1047
|
-
*/
|
|
1048
|
-
@RequiresApi(api = Build.VERSION_CODES.N)
|
|
1049
|
-
@ReactMethod
|
|
1050
|
-
public void getIndoorBeacons(final String venueId, final Promise promise){
|
|
1051
|
-
try{
|
|
1052
|
-
if (isWoosmapInitialized()){
|
|
1053
|
-
if (venueId != null && venueId.isEmpty()){
|
|
1054
|
-
promise.reject(WoosmapMessageAndKey.errorCode,WoosmapMessageAndKey.requiredVenueId);
|
|
1055
|
-
}
|
|
1056
|
-
else{
|
|
1057
|
-
WoosmapTask.getInstance(reactContext).enqueueGetIndoorBeaconRequest(venueId,promise);
|
|
1058
|
-
}
|
|
1059
|
-
}else {
|
|
1060
|
-
promise.reject(WoosmapMessageAndKey.errorCode,WoosmapMessageAndKey.woosmapNotInitialized);
|
|
1061
|
-
}
|
|
1062
|
-
}
|
|
1063
|
-
catch (Exception ex){
|
|
1064
|
-
promise.reject(WoosmapMessageAndKey.errorCode,ex.getMessage());
|
|
1065
|
-
}
|
|
1066
|
-
}
|
|
1067
|
-
|
|
1068
|
-
/***
|
|
1069
|
-
* Removes all indoor beacons from the database
|
|
1070
|
-
*/
|
|
1071
|
-
@RequiresApi(api = Build.VERSION_CODES.N)
|
|
1072
|
-
@ReactMethod
|
|
1073
|
-
public void removeIndoorBeacons(final Promise promise){
|
|
1074
|
-
try{
|
|
1075
|
-
if (isWoosmapInitialized()){
|
|
1076
|
-
WoosmapTask.getInstance(reactContext).removeAllBeacons(promise);
|
|
1077
|
-
}else {
|
|
1078
|
-
promise.reject(WoosmapMessageAndKey.errorCode,WoosmapMessageAndKey.woosmapNotInitialized);
|
|
1079
|
-
}
|
|
1080
|
-
}
|
|
1081
|
-
catch (Exception ex){
|
|
1082
|
-
promise.reject(WoosmapMessageAndKey.errorCode,ex.getMessage());
|
|
1083
|
-
}
|
|
1084
|
-
}
|
|
1085
|
-
|
|
1086
|
-
@ReactMethod
|
|
1087
|
-
public void addListener(String eventName) {
|
|
1088
|
-
|
|
1089
|
-
}
|
|
1090
|
-
|
|
1091
|
-
@ReactMethod
|
|
1092
|
-
public void removeListeners(Integer count) {
|
|
1093
|
-
|
|
1094
|
-
}
|
|
1095
|
-
|
|
1096
|
-
@ReactMethod
|
|
1097
|
-
public void refreshPois(final Promise promise){
|
|
1098
|
-
if (isWoosmapInitialized()) {
|
|
1099
|
-
woosmap.refreshPOIs(new Woosmap.POIRefreshCallback() {
|
|
1100
|
-
@Override
|
|
1101
|
-
public void onPOIsRefreshed() {
|
|
1102
|
-
promise.resolve(WoosmapMessageAndKey.successMessage);
|
|
1103
|
-
}
|
|
1104
|
-
|
|
1105
|
-
@Override
|
|
1106
|
-
public void onError(String error) {
|
|
1107
|
-
promise.reject(new Exception(error));
|
|
1108
|
-
}
|
|
1109
|
-
});
|
|
1110
|
-
} else {
|
|
1111
|
-
promise.reject(WoosmapMessageAndKey.errorCode, WoosmapMessageAndKey.woosmapNotInitialized);
|
|
1112
|
-
}
|
|
1113
|
-
}
|
|
1114
|
-
|
|
1115
|
-
/**
|
|
1116
|
-
* Provide status of notification permission / enablement.
|
|
1117
|
-
* Resolves:
|
|
1118
|
-
* - WoosmapMessageAndKey.notificationPermissionGrantedMessage if notifications are enabled (and POST_NOTIFICATIONS granted on API 33+)
|
|
1119
|
-
* - WoosmapMessageAndKey.notificationPermissionDeniedMessage if disabled/denied
|
|
1120
|
-
* - WoosmapMessageAndKey.unknownMessage if undetermined (e.g., no activity)
|
|
1121
|
-
*/
|
|
1122
|
-
private void provideNotificationPermissionStatus(final Promise promise) {
|
|
1123
|
-
if (promise == null) return;
|
|
1124
|
-
|
|
1125
|
-
Activity activity = getReactApplicationContext().getCurrentActivity();
|
|
1126
|
-
if (activity == null) {
|
|
1127
|
-
promise.resolve(WoosmapMessageAndKey.unknownMessage);
|
|
1128
|
-
return;
|
|
1129
|
-
}
|
|
1130
|
-
|
|
1131
|
-
boolean enabled = NotificationManagerCompat.from(activity).areNotificationsEnabled();
|
|
1132
|
-
|
|
1133
|
-
if (Build.VERSION.SDK_INT >= 33) {
|
|
1134
|
-
boolean granted = ActivityCompat.checkSelfPermission(activity, Manifest.permission.POST_NOTIFICATIONS)
|
|
1135
|
-
== PackageManager.PERMISSION_GRANTED;
|
|
1136
|
-
|
|
1137
|
-
if (enabled && granted) {
|
|
1138
|
-
promise.resolve(WoosmapMessageAndKey.grantedPermissionMessage);
|
|
1139
|
-
} else {
|
|
1140
|
-
promise.resolve(WoosmapMessageAndKey.deniedPermissionMessage);
|
|
1141
|
-
}
|
|
1142
|
-
} else {
|
|
1143
|
-
// On < 33, runtime permission doesn't exist; app-level enablement is what matters.
|
|
1144
|
-
if (enabled) {
|
|
1145
|
-
promise.resolve(WoosmapMessageAndKey.grantedPermissionMessage);
|
|
1146
|
-
} else {
|
|
1147
|
-
promise.resolve(WoosmapMessageAndKey.deniedPermissionMessage);
|
|
1148
|
-
}
|
|
1149
|
-
}
|
|
1150
|
-
}
|
|
1151
|
-
|
|
1152
|
-
/***
|
|
1153
|
-
* Checks notification permission / enablement status.
|
|
1154
|
-
* Returns GRANTED / DENIED / UNKNOWN (strings via WoosmapMessageAndKey).
|
|
1155
|
-
*/
|
|
1156
|
-
@ReactMethod
|
|
1157
|
-
public void getNotificationPermissionsStatus(final Promise promise) {
|
|
1158
|
-
try {
|
|
1159
|
-
provideNotificationPermissionStatus(promise);
|
|
1160
|
-
} catch (Exception ex) {
|
|
1161
|
-
promise.resolve(WoosmapMessageAndKey.unknownMessage);
|
|
1162
|
-
}
|
|
1163
|
-
}
|
|
1164
|
-
|
|
1165
|
-
/***
|
|
1166
|
-
* Requests notification permission (Android 13+, API 33).
|
|
1167
|
-
* On <33 there is no runtime permission; resolves based on enablement state.
|
|
1168
|
-
*/
|
|
1169
|
-
@ReactMethod
|
|
1170
|
-
public void requestNotificationPermissions(final Promise promise) {
|
|
1171
|
-
try {
|
|
1172
|
-
Activity activity = getReactApplicationContext().getCurrentActivity();
|
|
1173
|
-
if (activity == null) {
|
|
1174
|
-
promise.resolve(WoosmapMessageAndKey.unknownMessage);
|
|
1175
|
-
return;
|
|
1176
|
-
}
|
|
1177
|
-
|
|
1178
|
-
if (Build.VERSION.SDK_INT >= 33) {
|
|
1179
|
-
boolean granted = ActivityCompat.checkSelfPermission(activity, Manifest.permission.POST_NOTIFICATIONS)
|
|
1180
|
-
== PackageManager.PERMISSION_GRANTED;
|
|
1181
|
-
|
|
1182
|
-
if (granted && NotificationManagerCompat.from(activity).areNotificationsEnabled()) {
|
|
1183
|
-
// Already allowed & enabled
|
|
1184
|
-
promise.resolve(WoosmapMessageAndKey.grantedPermissionMessage);
|
|
1185
|
-
return;
|
|
1186
|
-
}
|
|
1187
|
-
|
|
1188
|
-
// Ask for POST_NOTIFICATIONS
|
|
1189
|
-
mNotificationPermissionsRequestPromise = promise;
|
|
1190
|
-
((PermissionAwareActivity) activity).requestPermissions(
|
|
1191
|
-
new String[]{ Manifest.permission.POST_NOTIFICATIONS },
|
|
1192
|
-
NOTIF_PERMISSIONS_REQUEST_CODE,
|
|
1193
|
-
this
|
|
1194
|
-
);
|
|
1195
|
-
} else {
|
|
1196
|
-
// No runtime permission; just report current enablement state.
|
|
1197
|
-
provideNotificationPermissionStatus(promise);
|
|
1198
|
-
}
|
|
1199
|
-
} catch (Exception ex) {
|
|
1200
|
-
promise.reject(WoosmapMessageAndKey.errorCode, ex.getMessage(), ex);
|
|
1201
|
-
}
|
|
1202
|
-
}
|
|
1203
|
-
|
|
1204
|
-
}
|