Skip to content

Commit

Permalink
Merge pull request #60 from woosmap/dev/addcontactKeySMFC
Browse files Browse the repository at this point in the history
add ContactKey in the data send to SFMC
  • Loading branch information
Llumbroso authored Nov 15, 2021
2 parents 41de434 + d4507f6 commit 28c6890
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 7 deletions.
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.2.0'
s.version = '1.3.2'
s.license = 'MIT'
s.summary = 'Geofencing in Swift'
s.homepage = 'https://github.com/woosmap/woosmap-geofencing-ios-sdk'
Expand Down
9 changes: 7 additions & 2 deletions WoosmapGeofencing/Sources/WoosmapGeofencing/APIClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,21 +41,26 @@ class APIClient {
// ensure there is data returned from this HTTP response
guard let content = data else {
print("getBearer - No data")
completion(NSError())
completion(NSError(domain: "No data", code: 0, userInfo:nil))
return
}

// serialise the data / NSData object into Dictionary [String : Any]
guard let json = (try? JSONSerialization.jsonObject(with: content, options: JSONSerialization.ReadingOptions.mutableContainers)) as? [String:Any] else {
print("getBearer - Not containing JSON")
completion(NSError())
completion(NSError(domain: "json", code: 0, userInfo:nil))
return
}

let response = (json.compactMapValues { $0 as? String })
let error_description = response["error_description"] ?? ""
if (error_description.isEmpty) {
SFMCAccesToken = response["access_token"] ?? ""
if(SFMCAccesToken.isEmpty) {
print("Token message " + response.debugDescription )
completion(NSError(domain: error_description, code: 0, userInfo:nil))
return
}
completion(nil)
} else {
print(error_description)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public class DataCleaner {
let predicate = NSPredicate(format: "(date <= %@)", limitDate! as CVarArg)
let locationFetchedResults = realm.objects(Location.self).filter(predicate)
let poiFetchedResults = realm.objects(POI.self).filter(predicate)
let regionFetchedResults = realm.objects(Region.self).filter(predicate)
let visitFetchedResults = realm.objects(Visit.self).filter(predicate)
if !visitFetchedResults.isEmpty {
ZOIs.updateZOI(visits: Array(visitFetchedResults))
Expand All @@ -33,6 +34,7 @@ public class DataCleaner {
realm.delete(locationFetchedResults)
realm.delete(poiFetchedResults)
realm.delete(visitFetchedResults)
realm.delete(regionFetchedResults)
try realm.commitWrite()
} catch {
}
Expand Down
4 changes: 4 additions & 0 deletions WoosmapGeofencing/Sources/WoosmapGeofencing/Monitor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,7 @@ public class LocationService: NSObject, CLLocationManagerDelegate {
func sendASVisitEvents(visit: Visit) {

var propertyDictionary = Dictionary <String, Any>()
propertyDictionary["ContactKey"] = SFMCCredentials["contactKey"] ?? ""
propertyDictionary["event"] = "woos_visit_event"
propertyDictionary["date"] = visit.date?.stringFromDate()
propertyDictionary["arrivalDate"] = visit.arrivalDate?.stringFromDate()
Expand Down Expand Up @@ -706,6 +707,7 @@ public class LocationService: NSObject, CLLocationManagerDelegate {

func sendASPOIEvents(poi: POI) {
var propertyDictionary = Dictionary <String, Any>()
propertyDictionary["ContactKey"] = SFMCCredentials["contactKey"] ?? ""
propertyDictionary["event"] = "woos_poi_event"
propertyDictionary["name"] = poi.name
propertyDictionary["lat"] = poi.latitude
Expand Down Expand Up @@ -736,6 +738,7 @@ public class LocationService: NSObject, CLLocationManagerDelegate {

func sendASRegionEvents(region: Region) {
var propertyDictionary = Dictionary <String, Any>()
propertyDictionary["ContactKey"] = SFMCCredentials["contactKey"] ?? ""
propertyDictionary["lat"] = region.latitude
propertyDictionary["lng"] = region.longitude
propertyDictionary["radius"] = region.radius
Expand Down Expand Up @@ -820,6 +823,7 @@ public class LocationService: NSObject, CLLocationManagerDelegate {

func sendASZOIClassifiedEvents(region: Region) {
var propertyDictionary = Dictionary <String, Any>()
propertyDictionary["ContactKey"] = SFMCCredentials["contactKey"] ?? ""
propertyDictionary["id"] = region.identifier
propertyDictionary["lat"] = region.latitude
propertyDictionary["lng"] = region.longitude
Expand Down
8 changes: 4 additions & 4 deletions WoosmapGeofencing/WoosmapGeofencing.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@
buildSettings = {
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 0;
CURRENT_PROJECT_VERSION = 2;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = 38H4FA3J9J;
DYLIB_COMPATIBILITY_VERSION = 1;
Expand All @@ -482,7 +482,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 1.2;
MARKETING_VERSION = 1.3;
PRODUCT_BUNDLE_IDENTIFIER = WebGeoServices.WoosmapGeofencing;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;
Expand All @@ -497,7 +497,7 @@
buildSettings = {
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 0;
CURRENT_PROJECT_VERSION = 2;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = 38H4FA3J9J;
DYLIB_COMPATIBILITY_VERSION = 1;
Expand All @@ -510,7 +510,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 1.2;
MARKETING_VERSION = 1.3;
PRODUCT_BUNDLE_IDENTIFIER = WebGeoServices.WoosmapGeofencing;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;
Expand Down

0 comments on commit 28c6890

Please sign in to comment.