Skip to content

Commit

Permalink
Merge pull request #70 from woosmap/fix/wrapping
Browse files Browse the repository at this point in the history
fix wrapping on region object
  • Loading branch information
Llumbroso authored Feb 7, 2022
2 parents 8d88343 + 7bcb018 commit 3ee5b5c
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 32 deletions.
2 changes: 1 addition & 1 deletion Sample/Data/DataRegion.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public class DataRegion: RegionsServiceDelegate {
}else {
content.title = "Region exit"
}
content.body = "Region = " + POIregion.identifier!
content.body = "Region = " + POIregion.identifier
content.body += "Lat = " + String(format: "%f", POIregion.latitude) + " Lng = " + String(format: "%f", POIregion.longitude)
if(POIregion.type == "circle") {
content.body += "\n FromPositionDetection = " + String(POIregion.fromPositionDetection)
Expand Down
12 changes: 6 additions & 6 deletions Sample/View/MapViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,8 @@ class MapViewController: UIViewController, MKMapViewDelegate {
if((textField!.text!.isEmpty)){
return
}
let radius = textField!.text!.dropLast()

let radius = textField!.text!
if(textField!.text!.contains("s")) {
let (_, _) = WoosmapGeofencing.shared.locationService.addRegion(identifier: region_identifer, center: coordinate, radius: Int(radius)!, type: "isochrone")
self.initMap()
Expand Down Expand Up @@ -380,11 +380,11 @@ class MapViewController: UIViewController, MKMapViewDelegate {

if region.didEnter {
let circlePOI = MKCircle(center: CLLocationCoordinate2D(latitude: region.latitude, longitude: region.longitude), radius: region.radius)
circlePOI.title = region.identifier! + "ENTER"
circlePOI.title = region.identifier + "ENTER"
self.circlesPOI.append(circlePOI)
mapView.addOverlays(circlesPOI)
} else {
circlesPOI.removeAll(where: {$0.title == (region.identifier! + "ENTER")})
circlesPOI.removeAll(where: {$0.title == (region.identifier + "ENTER")})
mapView.addOverlays(circlesPOI)
}
initMap()
Expand All @@ -403,8 +403,8 @@ class MapViewController: UIViewController, MKMapViewDelegate {
} else {
circle.title = "POI"
if let regionLog = Regions.getRegionFromId(id: region.identifier) {
if(regionLog.didEnter && !self.circlesPOI.contains(where: {$0.title == (regionLog.identifier! + "ENTER")})) {
circle.title = regionLog.identifier! + "ENTER"
if(regionLog.didEnter && !self.circlesPOI.contains(where: {$0.title == (regionLog.identifier + "ENTER")})) {
circle.title = regionLog.identifier + "ENTER"
self.circlesPOI.append(circle)
}
}
Expand Down
2 changes: 1 addition & 1 deletion WoosmapGeofencing.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'WoosmapGeofencing'
s.version = '1.6.0'
s.version = '1.6.1'
s.license = 'MIT'
s.summary = 'Geofencing in Swift'
s.homepage = 'https://github.com/woosmap/woosmap-geofencing-ios-sdk'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@
"repositoryURL": "https://github.com/realm/realm-cocoa",
"state": {
"branch": null,
"revision": "bdbbd57f411a0f4e72b359113dbc6d23fdf96680",
"version": "10.20.0"
"revision": "9dff9f2862240d521ad6ad599541269177ddb993",
"version": "10.22.0"
}
},
{
"package": "RealmDatabase",
"repositoryURL": "https://github.com/realm/realm-core",
"state": {
"branch": null,
"revision": "c3c11a841642ac93c27bd1edd61f989fc0bfb809",
"version": "11.6.1"
"revision": "6b81f1a7a2d421f9e0b9e7f04e76bcf736a54409",
"version": "11.9.0"
}
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import RealmSwift
import CoreLocation

public class Region: Object {
@objc public dynamic var date: Date?
@objc public dynamic var date: Date = Date()
@objc public dynamic var didEnter: Bool = false
@objc public dynamic var identifier: String?
@objc public dynamic var identifier: String = ""
@objc public dynamic var latitude: Double = 0.0
@objc public dynamic var longitude: Double = 0.0
@objc public dynamic var radius: Double = 0.0
Expand Down
32 changes: 16 additions & 16 deletions WoosmapGeofencing/Sources/WoosmapGeofencing/Monitor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ public class LocationService: NSObject, CLLocationManagerDelegate {
public func didEventRegionIsochrone(regionIsochrone: RegionIsochrone) {
let newRegionLog = Regions.add(regionIso: regionIsochrone)
sendASRegionEvents(region: newRegionLog)
if newRegionLog.identifier != nil {
if newRegionLog.identifier != "" {
if (newRegionLog.didEnter) {
self.regionDelegate?.didEnterPOIRegion(POIregion: newRegionLog)
} else {
Expand Down Expand Up @@ -691,13 +691,13 @@ public class LocationService: NSObject, CLLocationManagerDelegate {

func addRegionLogTransition(region: CLRegion, didEnter: Bool, fromPositionDetection: Bool) {
if let regionLog = Regions.getRegionFromId(id: region.identifier) {
if (regionLog.date!.timeIntervalSinceNow > -5) {
if (regionLog.date.timeIntervalSinceNow > -5) {
return
}
if (regionLog.didEnter != didEnter) {
let newRegionLog = Regions.add(POIregion: region, didEnter: didEnter, fromPositionDetection:fromPositionDetection)
sendASRegionEvents(region: newRegionLog)
if newRegionLog.identifier != nil {
if newRegionLog.identifier != "" {
if (didEnter) {
self.regionDelegate?.didEnterPOIRegion(POIregion: newRegionLog)
} else {
Expand All @@ -707,8 +707,8 @@ public class LocationService: NSObject, CLLocationManagerDelegate {
}
} else if (didEnter) {
let newRegionLog = Regions.add(POIregion: region, didEnter: didEnter, fromPositionDetection:fromPositionDetection)
sendASRegionEvents(region: newRegionLog)
if newRegionLog.identifier != nil {
if newRegionLog.identifier != "" {
sendASRegionEvents(region: newRegionLog)
if (didEnter) {
self.regionDelegate?.didEnterPOIRegion(POIregion: newRegionLog)
} else {
Expand Down Expand Up @@ -773,7 +773,7 @@ public class LocationService: NSObject, CLLocationManagerDelegate {
classifiedRegion.radius = radiusDetectionClassifiedZOI
classifiedRegion.latitude = latitude
classifiedRegion.longitude = longitude
classifiedRegion.identifier = classifiedZOI.period
classifiedRegion.identifier = classifiedZOI.period ?? ""
Regions.add(classifiedRegion: classifiedRegion)
self.regionDelegate?.homeZOIEnter(classifiedRegion: classifiedRegion)
sendASZOIClassifiedEvents(region: classifiedRegion)
Expand Down Expand Up @@ -881,8 +881,8 @@ public class LocationService: NSObject, CLLocationManagerDelegate {
propertyDictionary["lng"] = region.longitude
propertyDictionary["radius"] = region.radius

if(getRegionType(identifier: region.identifier!) == RegionType.poi) {
let idStore = region.identifier!.components(separatedBy: "<id>")[1]
if(getRegionType(identifier: region.identifier) == RegionType.poi) {
let idStore = region.identifier.components(separatedBy: "<id>")[1]
guard let poi = POIs.getPOIbyIdStore(idstore: idStore) else {
return
}
Expand All @@ -892,7 +892,7 @@ public class LocationService: NSObject, CLLocationManagerDelegate {
}

if let ASdelegate = self.airshipEventsDelegate {
propertyDictionary["date"] = region.date?.stringFromDate()
propertyDictionary["date"] = region.date.stringFromDate()
if(region.didEnter) {
propertyDictionary["event"] = "woos_geofence_entered_event"
ASdelegate.regionEnterEvent(regionEvent: propertyDictionary, eventName: "woos_geofence_entered_event")
Expand All @@ -903,7 +903,7 @@ public class LocationService: NSObject, CLLocationManagerDelegate {
}

if let MCdelegate = self.marketingCloudEventsDelegate {
propertyDictionary["date"] = region.date?.stringFromISO8601Date()
propertyDictionary["date"] = region.date.stringFromISO8601Date()
if(region.didEnter) {
propertyDictionary["event"] = "woos_geofence_entered_event"
MCdelegate.regionEnterEvent(regionEvent: propertyDictionary, eventName: "woos_geofence_entered_event")
Expand All @@ -914,13 +914,13 @@ public class LocationService: NSObject, CLLocationManagerDelegate {
}

if((SFMCCredentials["regionEnteredEventDefinitionKey"]) != nil && region.didEnter) {
propertyDictionary["date"] = region.date?.stringFromISO8601Date()
propertyDictionary["date"] = region.date.stringFromISO8601Date()
propertyDictionary["event"] = "woos_geofence_entered_event"
SFMCAPIclient.pushDataToMC(poiData: propertyDictionary,eventDefinitionKey: SFMCCredentials["regionEnteredEventDefinitionKey"]!)
}

if((SFMCCredentials["regionExitedEventDefinitionKey"]) != nil && !region.didEnter) {
propertyDictionary["date"] = region.date?.stringFromISO8601Date()
propertyDictionary["date"] = region.date.stringFromISO8601Date()
propertyDictionary["event"] = "woos_geofence_exited_event"
SFMCAPIclient.pushDataToMC(poiData: propertyDictionary,eventDefinitionKey: SFMCCredentials["regionExitedEventDefinitionKey"]!)
}
Expand Down Expand Up @@ -968,7 +968,7 @@ public class LocationService: NSObject, CLLocationManagerDelegate {
propertyDictionary["radius"] = region.radius

if let ASdelegate = self.airshipEventsDelegate {
propertyDictionary["date"] = region.date?.stringFromDate()
propertyDictionary["date"] = region.date.stringFromDate()
if(region.didEnter) {
propertyDictionary["event"] = "woos_zoi_classified_entered_event"
ASdelegate.ZOIclassifiedEnter(regionEvent: propertyDictionary, eventName: "woos_zoi_classified_entered_event")
Expand All @@ -979,7 +979,7 @@ public class LocationService: NSObject, CLLocationManagerDelegate {
}

if let MCdelegate = self.marketingCloudEventsDelegate {
propertyDictionary["date"] = region.date?.stringFromISO8601Date()
propertyDictionary["date"] = region.date.stringFromISO8601Date()
if(region.didEnter) {
propertyDictionary["event"] = "woos_zoi_classified_entered_event"
MCdelegate.ZOIclassifiedEnter(regionEvent: propertyDictionary, eventName: "woos_zoi_classified_entered_event")
Expand All @@ -990,13 +990,13 @@ public class LocationService: NSObject, CLLocationManagerDelegate {
}

if((SFMCCredentials["zoiClassifiedEnteredEventDefinitionKey"]) != nil && region.didEnter) {
propertyDictionary["date"] = region.date?.stringFromISO8601Date()
propertyDictionary["date"] = region.date.stringFromISO8601Date()
propertyDictionary["event"] = "woos_zoi_classified_entered_event"
SFMCAPIclient.pushDataToMC(poiData: propertyDictionary,eventDefinitionKey: SFMCCredentials["zoiClassifiedEnteredEventDefinitionKey"]!)
}

if((SFMCCredentials["zoiClassifiedExitedEventDefinitionKey"]) != nil && !region.didEnter) {
propertyDictionary["date"] = region.date?.stringFromISO8601Date()
propertyDictionary["date"] = region.date.stringFromISO8601Date()
propertyDictionary["event"] = "woos_zoi_classified_exited_event"
SFMCAPIclient.pushDataToMC(poiData: propertyDictionary,eventDefinitionKey: SFMCCredentials["zoiClassifiedExitedEventDefinitionKey"]!)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import RealmSwift
}

private func initRealm() {
Realm.Configuration.defaultConfiguration = Realm.Configuration(schemaVersion: 3)
Realm.Configuration.defaultConfiguration = Realm.Configuration(schemaVersion: 4)
}

public func getLocationService() -> LocationService {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@
repositoryURL = "https://github.com/realm/realm-cocoa";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 10.20.0;
minimumVersion = 10.22.0;
};
};
A2920CDD27690C820024FB06 /* XCRemoteSwiftPackageReference "Surge" */ = {
Expand Down

0 comments on commit 3ee5b5c

Please sign in to comment.