Skip to content

Commit

Permalink
additional logging added
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoRecchioni committed Nov 22, 2021
1 parent c320738 commit 1ca45fe
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
2 changes: 1 addition & 1 deletion BreinifyApi.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'BreinifyApi'
s.version = '2.0.17'
s.version = '2.0.18'
s.summary = 'Breinify´s DigitalDNA API puts dynamic behavior-based, people-driven data right at your fingertips'
s.description = 'Breinify´s DigitalDNA API puts dynamic behavior-based, people-driven data right at your fingertips. We believe that in many situations, a critical component of a great user experience is personalization. With all the data available on the web it should be easy to provide a unique experience to every visitor, and yet, sometimes you may find yourself wondering why it is so difficult.'
s.homepage = 'https://github.com/Breinify/brein-api-library-ios'
Expand Down
4 changes: 1 addition & 3 deletions BreinifyApi/api/Breinify.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ open class Breinify: NSObject {
typealias apiFailure = (_ error: NSDictionary) -> Void

/// contains the current version of the library
static let version: String! = "2.0.16"
static let version: String! = "2.0.18"

/// contains the configuration
static var config: BreinConfig?
Expand Down Expand Up @@ -151,7 +151,6 @@ open class Breinify: NSObject {
let lastName: String = userInfo?[BreinUser.UserInfo.lastName] ?? ""
let phone: String = userInfo?[BreinUser.UserInfo.phoneNumber] ?? ""
let email: String = userInfo?[BreinUser.UserInfo.email] ?? ""
// let userId: String = userInfo?[BreinUser.UserInfo.userId] ?? ""

Breinify.setUserInfo(firstName: firstName,
lastName: lastName,
Expand Down Expand Up @@ -269,7 +268,6 @@ open class Breinify: NSObject {

activity.setTagsDic(tagsDic)

// invoke activity call
do {
try Breinify.activity(activity,
successBlock,
Expand Down
17 changes: 9 additions & 8 deletions BreinifyApi/api/BreinifyManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ open class BreinifyManager: NSObject, UNUserNotificationCenterDelegate {
let campaignNotificationDic = getCampaignContent(response.notification.request.content.userInfo)
sendActivity(BreinActivityType.OPEN_PUSH_NOTIFICATION.rawValue, additionalActivityTagContent: campaignNotificationDic)

BreinLogger.shared.log("Breinify invoking handleIncomingNotificationContent from didReceive method")
handleIncomingNotificationContent(response.notification.request.content.userInfo)

completionHandler()
Expand All @@ -318,14 +319,14 @@ open class BreinifyManager: NSObject, UNUserNotificationCenterDelegate {
let campaignNotificationDic = getCampaignContent(userInfo)
sendActivity(BreinActivityType.RECEIVED_PUSH_NOTIFICATION.rawValue, additionalActivityTagContent: campaignNotificationDic)
}

}

private func handleIncomingNotificationContent(_ notification: [AnyHashable: Any]) {
BreinLogger.shared.log("Breinify handleIncomingNotificationContent invoked with notification: \(notification)")

let actionNotificationDic = getActionContent(notification)
guard let unwrappedDic = actionNotificationDic else {
BreinLogger.shared.log("Breinify handleIncomingNotificationContent - no action content detected on: \(notification)")
return
}

Expand All @@ -335,26 +336,30 @@ open class BreinifyManager: NSObject, UNUserNotificationCenterDelegate {
BreinLogger.shared.log("Breinify action: \(action) with parameter: \(parameter)")

if action == "openUrl" {
BreinLogger.shared.log("Breinify openUrl action detected")
let sharedSelector = NSSelectorFromString("sharedApplication")
let openSelector = NSSelectorFromString("openURL:")

let urlStr = getUrl(parameter)
if urlStr.isEmpty == false {

BreinLogger.shared.log("Breinify trying to open url: \(urlStr)")
DispatchQueue.main.async {
if let urlToOpen = URL(string: urlStr), UIApplication.responds(to: sharedSelector),
let shared = UIApplication.perform(sharedSelector)?.takeRetainedValue() as? UIApplication, shared.responds(to: openSelector) {
BreinLogger.shared.log("Breinify performing action - urlToOpen is: \(urlToOpen)")
shared.perform(openSelector, with: urlToOpen)
}
}
}
} else if action == "sendActivity" {
BreinLogger.shared.log("Breinify sendActivity action detected")
// send activity
let activityName = getActivityName(parameter)
if activityName.isEmpty == false {
let tags = getTags(parameter)
if tags?.isEmpty == false {
// send the activity
BreinLogger.shared.log("Breinify sending action detected with name: \(activityName) and tags: \(tags)")
BreinifyManager.shared.sendActivity(activityName, additionalActivityTagContent: tags)
}
}
Expand Down Expand Up @@ -656,7 +661,6 @@ open class BreinifyManager: NSObject, UNUserNotificationCenterDelegate {
let campaignNotificationDic = getCampaignContent(notification)
sendActivity(BreinActivityType.RECEIVED_PUSH_NOTIFICATION.rawValue, additionalActivityTagContent: campaignNotificationDic)
}

}

/// Provides the campaign related content as a dictionary
Expand Down Expand Up @@ -688,7 +692,7 @@ open class BreinifyManager: NSObject, UNUserNotificationCenterDelegate {
notiDic?.forEach {
let key = ($0).lowercased()
if key.contains("breinify") {
BreinLogger.shared.log("Breinify Tag detected in notification")
BreinLogger.shared.log("Breinify Tag detected in notification for content: \(content)")
if let innerValue = ($1) as? String {

let innerDic = BreinUtil.convertToDictionary(text: innerValue)
Expand All @@ -698,11 +702,10 @@ open class BreinifyManager: NSObject, UNUserNotificationCenterDelegate {
if key.contains(content) {
if let contentDic = val as? Dictionary<String, Any> {
retVal = contentDic
BreinLogger.shared.log("Breinify content is \(contentDic)")
BreinLogger.shared.log("Breinify content (\(content)) is \(contentDic)")
}
}
}

}
}
}
Expand All @@ -712,8 +715,6 @@ open class BreinifyManager: NSObject, UNUserNotificationCenterDelegate {

}



public func didFailToRegisterForRemoteNotificationsWithError(_ error: Error) {
BreinLogger.shared.log("Breinify didFailToRegisterForRemoteNotificationsWithError called")
}
Expand Down

0 comments on commit 1ca45fe

Please sign in to comment.