@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,38 @@
|
|
|
1
|
+
//
|
|
2
|
+
// DataSearchAPI.swift
|
|
3
|
+
// WoosmapGeofencing
|
|
4
|
+
//
|
|
5
|
+
//
|
|
6
|
+
|
|
7
|
+
import Foundation
|
|
8
|
+
import CoreLocation
|
|
9
|
+
import WoosmapGeofencing
|
|
10
|
+
|
|
11
|
+
public class DataPOI: SearchAPIDelegate {
|
|
12
|
+
public init() {}
|
|
13
|
+
|
|
14
|
+
public func searchAPIResponse(poi: POI) {
|
|
15
|
+
NotificationCenter.default.post(name: .newPOISaved, object: self, userInfo: ["POI": poi])
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
public func serachAPIError(error: String) {
|
|
19
|
+
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
public func readPOI() -> [POI] {
|
|
23
|
+
return POIs.getAll()
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
func getPOIbyLocationID(locationId: String) -> POI? {
|
|
27
|
+
return POIs.getPOIbyLocationID(locationId: locationId)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
public func erasePOI() {
|
|
31
|
+
POIs.deleteAll()
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
extension Notification.Name {
|
|
37
|
+
static let newPOISaved = Notification.Name("newPOISaved")
|
|
38
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
//
|
|
2
|
+
// DataRegion.swift
|
|
3
|
+
// Sample
|
|
4
|
+
//
|
|
5
|
+
|
|
6
|
+
import Foundation
|
|
7
|
+
|
|
8
|
+
import Foundation
|
|
9
|
+
import UIKit
|
|
10
|
+
import CoreLocation
|
|
11
|
+
import WoosmapGeofencing
|
|
12
|
+
|
|
13
|
+
public class DataRegion: RegionsServiceDelegate {
|
|
14
|
+
|
|
15
|
+
public init() {}
|
|
16
|
+
|
|
17
|
+
public func updateRegions(regions: Set<CLRegion>) {
|
|
18
|
+
NotificationCenter.default.post(name: .updateRegions, object: self, userInfo: ["Regions": regions])
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
public func didEnterPOIRegion(POIregion: Region) {
|
|
22
|
+
NotificationCenter.default.post(name: .didEventPOIRegion, object: self, userInfo: ["Region": POIregion])
|
|
23
|
+
sendNotification(POIregion: POIregion, didEnter: true)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
public func didExitPOIRegion(POIregion: Region) {
|
|
27
|
+
NotificationCenter.default.post(name: .didEventPOIRegion, object: self, userInfo: ["Region": POIregion])
|
|
28
|
+
sendNotification(POIregion: POIregion, didEnter: false)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
public func workZOIEnter(classifiedRegion: Region) {
|
|
32
|
+
NotificationCenter.default.post(name: .didEventPOIRegion, object: self, userInfo: ["Region": classifiedRegion])
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
public func homeZOIEnter(classifiedRegion: Region) {
|
|
36
|
+
NotificationCenter.default.post(name: .didEventPOIRegion, object: self, userInfo: ["Region": classifiedRegion])
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
public func readRegions() -> [Region] {
|
|
40
|
+
return Regions.getAll()
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
public func eraseRegions() {
|
|
44
|
+
Regions.deleteAll()
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
public func sendNotification(POIregion: Region, didEnter: Bool) {
|
|
48
|
+
let content = UNMutableNotificationContent()
|
|
49
|
+
if didEnter {
|
|
50
|
+
content.title = "Region enter"
|
|
51
|
+
} else {
|
|
52
|
+
content.title = "Region exit"
|
|
53
|
+
}
|
|
54
|
+
content.body = "Region = " + POIregion.identifier
|
|
55
|
+
content.body += "Lat = " + String(format: "%f", POIregion.latitude) + " Lng = " + String(format: "%f", POIregion.longitude)
|
|
56
|
+
content.body += "\n FromPositionDetection = " + String(POIregion.fromPositionDetection)
|
|
57
|
+
// Create the request
|
|
58
|
+
let uuidString = UUID().uuidString
|
|
59
|
+
let request = UNNotificationRequest(identifier: uuidString,
|
|
60
|
+
content: content, trigger: nil)
|
|
61
|
+
|
|
62
|
+
let center = UNUserNotificationCenter.current()
|
|
63
|
+
center.getNotificationSettings { settings in
|
|
64
|
+
if settings.authorizationStatus == .authorized {
|
|
65
|
+
// Schedule the request with the system.
|
|
66
|
+
let notificationCenter = UNUserNotificationCenter.current()
|
|
67
|
+
notificationCenter.add(request)
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
extension Notification.Name {
|
|
75
|
+
static let updateRegions = Notification.Name("updateRegions")
|
|
76
|
+
static let didEventPOIRegion = Notification.Name("didEventPOIRegion")
|
|
77
|
+
|
|
78
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
//
|
|
2
|
+
// DataVisit.swift
|
|
3
|
+
//
|
|
4
|
+
// WoosmapGeofencing
|
|
5
|
+
//
|
|
6
|
+
//
|
|
7
|
+
import Foundation
|
|
8
|
+
import CoreLocation
|
|
9
|
+
import WoosmapGeofencing
|
|
10
|
+
|
|
11
|
+
public class DataVisit: VisitServiceDelegate {
|
|
12
|
+
|
|
13
|
+
public init() {}
|
|
14
|
+
|
|
15
|
+
public func processVisit(visit: Visit) {
|
|
16
|
+
NotificationCenter.default.post(name: .newVisitSaved, object: self, userInfo: ["Visit": visit])
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
public func readVisits() -> [Visit] {
|
|
20
|
+
return Visits.getAll()
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
public func eraseVisits() {
|
|
24
|
+
Visits.deleteAll()
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
extension Notification.Name {
|
|
29
|
+
static let newVisitSaved = Notification.Name("newVisitSaved")
|
|
30
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
//
|
|
2
|
+
// DataZOI.swift
|
|
3
|
+
// Sample
|
|
4
|
+
//
|
|
5
|
+
// Created by Mac de Laurent on 26/05/2020.
|
|
6
|
+
// Copyright © 2020 Web Geo Services. All rights reserved.
|
|
7
|
+
//
|
|
8
|
+
|
|
9
|
+
import Foundation
|
|
10
|
+
import WoosmapGeofencing
|
|
11
|
+
|
|
12
|
+
public class DataZOI {
|
|
13
|
+
public init() {}
|
|
14
|
+
|
|
15
|
+
public func readZOIs() -> [ZOI] {
|
|
16
|
+
return ZOIs.getAll()
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
public func eraseZOIs() {
|
|
20
|
+
ZOIs.deleteAll()
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import CoreLocation
|
|
3
|
+
import WoosmapGeofencing
|
|
4
|
+
|
|
5
|
+
class MarketingData {
|
|
6
|
+
var eventname: String = ""
|
|
7
|
+
var properties: [String: Any]
|
|
8
|
+
|
|
9
|
+
required init(eventname: String, properties: [String: Any]) {
|
|
10
|
+
self.eventname = eventname
|
|
11
|
+
self.properties = properties
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
extension Notification.Name {
|
|
16
|
+
static let marketingEvent = Notification.Name("marketingEvent")
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
public class MarketingCloudEvents: MarketingCloudEventsDelegate {
|
|
20
|
+
|
|
21
|
+
public init() {}
|
|
22
|
+
|
|
23
|
+
public func regionEnterEvent(regionEvent: [String: Any], eventName: String) {
|
|
24
|
+
// here you can modify your event name and add your data in the dictonnary
|
|
25
|
+
print("MarketingCloudEvents regionEnterEvent")
|
|
26
|
+
let result: MarketingData = MarketingData.init(eventname: eventName, properties: regionEvent)
|
|
27
|
+
NotificationCenter.default.post(name: .marketingEvent, object: self, userInfo: ["Marketing": result])
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
public func regionExitEvent(regionEvent: [String: Any], eventName: String) {
|
|
31
|
+
// here you can modify your event name and add your data in the dictonnary
|
|
32
|
+
print("MarketingCloudEvents regionExitEvent")
|
|
33
|
+
let result: MarketingData = MarketingData.init(eventname: eventName, properties: regionEvent)
|
|
34
|
+
NotificationCenter.default.post(name: .marketingEvent, object: self, userInfo: ["Marketing": result])
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
public func visitEvent(visitEvent: [String: Any], eventName: String) {
|
|
38
|
+
// here you can modify your event name and add your data in the dictonnary
|
|
39
|
+
print("MarketingCloudEvents visitEvent")
|
|
40
|
+
let result: MarketingData = MarketingData.init(eventname: eventName, properties: visitEvent)
|
|
41
|
+
NotificationCenter.default.post(name: .marketingEvent, object: self, userInfo: ["Marketing": result])
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
public func poiEvent(POIEvent: [String: Any], eventName: String) {
|
|
45
|
+
// here you can modify your event name and add your data in the dictonnary
|
|
46
|
+
print("MarketingCloudEvents poiEvent")
|
|
47
|
+
let result: MarketingData = MarketingData.init(eventname: eventName, properties: POIEvent)
|
|
48
|
+
NotificationCenter.default.post(name: .marketingEvent, object: self, userInfo: ["Marketing": result])
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
public func ZOIclassifiedEnter(regionEvent: [String: Any], eventName: String) {
|
|
52
|
+
// here you can modify your event name and add your data in the dictonnary
|
|
53
|
+
print("MarketingCloudEvents ZOIclassifiedEnter")
|
|
54
|
+
let result: MarketingData = MarketingData.init(eventname: eventName, properties: regionEvent)
|
|
55
|
+
NotificationCenter.default.post(name: .marketingEvent, object: self, userInfo: ["Marketing": result])
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
public func ZOIclassifiedExit(regionEvent: [String: Any], eventName: String) {
|
|
59
|
+
// here you can modify your event name and add your data in the dictonnary
|
|
60
|
+
print("MarketingCloudEvents ZOIclassifiedExit")
|
|
61
|
+
let result: MarketingData = MarketingData.init(eventname: eventName, properties: regionEvent)
|
|
62
|
+
NotificationCenter.default.post(name: .marketingEvent, object: self, userInfo: ["Marketing": result])
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
//
|
|
2
|
+
// MockDataVisit.swift
|
|
3
|
+
// Sample
|
|
4
|
+
//
|
|
5
|
+
// Created by Mac de Laurent on 09/06/2020.
|
|
6
|
+
// Copyright © 2020 Web Geo Services. All rights reserved.
|
|
7
|
+
//
|
|
8
|
+
|
|
9
|
+
import Foundation
|
|
10
|
+
import WoosmapGeofencing
|
|
11
|
+
|
|
12
|
+
// Class to mock the visits in order to create ZOI
|
|
13
|
+
public class MockDataVisit {
|
|
14
|
+
|
|
15
|
+
public init() {}
|
|
16
|
+
|
|
17
|
+
func csv(data: String) -> [[String]] {
|
|
18
|
+
var result: [[String]] = []
|
|
19
|
+
let rows = data.components(separatedBy: "\n")
|
|
20
|
+
for row in rows {
|
|
21
|
+
let columns = row.components(separatedBy: ";")
|
|
22
|
+
if columns[0] != "" {
|
|
23
|
+
result.append(columns)
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return result
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
public func mockVisitData() {
|
|
30
|
+
DataVisit().eraseVisits()
|
|
31
|
+
DataZOI().eraseZOIs()
|
|
32
|
+
if let path = Bundle.main.path(forResource: "Visit_qualif.csv", ofType: nil) {
|
|
33
|
+
if let dataVisit = try? String(contentsOfFile: path, encoding: String.Encoding.utf8) {
|
|
34
|
+
let testDatas = csv(data: dataVisit)
|
|
35
|
+
let dateFormatter = DateFormatter()
|
|
36
|
+
dateFormatter.locale = Locale(identifier: "en_US_POSIX") // set locale to reliable US_POSIX
|
|
37
|
+
dateFormatter.dateFormat = "yyyy-MM-dd' 'HH:mm:ssZ"
|
|
38
|
+
|
|
39
|
+
for linePoint in testDatas {
|
|
40
|
+
let visit = linePoint[0].components(separatedBy: ",")
|
|
41
|
+
|
|
42
|
+
let id = visit[0]
|
|
43
|
+
let accuracy = Double(visit[1])!
|
|
44
|
+
|
|
45
|
+
if accuracy < 20.0 {
|
|
46
|
+
let latLng = visit[2].replacingOccurrences(of: "POINT(", with: "").replacingOccurrences(of: ")", with: "")
|
|
47
|
+
let lng = Double(latLng.components(separatedBy: " ")[0])!
|
|
48
|
+
let lat = Double(latLng.components(separatedBy: " ")[1])!
|
|
49
|
+
|
|
50
|
+
let arrivalDate = dateFormatter.date(from: visit[3])!
|
|
51
|
+
let departureDate = dateFormatter.date(from: visit[4])!
|
|
52
|
+
|
|
53
|
+
let visitToSave = Visit(visitId: id, arrivalDate: arrivalDate, departureDate: departureDate, latitude: lat, longitude: lng, dateCaptured: departureDate, accuracy: accuracy)
|
|
54
|
+
Visits.addTest(visit: visitToSave)
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
NotificationCenter.default.post(name: .reloadData, object: self)
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
public func mockLocationsData() {
|
|
63
|
+
DataLocation().eraseLocations()
|
|
64
|
+
DataVisit().eraseVisits()
|
|
65
|
+
DataZOI().eraseZOIs()
|
|
66
|
+
if let path = Bundle.main.path(forResource: "Locations.csv", ofType: nil) {
|
|
67
|
+
if let dataVisit = try? String(contentsOfFile: path, encoding: String.Encoding.utf8) {
|
|
68
|
+
let testDatas = csv(data: dataVisit)
|
|
69
|
+
let dateFormatter = DateFormatter()
|
|
70
|
+
dateFormatter.locale = Locale(identifier: "en_US_POSIX") // set locale to reliable US_POSIX
|
|
71
|
+
dateFormatter.dateFormat = "yyyy-MM-dd' 'HH:mm:ssZ"
|
|
72
|
+
|
|
73
|
+
for linePoint in testDatas {
|
|
74
|
+
let visit = linePoint[0].components(separatedBy: ",")
|
|
75
|
+
|
|
76
|
+
let id = visit[0]
|
|
77
|
+
let accuracy = Double(visit[1])!
|
|
78
|
+
|
|
79
|
+
if accuracy < 20.0 {
|
|
80
|
+
let latLng = visit[2].replacingOccurrences(of: "POINT(", with: "").replacingOccurrences(of: ")", with: "")
|
|
81
|
+
let lng = Double(latLng.components(separatedBy: " ")[0])!
|
|
82
|
+
let lat = Double(latLng.components(separatedBy: " ")[1])!
|
|
83
|
+
|
|
84
|
+
let arrivalDate = dateFormatter.date(from: visit[3])!
|
|
85
|
+
let departureDate = dateFormatter.date(from: visit[4])!
|
|
86
|
+
|
|
87
|
+
let visitToSave = Visit(visitId: id, arrivalDate: arrivalDate, departureDate: departureDate, latitude: lat, longitude: lng, dateCaptured: departureDate, accuracy: accuracy)
|
|
88
|
+
|
|
89
|
+
let locationToSave = Location(locationId: id, latitude: lat, longitude: lng, dateCaptured: departureDate, descriptionToSave: "mockLocation")
|
|
90
|
+
|
|
91
|
+
let POIToSave = POI(locationId: id, city: "test", zipCode: "75020", distance: 10.0, latitude: lat, longitude: lng, dateCaptured: departureDate)
|
|
92
|
+
|
|
93
|
+
Visits.addTest(visit: visitToSave)
|
|
94
|
+
Locations.addTest(location: locationToSave)
|
|
95
|
+
POIs.addTest(poi: POIToSave)
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
NotificationCenter.default.post(name: .reloadData, object: self)
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
public func mockDataFromSample() {
|
|
104
|
+
DataLocation().eraseLocations()
|
|
105
|
+
DataVisit().eraseVisits()
|
|
106
|
+
DataZOI().eraseZOIs()
|
|
107
|
+
if let path = Bundle.main.path(forResource: "SampleGeofencing.csv", ofType: nil) {
|
|
108
|
+
if let dataCSV = try? String(contentsOfFile: path, encoding: String.Encoding.utf8) {
|
|
109
|
+
let extractedDatas = csv(data: dataCSV)
|
|
110
|
+
let dateFormatter = DateFormatter()
|
|
111
|
+
dateFormatter.locale = Locale(identifier: "en_US_POSIX") // set locale to reliable US_POSIX
|
|
112
|
+
dateFormatter.dateFormat = "yyyy-MM-dd' 'HH:mm:ssZ"
|
|
113
|
+
var id = 0
|
|
114
|
+
var nbrLoc = 0
|
|
115
|
+
for linePoint in extractedDatas {
|
|
116
|
+
if linePoint == extractedDatas.first {
|
|
117
|
+
continue
|
|
118
|
+
}
|
|
119
|
+
id+=1
|
|
120
|
+
let point = linePoint[0].components(separatedBy: ",")
|
|
121
|
+
let creationDate = point[0].replacingOccurrences(of: "Optional(", with: "").replacingOccurrences(of: ")", with: "")
|
|
122
|
+
let lat = Double(point[1])
|
|
123
|
+
let lng = Double(point[2])
|
|
124
|
+
let description = point[3].replacingOccurrences(of: "Optional(", with: "").replacingOccurrences(of: ")", with: "")
|
|
125
|
+
let city = point[4].replacingOccurrences(of: "Optional(", with: "").replacingOccurrences(of: ")", with: "")
|
|
126
|
+
let distance = Double(point[5])
|
|
127
|
+
let zipcode = point[6].replacingOccurrences(of: "Optional(", with: "").replacingOccurrences(of: ")", with: "")
|
|
128
|
+
let type = point[7]
|
|
129
|
+
let accuracy = Double(point[8])
|
|
130
|
+
let arrivalDate = point[9].replacingOccurrences(of: "Optional(", with: "").replacingOccurrences(of: ")", with: "")
|
|
131
|
+
let departureDate = point[10].replacingOccurrences(of: "Optional(", with: "").replacingOccurrences(of: ")", with: "")
|
|
132
|
+
|
|
133
|
+
if type == "location" {
|
|
134
|
+
nbrLoc+=1
|
|
135
|
+
print("location " + String(nbrLoc))
|
|
136
|
+
let locationToSave = Location(locationId: String(id), latitude: lat!, longitude: lng!, dateCaptured: dateFormatter.date(from: creationDate)!, descriptionToSave: description)
|
|
137
|
+
Locations.addTest(location: locationToSave)
|
|
138
|
+
} else if type == "POI" {
|
|
139
|
+
let POIToSave = POI(locationId: String(id),
|
|
140
|
+
city: city,
|
|
141
|
+
zipCode: zipcode,
|
|
142
|
+
distance: distance,
|
|
143
|
+
latitude: lat,
|
|
144
|
+
longitude: lng,
|
|
145
|
+
dateCaptured: dateFormatter.date(from: creationDate))
|
|
146
|
+
POIs.addTest(poi: POIToSave)
|
|
147
|
+
} else if type == "visit" {
|
|
148
|
+
let visitToSave = Visit(visitId: String(id),
|
|
149
|
+
arrivalDate: dateFormatter.date(from: arrivalDate),
|
|
150
|
+
departureDate: dateFormatter.date(from: departureDate),
|
|
151
|
+
latitude: lat!,
|
|
152
|
+
longitude: lng!,
|
|
153
|
+
dateCaptured: dateFormatter.date(from: creationDate),
|
|
154
|
+
accuracy: accuracy!)
|
|
155
|
+
Visits.addTest(visit: visitToSave)
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
NotificationCenter.default.post(name: .reloadData, object: self)
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
extension Notification.Name {
|
|
166
|
+
static let reloadData = Notification.Name("reloadData")
|
|
167
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
#import <React/RCTBridgeModule.h>
|
|
2
|
+
//@interface RCT_EXTERN_REMAP_MODULE(newname, PluginGeofencing, RCTEventEmitter)
|
|
3
|
+
@interface RCT_EXTERN_MODULE(PluginGeofencing, NSObject)
|
|
4
|
+
|
|
5
|
+
RCT_EXTERN_METHOD(multiply:(float)a withB:(float)b
|
|
6
|
+
withResolver:(RCTPromiseResolveBlock)resolve
|
|
7
|
+
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
8
|
+
|
|
9
|
+
RCT_EXTERN_METHOD(initialize:(NSDictionary *)options
|
|
10
|
+
withResolver:(RCTPromiseResolveBlock)resolve
|
|
11
|
+
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
12
|
+
|
|
13
|
+
RCT_EXTERN_METHOD(setWoosmapApiKey:(NSArray *)options
|
|
14
|
+
withResolver:(RCTPromiseResolveBlock)resolve
|
|
15
|
+
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
16
|
+
|
|
17
|
+
RCT_EXTERN_METHOD(startTracking:(NSArray *)options
|
|
18
|
+
withResolver:(RCTPromiseResolveBlock)resolve
|
|
19
|
+
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
20
|
+
|
|
21
|
+
RCT_EXTERN_METHOD(stopTracking:(RCTPromiseResolveBlock)resolve
|
|
22
|
+
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
23
|
+
|
|
24
|
+
RCT_EXTERN_METHOD(requestPermissions:(NSArray *)options
|
|
25
|
+
withResolver:(RCTPromiseResolveBlock)resolve
|
|
26
|
+
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
27
|
+
|
|
28
|
+
RCT_EXTERN_METHOD(getPermissionsStatus:(RCTPromiseResolveBlock)resolve
|
|
29
|
+
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
30
|
+
|
|
31
|
+
RCT_EXTERN_METHOD(watchLocation:(NSString *)watchid
|
|
32
|
+
withResolver:(RCTPromiseResolveBlock)resolve
|
|
33
|
+
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
34
|
+
|
|
35
|
+
RCT_EXTERN_METHOD(clearLocationWatch:(NSString *)watchid
|
|
36
|
+
withResolver:(RCTPromiseResolveBlock)resolve
|
|
37
|
+
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
38
|
+
|
|
39
|
+
RCT_EXTERN_METHOD(clearAllLocationWatch:(RCTPromiseResolveBlock)resolve
|
|
40
|
+
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
RCT_EXTERN_METHOD(watchRegions:(NSString *)watchid
|
|
44
|
+
withResolver:(RCTPromiseResolveBlock)resolve
|
|
45
|
+
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
46
|
+
|
|
47
|
+
RCT_EXTERN_METHOD(clearRegionsWatch:(NSString *)watchid
|
|
48
|
+
withResolver:(RCTPromiseResolveBlock)resolve
|
|
49
|
+
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
50
|
+
|
|
51
|
+
RCT_EXTERN_METHOD(clearAllRegionsWatch:(RCTPromiseResolveBlock)resolve
|
|
52
|
+
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
53
|
+
|
|
54
|
+
RCT_EXTERN_METHOD(setSFMCCredentials:(NSDictionary *)credentials
|
|
55
|
+
withResolver:(RCTPromiseResolveBlock)resolve
|
|
56
|
+
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
57
|
+
|
|
58
|
+
RCT_EXTERN_METHOD(setPoiRadius:(NSString *)radius
|
|
59
|
+
withResolver:(RCTPromiseResolveBlock)resolve
|
|
60
|
+
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
61
|
+
|
|
62
|
+
@end
|