@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
|
@@ -0,0 +1,474 @@
|
|
|
1
|
+
//
|
|
2
|
+
// WoosmapGeofenceService.swift
|
|
3
|
+
// woosmapgeofencingsample
|
|
4
|
+
//
|
|
5
|
+
// Created by apple on 02/08/21.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
import Foundation
|
|
9
|
+
import UIKit
|
|
10
|
+
import CoreLocation
|
|
11
|
+
import WoosmapGeofencing
|
|
12
|
+
#if canImport(AirshipCore)
|
|
13
|
+
import AirshipCore
|
|
14
|
+
#endif
|
|
15
|
+
|
|
16
|
+
/// Geofence services
|
|
17
|
+
@objc(WoosmapGeofenceService) public class WoosmapGeofenceService: NSObject {
|
|
18
|
+
|
|
19
|
+
/// Share object for WoosmapGeofenceService
|
|
20
|
+
@objc static var shared: WoosmapGeofenceService?
|
|
21
|
+
private var woosmapKey: String = ""
|
|
22
|
+
private var defaultProfile: String = ""
|
|
23
|
+
private let dataLocation = DataLocation()
|
|
24
|
+
private let dataPOI = DataPOI()
|
|
25
|
+
private let dataDistance = DataDistance()
|
|
26
|
+
private let dataRegion = DataRegion()
|
|
27
|
+
private let dataVisit = DataVisit()
|
|
28
|
+
private let airshipEvents = AirshipEvents()
|
|
29
|
+
private let marketingCloudEvents = MarketingCloudEvents()
|
|
30
|
+
|
|
31
|
+
private var defaultPOIRadius: String {
|
|
32
|
+
get {
|
|
33
|
+
let defaults = UserDefaults.standard
|
|
34
|
+
let defaultPOIRadius = defaults.string(forKey: "WoosmapGeofenceService.poiradius") ?? ""
|
|
35
|
+
return defaultPOIRadius
|
|
36
|
+
}
|
|
37
|
+
set {
|
|
38
|
+
let defaults = UserDefaults.standard
|
|
39
|
+
defaults.set(newValue, forKey: "WoosmapGeofenceService.poiradius")
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/// Status of search api On/Off
|
|
44
|
+
@objc public var searchAPIRequestEnable: Bool {
|
|
45
|
+
get {
|
|
46
|
+
return WoosmapGeofencing.shared.getSearchAPIRequestEnable()
|
|
47
|
+
}
|
|
48
|
+
set {
|
|
49
|
+
WoosmapGeofencing.shared.setSearchAPIRequestEnable(enable: newValue)
|
|
50
|
+
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/// Status of distance api On/Off
|
|
55
|
+
@objc public var distanceAPIRequestEnable: Bool {
|
|
56
|
+
get {
|
|
57
|
+
return WoosmapGeofencing.shared.getDistanceAPIRequestEnable()
|
|
58
|
+
}
|
|
59
|
+
set {
|
|
60
|
+
WoosmapGeofencing.shared.setDistanceAPIRequestEnable(enable: newValue)
|
|
61
|
+
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/// status of CreationRegionEnable. On/Off
|
|
66
|
+
@objc public var searchAPICreationRegionEnable: Bool {
|
|
67
|
+
get {
|
|
68
|
+
return WoosmapGeofencing.shared.getSearchAPICreationRegionEnable()
|
|
69
|
+
}
|
|
70
|
+
set {
|
|
71
|
+
WoosmapGeofencing.shared.setSearchAPICreationRegionEnable(enable: newValue)
|
|
72
|
+
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/// Status of HighfrequencyLocation Mode. On/Off
|
|
77
|
+
@objc public var modeHighfrequencyLocation: Bool {
|
|
78
|
+
get {
|
|
79
|
+
return WoosmapGeofencing.shared.getModeHighfrequencyLocation()
|
|
80
|
+
}
|
|
81
|
+
set {
|
|
82
|
+
WoosmapGeofencing.shared.setModeHighfrequencyLocation(enable: newValue)
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/// Status of tracking state. On/Off
|
|
87
|
+
@objc public var trackingState: Bool {
|
|
88
|
+
get {
|
|
89
|
+
return WoosmapGeofencing.shared.getTrackingState()
|
|
90
|
+
}
|
|
91
|
+
set {
|
|
92
|
+
WoosmapGeofencing.shared.setTrackingEnable(enable: newValue)
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// MARK: Application events
|
|
97
|
+
|
|
98
|
+
/// This callback received when application become active
|
|
99
|
+
@objc func appDidBecomeActive() {
|
|
100
|
+
WoosmapGeofencing.shared.didBecomeActive()
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/// This callback recived when application enter in background mode
|
|
104
|
+
@objc func appDidEnterBackground() {
|
|
105
|
+
if CLLocationManager.authorizationStatus() != .notDetermined {
|
|
106
|
+
WoosmapGeofencing.shared.startMonitoringInBackground()
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/// This callback received when application is terminated
|
|
111
|
+
@objc func appWillTerminate() {
|
|
112
|
+
WoosmapGeofencing.shared.setModeHighfrequencyLocation(enable: false)
|
|
113
|
+
}
|
|
114
|
+
// MARK: Init
|
|
115
|
+
|
|
116
|
+
/// Initialize woosGeofencing service with key saved in previous call
|
|
117
|
+
private override init() {
|
|
118
|
+
super.init()
|
|
119
|
+
let defaults = UserDefaults.standard
|
|
120
|
+
let woosmapKey = defaults.string(forKey: "WoosmapGeofenceService.woosmap") ?? ""
|
|
121
|
+
let defaultProfile = defaults.string(forKey: "WoosmapGeofenceService.profile") ?? ""
|
|
122
|
+
self.woosmapKey = woosmapKey
|
|
123
|
+
self.defaultProfile = defaultProfile
|
|
124
|
+
|
|
125
|
+
defaults.register(defaults: ["TrackingEnable": true,
|
|
126
|
+
"ModeHighfrequencyLocation": false,
|
|
127
|
+
"SearchAPIEnable": true,
|
|
128
|
+
"DistanceAPIEnable": true,
|
|
129
|
+
"searchAPICreationRegionEnable": true])
|
|
130
|
+
|
|
131
|
+
self.activateGeofenceService()
|
|
132
|
+
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/// Initialize service with keys and profile
|
|
136
|
+
/// - Parameters:
|
|
137
|
+
/// - woosmapKey: key use for woosmap service
|
|
138
|
+
/// - configurationProfile: configuration profile
|
|
139
|
+
private init(_ woosmapKey: String, _ configurationProfile: String) {
|
|
140
|
+
super.init()
|
|
141
|
+
self.woosmapKey = woosmapKey
|
|
142
|
+
self.defaultProfile = configurationProfile
|
|
143
|
+
|
|
144
|
+
// Save it on prefrences
|
|
145
|
+
let defaults = UserDefaults.standard
|
|
146
|
+
defaults.set(woosmapKey, forKey: "WoosmapGeofenceService.woosmap")
|
|
147
|
+
defaults.set(configurationProfile, forKey: "WoosmapGeofenceService.profile")
|
|
148
|
+
|
|
149
|
+
defaults.register(defaults: ["TrackingEnable": true,
|
|
150
|
+
"ModeHighfrequencyLocation": false,
|
|
151
|
+
"SearchAPIEnable": true,
|
|
152
|
+
"DistanceAPIEnable": true,
|
|
153
|
+
"searchAPICreationRegionEnable": true])
|
|
154
|
+
self.activateGeofenceService()
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/// Static instance of woosGeofencing service
|
|
158
|
+
/// - Parameters:
|
|
159
|
+
/// - woosmapKey: key use for woosmap service
|
|
160
|
+
/// - configurationProfile: configuration profile
|
|
161
|
+
@objc public static func setup(woosmapKey: String, configurationProfile: String) {
|
|
162
|
+
DispatchQueue.main.async {
|
|
163
|
+
shared = WoosmapGeofenceService.init( woosmapKey, configurationProfile)
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/// Creating instance for woosGeofencing service
|
|
168
|
+
@objc public static func setup() {
|
|
169
|
+
DispatchQueue.main.async {
|
|
170
|
+
shared = WoosmapGeofenceService.init( "", "")
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/// Setting up woosmap key
|
|
175
|
+
/// - Parameter key: woosmap key
|
|
176
|
+
/// - Throws: WoosGeofenceError incase of no key pass or empty
|
|
177
|
+
public func setWoosmapAPIKey(key: String) throws {
|
|
178
|
+
if key.trimmingCharacters(in: .whitespacesAndNewlines) == "" {
|
|
179
|
+
throw WoosGeofenceError(WoosmapGeofenceMessage.invalidWoosmapKey)
|
|
180
|
+
} else {
|
|
181
|
+
self.woosmapKey = key
|
|
182
|
+
WoosmapGeofencing.shared.setWoosmapAPIKey(key: self.woosmapKey)
|
|
183
|
+
|
|
184
|
+
let defaults = UserDefaults.standard
|
|
185
|
+
defaults.set(key, forKey: "WoosmapGeofenceService.woosmap")
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/// Change tracking mode with new profile
|
|
190
|
+
/// - Parameter profile: profile for tracking. liveTracking / passiveTracking / visitsTracking
|
|
191
|
+
/// - Throws: in case of wrong profile provided it return error invalidProfile
|
|
192
|
+
public func startTracking(profile: String) throws {
|
|
193
|
+
if let savedProfile = ConfigurationProfile(rawValue: profile) {
|
|
194
|
+
WoosmapGeofencing.shared.startTracking(configurationProfile: savedProfile)
|
|
195
|
+
self.defaultProfile = profile
|
|
196
|
+
let defaults = UserDefaults.standard
|
|
197
|
+
defaults.set(profile, forKey: "WoosmapGeofenceService.profile")
|
|
198
|
+
|
|
199
|
+
} else {
|
|
200
|
+
self.defaultProfile = ""
|
|
201
|
+
let defaults = UserDefaults.standard
|
|
202
|
+
defaults.set(self.defaultProfile, forKey: "WoosmapGeofenceService.profile")
|
|
203
|
+
throw WoosGeofenceError(WoosmapGeofenceMessage.invalidProfile)
|
|
204
|
+
}
|
|
205
|
+
print ("Highfrequency \(WoosmapGeofencing.shared.getModeHighfrequencyLocation()) , TrackingState \(WoosmapGeofencing.shared.getTrackingState()) ")
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/// Stop tracking
|
|
209
|
+
public func stopTracking() {
|
|
210
|
+
WoosmapGeofencing.shared.stopTracking()
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/// activating WoosmapGeofencing with default parameters
|
|
214
|
+
private func activateGeofenceService() {
|
|
215
|
+
// Set private Woosmap key API
|
|
216
|
+
WoosmapGeofencing.shared.setWoosmapAPIKey(key: woosmapKey)
|
|
217
|
+
|
|
218
|
+
// Set delegate of protocol Location, POI and Distance
|
|
219
|
+
WoosmapGeofencing.shared.getLocationService().locationServiceDelegate = dataLocation
|
|
220
|
+
WoosmapGeofencing.shared.getLocationService().searchAPIDataDelegate = dataPOI
|
|
221
|
+
WoosmapGeofencing.shared.getLocationService().distanceAPIDataDelegate = dataDistance
|
|
222
|
+
WoosmapGeofencing.shared.getLocationService().regionDelegate = dataRegion
|
|
223
|
+
|
|
224
|
+
// Enable Visit and set delegate of protocol Visit
|
|
225
|
+
WoosmapGeofencing.shared.getLocationService().visitDelegate = dataVisit
|
|
226
|
+
|
|
227
|
+
// Set delagate for Airship Cloud
|
|
228
|
+
WoosmapGeofencing.shared.getLocationService().airshipEventsDelegate = airshipEvents
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
// Set delagate for Marketing Cloud
|
|
232
|
+
WoosmapGeofencing.shared.getLocationService().marketingCloudEventsDelegate = marketingCloudEvents
|
|
233
|
+
if defaultPOIRadius != "" {
|
|
234
|
+
WoosmapGeofencing.shared.setPoiRadius(radius: formatedRadius(radius: defaultPOIRadius))
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
if let savedProfile = ConfigurationProfile(rawValue: defaultProfile) {
|
|
238
|
+
WoosmapGeofencing.shared.startTracking(configurationProfile: savedProfile)
|
|
239
|
+
}
|
|
240
|
+
else{ //Default tracking
|
|
241
|
+
WoosmapGeofencing.shared.startTracking(configurationProfile: ConfigurationProfile.passiveTracking)
|
|
242
|
+
}
|
|
243
|
+
// Check if the authorization Status of location Manager
|
|
244
|
+
if CLLocationManager.authorizationStatus() != .notDetermined {
|
|
245
|
+
WoosmapGeofencing.shared.startMonitoringInBackground()
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
NotificationCenter.default.addObserver(self,
|
|
249
|
+
selector: #selector(appDidBecomeActive),
|
|
250
|
+
name: UIApplication.didBecomeActiveNotification,
|
|
251
|
+
object: nil)
|
|
252
|
+
|
|
253
|
+
NotificationCenter.default.addObserver(self, selector: #selector(appDidEnterBackground), name: UIApplication.didEnterBackgroundNotification, object: nil)
|
|
254
|
+
|
|
255
|
+
NotificationCenter.default.addObserver(self, selector: #selector(appWillTerminate), name: UIApplication.willTerminateNotification, object: nil)
|
|
256
|
+
|
|
257
|
+
// MARK: Only for testing
|
|
258
|
+
self.searchAPIRequestEnable = true
|
|
259
|
+
self.distanceAPIRequestEnable = true
|
|
260
|
+
self.searchAPICreationRegionEnable = true
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
print ("\(WoosmapGeofencing.shared.getModeHighfrequencyLocation()) \(WoosmapGeofencing.shared.getTrackingState()) ")
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
/// Adding new region
|
|
267
|
+
/// - Parameters:
|
|
268
|
+
/// - identifier: Region id
|
|
269
|
+
/// - center: geoLocation point
|
|
270
|
+
/// - radius: radius of region
|
|
271
|
+
/// - Returns: Status for reagion created or not and new region id from system
|
|
272
|
+
public func addRegion(identifier: String, center: CLLocationCoordinate2D, radius: CLLocationDistance) -> (isCreate: Bool, identifier: String) {
|
|
273
|
+
return WoosmapGeofencing.shared.locationService.addRegion(identifier: identifier, center: center, radius: radius)
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
/// Remove region from system
|
|
277
|
+
/// - Parameter center: geoLocation point of region
|
|
278
|
+
public func removeRegion(center: CLLocationCoordinate2D) {
|
|
279
|
+
return WoosmapGeofencing.shared.locationService.removeRegion(center: center)
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/// Remove region from system
|
|
283
|
+
/// - Parameter identifier: region id assined for region
|
|
284
|
+
public func removeRegion(identifier: String) {
|
|
285
|
+
return WoosmapGeofencing.shared.locationService.removeRegion(identifier: identifier)
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
/// Get location information for geopoint from woos system
|
|
289
|
+
/// - Parameters:
|
|
290
|
+
/// - location: geopoint for location
|
|
291
|
+
/// - locationId: id recorded for that location
|
|
292
|
+
public func searchAPIRequest(location: CLLocationCoordinate2D, locationId: String = "") {
|
|
293
|
+
// TODO: Missing implementation
|
|
294
|
+
//WoosmapGeofencing.shared.getLocationService().searchAPIRequest(location: CLLocation.init(latitude: location.latitude, longitude: location.longitude), locationId: locationId)
|
|
295
|
+
}
|
|
296
|
+
// TODO: Missing implementation
|
|
297
|
+
// /// Get distnce between location point and origin
|
|
298
|
+
// /// - Parameters:
|
|
299
|
+
// /// - locationOrigin: origin geolocation
|
|
300
|
+
// /// - coordinatesDest: destination geolocation
|
|
301
|
+
// /// - locationId: id recorded for that location
|
|
302
|
+
// public func distanceAPIRequest(locationOrigin: CLLocationCoordinate2D, coordinatesDest: CLLocation, locationId: String = "") {
|
|
303
|
+
// let latDest = coordinatesDest.coordinate.latitude
|
|
304
|
+
// let lngDest = coordinatesDest.coordinate.longitude
|
|
305
|
+
// let originLocation = CLLocation.init(latitude: locationOrigin.latitude,
|
|
306
|
+
// longitude: locationOrigin.longitude)
|
|
307
|
+
// WoosmapGeofencing.shared.getLocationService().distanceAPIRequest(locationOrigin: originLocation,
|
|
308
|
+
// coordinatesDest: [(latDest, lngDest)],
|
|
309
|
+
// locationId: locationId)
|
|
310
|
+
// }
|
|
311
|
+
//
|
|
312
|
+
// /// Get distnce between location point and origin
|
|
313
|
+
// /// - Parameters:
|
|
314
|
+
// /// - locationOrigin: origin geolocation
|
|
315
|
+
// /// - locationId: id recorded for that location
|
|
316
|
+
// public func distanceAPIRequest(locationOrigin: CLLocationCoordinate2D, locationId: String = "") {
|
|
317
|
+
// if let poi = DataPOI().getPOIbyLocationID(locationId: locationId) {
|
|
318
|
+
// let latDest = poi.latitude
|
|
319
|
+
// let lngDest = poi.longitude
|
|
320
|
+
// let originLocation = CLLocation.init(latitude: locationOrigin.latitude,
|
|
321
|
+
// longitude: locationOrigin.longitude)
|
|
322
|
+
// WoosmapGeofencing.shared.getLocationService().distanceAPIRequest(locationOrigin: originLocation,
|
|
323
|
+
// coordinatesDest: [(latDest, lngDest)],
|
|
324
|
+
// locationId: locationId)
|
|
325
|
+
// }
|
|
326
|
+
//
|
|
327
|
+
// }
|
|
328
|
+
|
|
329
|
+
/// List all locations capture by system
|
|
330
|
+
/// - Returns: Array of location captured
|
|
331
|
+
public func getLocations() -> [Location] {
|
|
332
|
+
let locations = DataLocation().readLocations()
|
|
333
|
+
return locations
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
/// List all POIs capture by system
|
|
337
|
+
/// - Returns: Array of POIs
|
|
338
|
+
public func getPOIs() -> [POI] {
|
|
339
|
+
let poi = DataPOI().readPOI()
|
|
340
|
+
return poi
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
/// List all intrest zone capture by system
|
|
344
|
+
/// - Returns: Array of zones
|
|
345
|
+
public func getZOIs() -> [ZOI] {
|
|
346
|
+
let zoi = DataZOI().readZOIs()
|
|
347
|
+
return zoi
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
/// List all region capture by system
|
|
351
|
+
/// - Returns: Array of regions
|
|
352
|
+
public func getRegions() -> [Region] {
|
|
353
|
+
let regions = DataRegion().readRegions()
|
|
354
|
+
return regions
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
/// List all visits capture by system
|
|
358
|
+
/// - Returns: Array of visits
|
|
359
|
+
public func getVisits() -> [Visit] {
|
|
360
|
+
let visit = DataVisit().readVisits()
|
|
361
|
+
return visit
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
/// Delete all visits from system
|
|
365
|
+
public func deleteVisits() {
|
|
366
|
+
DataVisit().eraseVisits()
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
/// Delete all zois form system
|
|
370
|
+
public func deleteZoi() {
|
|
371
|
+
DataZOI().eraseZOIs()
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
/// Delete all location from system
|
|
375
|
+
public func deleteLocations() {
|
|
376
|
+
DataLocation().eraseLocations()
|
|
377
|
+
// Native SDK Works independently
|
|
378
|
+
// DataPOI().erasePOI()
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
/// Delete all ZOI regions
|
|
382
|
+
public func deleteAllZoiRegion() {
|
|
383
|
+
WoosmapGeofencing.shared.locationService.removeRegions(type: LocationService.RegionType.custom)
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
/// Delete all POI regions
|
|
387
|
+
public func deleteAllPoiRegion() {
|
|
388
|
+
WoosmapGeofencing.shared.locationService.removeRegions(type: LocationService.RegionType.poi)
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
/// Delete all regions
|
|
392
|
+
public func deleteAllRegion() {
|
|
393
|
+
WoosmapGeofencing.shared.locationService.removeRegions(type: LocationService.RegionType.none)
|
|
394
|
+
DataRegion().eraseRegions()
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
@objc static public func mockdata() {
|
|
398
|
+
if WoosmapGeofenceService.shared == nil {
|
|
399
|
+
WoosmapGeofenceService.setup()
|
|
400
|
+
}
|
|
401
|
+
MockDataVisit().mockVisitData()
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
/// Setting up SFMCCredentials
|
|
405
|
+
/// - Parameter credentials: Key/value pair for credentials settings
|
|
406
|
+
/// - Throws: Error for required keys
|
|
407
|
+
@objc public func setSFMCCredentials(credentials: [String: String]) throws {
|
|
408
|
+
var requiredSatisfied = true
|
|
409
|
+
if credentials["authenticationBaseURI"] == nil {
|
|
410
|
+
requiredSatisfied = false
|
|
411
|
+
throw WoosGeofenceError(WoosmapGeofenceMessage.required_authenticationBaseURI )
|
|
412
|
+
}
|
|
413
|
+
else if credentials["restBaseURI"] == nil {
|
|
414
|
+
requiredSatisfied = false
|
|
415
|
+
throw WoosGeofenceError(WoosmapGeofenceMessage.required_restBaseURI)
|
|
416
|
+
}
|
|
417
|
+
else if credentials["client_id"] == nil {
|
|
418
|
+
requiredSatisfied = false
|
|
419
|
+
throw WoosGeofenceError(WoosmapGeofenceMessage.required_client_id)
|
|
420
|
+
}
|
|
421
|
+
else if credentials["client_secret"] == nil {
|
|
422
|
+
requiredSatisfied = false
|
|
423
|
+
throw WoosGeofenceError(WoosmapGeofenceMessage.required_client_secret)
|
|
424
|
+
}
|
|
425
|
+
else if credentials["contactKey"] == nil {
|
|
426
|
+
requiredSatisfied = false
|
|
427
|
+
throw WoosGeofenceError(WoosmapGeofenceMessage.required_contactKey)
|
|
428
|
+
}
|
|
429
|
+
if requiredSatisfied {
|
|
430
|
+
WoosmapGeofencing.shared.setSFMCCredentials(credentials: credentials)
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
/// Setting POI redious
|
|
435
|
+
/// - Parameter radius: integer or string for radius value
|
|
436
|
+
public func setPoiRadius(radius: String) {
|
|
437
|
+
self.defaultPOIRadius = radius
|
|
438
|
+
WoosmapGeofencing.shared.setPoiRadius(radius: formatedRadius(radius: radius))
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
/// Format String value to proper datatype
|
|
442
|
+
/// - Parameter radius: radius of POI
|
|
443
|
+
/// - Returns: Formatted radius
|
|
444
|
+
private func formatedRadius (radius: String) -> Any {
|
|
445
|
+
if let poiRadius = Int(radius){
|
|
446
|
+
return poiRadius
|
|
447
|
+
}
|
|
448
|
+
else if let poiRadius = Double(radius){
|
|
449
|
+
return poiRadius
|
|
450
|
+
}
|
|
451
|
+
else{
|
|
452
|
+
return radius
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
/// WoosGeofense error
|
|
459
|
+
struct WoosGeofenceError: Error {
|
|
460
|
+
|
|
461
|
+
/// Error info
|
|
462
|
+
let message: String
|
|
463
|
+
|
|
464
|
+
/// Initialize
|
|
465
|
+
/// - Parameter message: error detail text
|
|
466
|
+
init(_ message: String) {
|
|
467
|
+
self.message = message
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
/// Localized Description
|
|
471
|
+
public var localizedDescription: String {
|
|
472
|
+
return message
|
|
473
|
+
}
|
|
474
|
+
}
|
|
Binary file
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
3
|
+
<plist version="1.0">
|
|
4
|
+
<dict>
|
|
5
|
+
<key>SchemeUserState</key>
|
|
6
|
+
<dict>
|
|
7
|
+
<key>WoosmapGeofencingPlugin.xcscheme_^#shared#^_</key>
|
|
8
|
+
<dict>
|
|
9
|
+
<key>orderHint</key>
|
|
10
|
+
<integer>0</integer>
|
|
11
|
+
</dict>
|
|
12
|
+
</dict>
|
|
13
|
+
</dict>
|
|
14
|
+
</plist>
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @classdesc A class that represents the Airship object.
|
|
7
|
+
* @constructs Airship
|
|
8
|
+
* @param {string} name The name of the custom event.
|
|
9
|
+
* @param {string} properties The attributes of the POI such as `name`, `address`, `zipCode` etc.
|
|
10
|
+
*/
|
|
11
|
+
class Airship {
|
|
12
|
+
constructor(name, properties) {
|
|
13
|
+
_defineProperty(this, "Name", void 0);
|
|
14
|
+
|
|
15
|
+
_defineProperty(this, "Properties", void 0);
|
|
16
|
+
|
|
17
|
+
this.Name = name;
|
|
18
|
+
this.Properties = properties;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Converts json object to an object of type Airship.
|
|
22
|
+
* @param {Object} json The json representation of Airship.
|
|
23
|
+
* @returns Object
|
|
24
|
+
* @memberof Airship
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
static jsonToObj(json) {
|
|
29
|
+
return new Airship(json.name, json.properties);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
module.exports = Airship;
|
|
35
|
+
//# sourceMappingURL=Airship.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["Airship.tsx"],"names":["Airship","constructor","name","properties","Name","Properties","jsonToObj","json","module","exports"],"mappings":";;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMA,OAAN,CAAc;AAGZC,EAAAA,WAAW,CAACC,IAAD,EAAeC,UAAf,EAAmC;AAAA;;AAAA;;AAC5C,SAAKC,IAAL,GAAYF,IAAZ;AACA,SAAKG,UAAL,GAAkBF,UAAlB;AACD;AACD;AACF;AACA;AACA;AACA;AACA;;;AACkB,SAATG,SAAS,CAACC,IAAD,EAAY;AAC1B,WAAO,IAAIP,OAAJ,CAAYO,IAAI,CAACL,IAAjB,EAAuBK,IAAI,CAACJ,UAA5B,CAAP;AACD;;AAfW;;AAiBdK,MAAM,CAACC,OAAP,GAAiBT,OAAjB","sourcesContent":["/**\n * @classdesc A class that represents the Airship object.\n * @constructs Airship\n * @param {string} name The name of the custom event.\n * @param {string} properties The attributes of the POI such as `name`, `address`, `zipCode` etc.\n */\nclass Airship {\n Name: String;\n Properties: String;\n constructor(name: String, properties: String) {\n this.Name = name;\n this.Properties = properties;\n }\n /**\n * Converts json object to an object of type Airship.\n * @param {Object} json The json representation of Airship.\n * @returns Object\n * @memberof Airship\n */\n static jsonToObj(json: any) {\n return new Airship(json.name, json.properties);\n }\n}\nmodule.exports = Airship;\n"]}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @classdesc A class that represents the location object.
|
|
12
|
+
* @constructs Location
|
|
13
|
+
* @param {number} date The datetime stamp.
|
|
14
|
+
* @param {number} latitude The latitude of the location.
|
|
15
|
+
|
|
16
|
+
* @param {string} Locationdescription The description of the location.
|
|
17
|
+
* @param {string} Locationid A unique identifier for the location.
|
|
18
|
+
* @param {number} longitude The longitude of the location.
|
|
19
|
+
*/
|
|
20
|
+
class Location {
|
|
21
|
+
constructor(date, latitude, locationdescription, locationid, longitude) {
|
|
22
|
+
_defineProperty(this, "Date", void 0);
|
|
23
|
+
|
|
24
|
+
_defineProperty(this, "Latitude", void 0);
|
|
25
|
+
|
|
26
|
+
_defineProperty(this, "Locationdescription", void 0);
|
|
27
|
+
|
|
28
|
+
_defineProperty(this, "Locationid", void 0);
|
|
29
|
+
|
|
30
|
+
_defineProperty(this, "Longitude", void 0);
|
|
31
|
+
|
|
32
|
+
this.Date = date;
|
|
33
|
+
this.Latitude = latitude;
|
|
34
|
+
this.Locationdescription = locationdescription;
|
|
35
|
+
this.Locationid = locationid;
|
|
36
|
+
this.Longitude = longitude;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Converts json object to an object of type Location.
|
|
40
|
+
* @param {Object} json The json representation of the Location.
|
|
41
|
+
* @returns Object
|
|
42
|
+
* @memberof Location
|
|
43
|
+
*/
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
static jsonToObj(json) {
|
|
47
|
+
return new Location(json.date, json.latitude, json.locationdescription, json.locationid, json.longitude);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
var _default = Location;
|
|
53
|
+
exports.default = _default;
|
|
54
|
+
//# sourceMappingURL=Location.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["Location.tsx"],"names":["Location","constructor","date","latitude","locationdescription","locationid","longitude","Date","Latitude","Locationdescription","Locationid","Longitude","jsonToObj","json"],"mappings":";;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMA,QAAN,CAAe;AAMbC,EAAAA,WAAW,CACTC,IADS,EAETC,QAFS,EAGTC,mBAHS,EAITC,UAJS,EAKTC,SALS,EAMT;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AACA,SAAKC,IAAL,GAAYL,IAAZ;AACA,SAAKM,QAAL,GAAgBL,QAAhB;AACA,SAAKM,mBAAL,GAA2BL,mBAA3B;AACA,SAAKM,UAAL,GAAkBL,UAAlB;AACA,SAAKM,SAAL,GAAiBL,SAAjB;AACD;AACD;AACF;AACA;AACA;AACA;AACA;;;AACkB,SAATM,SAAS,CAACC,IAAD,EAAY;AAC1B,WAAO,IAAIb,QAAJ,CACLa,IAAI,CAACX,IADA,EAELW,IAAI,CAACV,QAFA,EAGLU,IAAI,CAACT,mBAHA,EAILS,IAAI,CAACR,UAJA,EAKLQ,IAAI,CAACP,SALA,CAAP;AAOD;;AAjCY;;eAmCAN,Q","sourcesContent":["/**\n * @classdesc A class that represents the location object.\n * @constructs Location\n * @param {number} date The datetime stamp.\n * @param {number} latitude The latitude of the location.\n\n * @param {string} Locationdescription The description of the location. \n * @param {string} Locationid A unique identifier for the location.\n * @param {number} longitude The longitude of the location.\n */\nclass Location {\n Date: number;\n Latitude: number;\n Locationdescription: string;\n Locationid: string;\n Longitude: number;\n constructor(\n date: number,\n latitude: number,\n locationdescription: string,\n locationid: string,\n longitude: number\n ) {\n this.Date = date;\n this.Latitude = latitude;\n this.Locationdescription = locationdescription;\n this.Locationid = locationid;\n this.Longitude = longitude;\n }\n /**\n * Converts json object to an object of type Location.\n * @param {Object} json The json representation of the Location.\n * @returns Object\n * @memberof Location\n */\n static jsonToObj(json: any) {\n return new Location(\n json.date,\n json.latitude,\n json.locationdescription,\n json.locationid,\n json.longitude\n );\n }\n}\nexport default Location;\n"]}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @classdesc A class that represents the Marketing Cloud object.
|
|
7
|
+
* @constructs MarketingCloud
|
|
8
|
+
* @param {string} name The name of the custom event.
|
|
9
|
+
* @param {string} properties The attributes of the POI such as `name`, `address`, `zipCode` etc.
|
|
10
|
+
*/
|
|
11
|
+
class MarketingCloud {
|
|
12
|
+
constructor(name, properties) {
|
|
13
|
+
_defineProperty(this, "Name", void 0);
|
|
14
|
+
|
|
15
|
+
_defineProperty(this, "Properties", void 0);
|
|
16
|
+
|
|
17
|
+
this.Name = name;
|
|
18
|
+
this.Properties = properties;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Converts json object to an object of type MarketingCloud.
|
|
22
|
+
* @param {Object} json The json representation of MarketingCloud.
|
|
23
|
+
* @returns Object
|
|
24
|
+
* @memberof MarketingCloud
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
static jsonToObj(json) {
|
|
29
|
+
return new MarketingCloud(json.name, json.properties);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
module.exports = MarketingCloud;
|
|
35
|
+
//# sourceMappingURL=MarketingCloud.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["MarketingCloud.tsx"],"names":["MarketingCloud","constructor","name","properties","Name","Properties","jsonToObj","json","module","exports"],"mappings":";;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMA,cAAN,CAAqB;AAGnBC,EAAAA,WAAW,CAACC,IAAD,EAAeC,UAAf,EAAmC;AAAA;;AAAA;;AAC5C,SAAKC,IAAL,GAAYF,IAAZ;AACA,SAAKG,UAAL,GAAkBF,UAAlB;AACD;AACD;AACF;AACA;AACA;AACA;AACA;;;AACkB,SAATG,SAAS,CAACC,IAAD,EAAY;AAC1B,WAAO,IAAIP,cAAJ,CAAmBO,IAAI,CAACL,IAAxB,EAA8BK,IAAI,CAACJ,UAAnC,CAAP;AACD;;AAfkB;;AAiBrBK,MAAM,CAACC,OAAP,GAAiBT,cAAjB","sourcesContent":["/**\n * @classdesc A class that represents the Marketing Cloud object.\n * @constructs MarketingCloud\n * @param {string} name The name of the custom event.\n * @param {string} properties The attributes of the POI such as `name`, `address`, `zipCode` etc.\n */\nclass MarketingCloud {\n Name: string;\n Properties: string;\n constructor(name: string, properties: string) {\n this.Name = name;\n this.Properties = properties;\n }\n /**\n * Converts json object to an object of type MarketingCloud.\n * @param {Object} json The json representation of MarketingCloud.\n * @returns Object\n * @memberof MarketingCloud\n */\n static jsonToObj(json: any) {\n return new MarketingCloud(json.name, json.properties);\n }\n}\nmodule.exports = MarketingCloud;\n"]}
|