@woosmap/react-native-plugin-geofencing 0.1.2
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/LICENSE +21 -0
- package/README.md +340 -0
- package/android/.gradle/7.1.1/dependencies-accessors/dependencies-accessors.lock +0 -0
- package/android/.gradle/7.1.1/dependencies-accessors/gc.properties +0 -0
- package/android/.gradle/7.1.1/executionHistory/executionHistory.lock +0 -0
- package/android/.gradle/7.1.1/fileChanges/last-build.bin +0 -0
- package/android/.gradle/7.1.1/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/7.1.1/gc.properties +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +2 -0
- package/android/.gradle/checksums/checksums.lock +0 -0
- package/android/.gradle/checksums/md5-checksums.bin +0 -0
- package/android/.gradle/checksums/sha1-checksums.bin +0 -0
- package/android/.gradle/vcs-1/gc.properties +0 -0
- package/android/build.gradle +60 -0
- package/android/src/main/AndroidManifest.xml +4 -0
- package/android/src/main/java/com/reactnativeplugingeofencing/PluginGeofencingModule.java +365 -0
- package/android/src/main/java/com/reactnativeplugingeofencing/PluginGeofencingPackage.java +28 -0
- package/android/src/main/java/com/reactnativeplugingeofencing/WoosLocationReadyListener.java +38 -0
- package/android/src/main/java/com/reactnativeplugingeofencing/WoosmapMessageAndKey.java +36 -0
- package/android/src/main/java/com/reactnativeplugingeofencing/WoosmapUtil.java +34 -0
- package/ios/AirshipEvents.swift +73 -0
- package/ios/DataDistance.swift +61 -0
- package/ios/DataLocation.swift +36 -0
- package/ios/DataPOI.swift +38 -0
- package/ios/DataRegion.swift +78 -0
- package/ios/DataVisit.swift +30 -0
- package/ios/DataZOI.swift +22 -0
- package/ios/MarketingCloudEvents.swift +64 -0
- package/ios/MockDataVisit.swift +167 -0
- package/ios/PluginGeofencing-Bridging-Header.h +3 -0
- package/ios/PluginGeofencing.m +62 -0
- package/ios/PluginGeofencing.swift +688 -0
- package/ios/PluginGeofencing.xcodeproj/project.pbxproj +293 -0
- package/ios/WoosmapGeofenceMessage.swift +40 -0
- package/ios/WoosmapGeofenceService.swift +474 -0
- package/ios/WoosmapGeofencingPlugin.xcodeproj/project.xcworkspace/contents.xcworkspacedata +4 -0
- package/ios/WoosmapGeofencingPlugin.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/ios/WoosmapGeofencingPlugin.xcodeproj/project.xcworkspace/xcuserdata/saturn.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/WoosmapGeofencingPlugin.xcodeproj/xcuserdata/saturn.xcuserdatad/xcschemes/xcschememanagement.plist +14 -0
- package/lib/commonjs/Airship.js +35 -0
- package/lib/commonjs/Airship.js.map +1 -0
- package/lib/commonjs/Location.js +54 -0
- package/lib/commonjs/Location.js.map +1 -0
- package/lib/commonjs/MarketingCloud.js +35 -0
- package/lib/commonjs/MarketingCloud.js.map +1 -0
- package/lib/commonjs/Poi.js +96 -0
- package/lib/commonjs/Poi.js.map +1 -0
- package/lib/commonjs/Region.js +62 -0
- package/lib/commonjs/Region.js.map +1 -0
- package/lib/commonjs/Visit.js +50 -0
- package/lib/commonjs/Visit.js.map +1 -0
- package/lib/commonjs/Zoi.js +97 -0
- package/lib/commonjs/Zoi.js.map +1 -0
- package/lib/commonjs/index.js +276 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/module/Airship.js +33 -0
- package/lib/module/Airship.js.map +1 -0
- package/lib/module/Location.js +46 -0
- package/lib/module/Location.js.map +1 -0
- package/lib/module/MarketingCloud.js +33 -0
- package/lib/module/MarketingCloud.js.map +1 -0
- package/lib/module/Poi.js +94 -0
- package/lib/module/Poi.js.map +1 -0
- package/lib/module/Region.js +54 -0
- package/lib/module/Region.js.map +1 -0
- package/lib/module/Visit.js +48 -0
- package/lib/module/Visit.js.map +1 -0
- package/lib/module/Zoi.js +95 -0
- package/lib/module/Zoi.js.map +1 -0
- package/lib/module/index.js +261 -0
- package/lib/module/index.js.map +1 -0
- package/lib/typescript/Airship.d.ts +18 -0
- package/lib/typescript/Location.d.ts +26 -0
- package/lib/typescript/MarketingCloud.d.ts +18 -0
- package/lib/typescript/Poi.d.ts +48 -0
- package/lib/typescript/Region.d.ts +30 -0
- package/lib/typescript/Visit.d.ts +25 -0
- package/lib/typescript/Zoi.d.ts +49 -0
- package/lib/typescript/index.d.ts +97 -0
- package/package.json +150 -0
- package/react-native-plugin-geofencing.podspec +20 -0
- package/src/Airship.tsx +24 -0
- package/src/Location.tsx +46 -0
- package/src/MarketingCloud.tsx +24 -0
- package/src/Poi.tsx +106 -0
- package/src/Region.tsx +56 -0
- package/src/Visit.tsx +49 -0
- package/src/Zoi.tsx +107 -0
- package/src/index.tsx +255 -0
package/src/index.tsx
ADDED
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
import { NativeModules, NativeEventEmitter } from 'react-native';
|
|
2
|
+
import uuid from 'react-native-uuid';
|
|
3
|
+
import Location from './Location';
|
|
4
|
+
import Region from './Region';
|
|
5
|
+
|
|
6
|
+
// const LINKING_ERROR =
|
|
7
|
+
// `The package 'react-native-plugin-geofencing' doesn't seem to be linked. Make sure: \n\n` +
|
|
8
|
+
// Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) +
|
|
9
|
+
// '- You rebuilt the app after installing the package\n' +
|
|
10
|
+
// '- You are not using Expo managed workflow\n';
|
|
11
|
+
|
|
12
|
+
// const PluginGeofencing = NativeModules.PluginGeofencing
|
|
13
|
+
// ? NativeModules.PluginGeofencing
|
|
14
|
+
// : new Proxy(
|
|
15
|
+
// {},
|
|
16
|
+
// {
|
|
17
|
+
// get() {
|
|
18
|
+
// throw new Error(LINKING_ERROR);
|
|
19
|
+
// },
|
|
20
|
+
// }
|
|
21
|
+
// );
|
|
22
|
+
|
|
23
|
+
if (!NativeModules.PluginGeofencing) {
|
|
24
|
+
throw new Error('NativeModules.PluginGeofencing is undefined');
|
|
25
|
+
}
|
|
26
|
+
const PluginGeofencing = NativeModules.PluginGeofencing;
|
|
27
|
+
// ? NativeModules.PluginGeofencing
|
|
28
|
+
// : new Proxy(
|
|
29
|
+
// {},
|
|
30
|
+
// {
|
|
31
|
+
// get() {
|
|
32
|
+
// throw new Error(LINKING_ERROR);
|
|
33
|
+
// },
|
|
34
|
+
// }
|
|
35
|
+
// );
|
|
36
|
+
const eventEmitter = new NativeEventEmitter(PluginGeofencing);
|
|
37
|
+
|
|
38
|
+
let subscriptionsLocation: any = {};
|
|
39
|
+
let subscriptionsRegion: any = {};
|
|
40
|
+
|
|
41
|
+
function multiply(a: number, b: number): Promise<number> {
|
|
42
|
+
return PluginGeofencing.multiply(a, b);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Initializes the Woosmap object
|
|
46
|
+
* @param arg0 A JSON object with Woosmap Key (optional) and tracking profile (`liveTracking`,`passiveTracking`,`visitsTracking`).
|
|
47
|
+
* @returns promise:success - A callback function that will be called on success.
|
|
48
|
+
error - A callback function that will be called on error.
|
|
49
|
+
*/
|
|
50
|
+
function initialize(arg0?: any): Promise<string> {
|
|
51
|
+
if (arg0 == null) {
|
|
52
|
+
arg0 = {};
|
|
53
|
+
}
|
|
54
|
+
return PluginGeofencing.initialize(arg0);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* A method that sets Woosmap private API key
|
|
59
|
+
* @param apiKey new API key.
|
|
60
|
+
* @returns promise:success - A callback function that will be called on success.
|
|
61
|
+
error - A callback function that will be called on error.
|
|
62
|
+
*/
|
|
63
|
+
function setWoosmapApiKey(apiKey: string): Promise<string> {
|
|
64
|
+
return PluginGeofencing.setWoosmapApiKey([apiKey]);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* A method to start tracking the user's location.
|
|
69
|
+
* @param trackingProfile The configuration profile to use. Values could be anyone of the following: liveTracking, passiveTracking and visitsTracking.
|
|
70
|
+
* @returns promise:success - A callback function that will be called on success.
|
|
71
|
+
error - A callback function that will be called on error.
|
|
72
|
+
*/
|
|
73
|
+
function startTracking(trackingProfile: string): Promise<string> {
|
|
74
|
+
return PluginGeofencing.startTracking([trackingProfile]);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Stops tracking the user's location.
|
|
79
|
+
* @returns promise:success - A callback function that will be called on success.
|
|
80
|
+
error - A callback function that will be called on error.
|
|
81
|
+
*/
|
|
82
|
+
function stopTracking(): Promise<string> {
|
|
83
|
+
return PluginGeofencing.stopTracking();
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* A method to request the required permissions to collect locations.
|
|
88
|
+
* @param background - A boolean value indicating whether the permissions to request is for background or foreground permission.
|
|
89
|
+
* @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'.
|
|
90
|
+
*/
|
|
91
|
+
function requestPermissions(background?: boolean): Promise<string> {
|
|
92
|
+
if (background == null) {
|
|
93
|
+
background = false;
|
|
94
|
+
}
|
|
95
|
+
return PluginGeofencing.requestPermissions([background]);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* A method to check if the app has granted required permissions to track location.
|
|
100
|
+
* @returns A callback that will be called with the following status - GRANTED_BACKGROUND, GRANTED_FOREGROUND, DENIED
|
|
101
|
+
*/
|
|
102
|
+
function getPermissionsStatus(): Promise<string> {
|
|
103
|
+
return PluginGeofencing.getPermissionsStatus();
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Method will
|
|
108
|
+
invoke callback and pass a location object as a parameter. Method will return a watchId . This id can be used to remove a callback.
|
|
109
|
+
* @param success new location found callback
|
|
110
|
+
* @param error error status callback
|
|
111
|
+
* @returns watchid
|
|
112
|
+
*/
|
|
113
|
+
function watchLocation(
|
|
114
|
+
success: (result: Location) => any,
|
|
115
|
+
error?: any
|
|
116
|
+
): Promise<string> {
|
|
117
|
+
const watchID = uuid.v1().toString();
|
|
118
|
+
|
|
119
|
+
const successCallback = (result: any) => {
|
|
120
|
+
success(Location.jsonToObj(result));
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
subscriptionsLocation[watchID] = [
|
|
124
|
+
eventEmitter.addListener('geolocationDidChange', successCallback),
|
|
125
|
+
error ? eventEmitter.addListener('geolocationError', error) : null,
|
|
126
|
+
];
|
|
127
|
+
return PluginGeofencing.watchLocation(watchID);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* A method to stop tracking location for a specified watch. If watchId is null or undefined the plugin will clear all watches.
|
|
132
|
+
* @param watchID Reference ID.
|
|
133
|
+
* @returns return promise with same id back in case of success otherwise error info
|
|
134
|
+
*/
|
|
135
|
+
function clearLocationWatch(watchID?: string): Promise<string> {
|
|
136
|
+
if (watchID == null) {
|
|
137
|
+
eventEmitter.removeAllListeners('geolocationDidChange');
|
|
138
|
+
eventEmitter.removeAllListeners('geolocationError');
|
|
139
|
+
subscriptionsLocation = {};
|
|
140
|
+
return PluginGeofencing.clearAllLocationWatch();
|
|
141
|
+
} else {
|
|
142
|
+
const saved = subscriptionsLocation[watchID];
|
|
143
|
+
if (saved) {
|
|
144
|
+
const arg0 = saved[0];
|
|
145
|
+
eventEmitter.removeListener('geolocationDidChange', arg0);
|
|
146
|
+
const arg1 = saved[1];
|
|
147
|
+
if (arg1) {
|
|
148
|
+
eventEmitter.removeListener('geolocationError', arg1);
|
|
149
|
+
}
|
|
150
|
+
subscriptionsLocation[watchID] = undefined;
|
|
151
|
+
}
|
|
152
|
+
return PluginGeofencing.clearLocationWatch(watchID);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* A method to to track Regions. Method will invoke a callback with Region object. Method will return
|
|
158
|
+
a watch id which can be used later to remove the callback.
|
|
159
|
+
* @param success new location found callback
|
|
160
|
+
* @param error error status callback
|
|
161
|
+
* @returns watchid
|
|
162
|
+
*/
|
|
163
|
+
function watchRegions(
|
|
164
|
+
success: (result: Region) => any,
|
|
165
|
+
error?: any
|
|
166
|
+
): Promise<string> {
|
|
167
|
+
const watchID = uuid.v1().toString();
|
|
168
|
+
|
|
169
|
+
const successCallback = (result: any) => {
|
|
170
|
+
success(Region.jsonToObj(result));
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
subscriptionsRegion[watchID] = [
|
|
174
|
+
eventEmitter.addListener('woosmapgeofenceRegionDidChange', successCallback),
|
|
175
|
+
error
|
|
176
|
+
? eventEmitter.addListener('woosmapgeofenceRegionError', error)
|
|
177
|
+
: null,
|
|
178
|
+
];
|
|
179
|
+
return PluginGeofencing.watchRegions(watchID);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* 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.
|
|
184
|
+
* @param watchID Reference ID.
|
|
185
|
+
* @returns return promise with same id back in case of success otherwise error info
|
|
186
|
+
*/
|
|
187
|
+
function clearRegionsWatch(watchID: string): Promise<string> {
|
|
188
|
+
if (watchID == null) {
|
|
189
|
+
eventEmitter.removeAllListeners('woosmapgeofenceRegionDidChange');
|
|
190
|
+
eventEmitter.removeAllListeners('woosmapgeofenceRegionError');
|
|
191
|
+
subscriptionsRegion = {};
|
|
192
|
+
return PluginGeofencing.clearAllRegionsWatch();
|
|
193
|
+
} else {
|
|
194
|
+
const saved = subscriptionsRegion[watchID];
|
|
195
|
+
if (saved) {
|
|
196
|
+
const arg0 = saved[0];
|
|
197
|
+
eventEmitter.removeListener('woosmapgeofenceRegionDidChange', arg0);
|
|
198
|
+
const arg1 = saved[1];
|
|
199
|
+
if (arg1) {
|
|
200
|
+
eventEmitter.removeListener('woosmapgeofenceRegionError', arg1);
|
|
201
|
+
}
|
|
202
|
+
subscriptionsRegion[watchID] = undefined;
|
|
203
|
+
}
|
|
204
|
+
return PluginGeofencing.clearRegionsWatch(watchID);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Sets Sales Force Marketing Cloud (SFMC) credentials
|
|
209
|
+
* @param arg0 A JSON object with SFMC credentials. Keys authenticationBaseURI, restBaseURI, client_id, client_secret and contactKey are required.
|
|
210
|
+
* @returns promise with A callback that will be called on success or error.
|
|
211
|
+
*/
|
|
212
|
+
function setSFMCCredentials(arg0: Object): Promise<string> {
|
|
213
|
+
return PluginGeofencing.setSFMCCredentials(arg0);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* 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").
|
|
218
|
+
* @param radius can be integer or string.
|
|
219
|
+
* @returns promise with A callback that will be called on success or error.
|
|
220
|
+
*/
|
|
221
|
+
function setPoiRadius(radius: string): Promise<string> {
|
|
222
|
+
return PluginGeofencing.setPoiRadius(radius);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
const WoosmapGeofencing = {
|
|
226
|
+
multiply,
|
|
227
|
+
initialize,
|
|
228
|
+
setWoosmapApiKey,
|
|
229
|
+
startTracking,
|
|
230
|
+
requestPermissions,
|
|
231
|
+
getPermissionsStatus,
|
|
232
|
+
stopTracking,
|
|
233
|
+
watchLocation,
|
|
234
|
+
clearLocationWatch,
|
|
235
|
+
watchRegions,
|
|
236
|
+
clearRegionsWatch,
|
|
237
|
+
setSFMCCredentials,
|
|
238
|
+
setPoiRadius,
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
/* We export the native interface in this way to give easy shared access to it between the
|
|
242
|
+
* JavaScript code and the tests
|
|
243
|
+
*/
|
|
244
|
+
//let nativeEventEmitter: NativeEventEmitter | null = null;
|
|
245
|
+
|
|
246
|
+
export default WoosmapGeofencing;
|
|
247
|
+
// module.exports = {
|
|
248
|
+
// WoosmapGeofencing,
|
|
249
|
+
// get GeolocationEventEmitter() {
|
|
250
|
+
// if (!nativeEventEmitter) {
|
|
251
|
+
// nativeEventEmitter = new NativeEventEmitter(PluginGeofencing);
|
|
252
|
+
// }
|
|
253
|
+
// return nativeEventEmitter;
|
|
254
|
+
// },
|
|
255
|
+
// };
|