Skip to content

Commit ac4ce41

Browse files
improved activity timing
1 parent 50b71ec commit ac4ce41

File tree

2 files changed

+28
-23
lines changed

2 files changed

+28
-23
lines changed

BreinifyApi.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = 'BreinifyApi'
3-
s.version = '2.0.13'
3+
s.version = '2.0.14'
44
s.summary = 'Breinify´s DigitalDNA API puts dynamic behavior-based, people-driven data right at your fingertips'
55
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.'
66
s.homepage = 'https://github.com/Breinify/brein-api-library-ios'

BreinifyApi/api/BreinifyManager.swift

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -251,10 +251,10 @@ open class BreinifyManager: NSObject, UNUserNotificationCenterDelegate {
251251
BreinLogger.shared.log("Breinify UserNotification willPresent invoked with notification: \(notification)")
252252

253253
// due to a possible URLSession connection time out we wait half a second to send a message
254-
// DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 0.5) { [self] in
255-
// let campaignNotificationDic = getCampaignContent(notification.request.content.userInfo)
256-
// sendActivity(BreinActivityType.RECEIVED_PUSH_NOTIFICATION.rawValue, additionalActivityTagContent: campaignNotificationDic)
257-
// }
254+
DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 1.5) { [self] in
255+
let campaignNotificationDic = getCampaignContent(notification.request.content.userInfo)
256+
sendActivity(BreinActivityType.RECEIVED_PUSH_NOTIFICATION.rawValue, additionalActivityTagContent: campaignNotificationDic)
257+
}
258258

259259
completionHandler([.alert, .badge, .sound])
260260
}
@@ -515,7 +515,7 @@ open class BreinifyManager: NSObject, UNUserNotificationCenterDelegate {
515515
BreinLogger.shared.log("Breinify didReceiveRemoteNotification called with notification: \(notification)")
516516

517517
// due to a possible URLSession connection time out we wait half a second to send a message
518-
DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 0.5) { [self] in
518+
DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 1.5) { [self] in
519519
let campaignNotificationDic = getCampaignContent(notification)
520520
sendActivity(BreinActivityType.RECEIVED_PUSH_NOTIFICATION.rawValue, additionalActivityTagContent: campaignNotificationDic)
521521
}
@@ -533,31 +533,36 @@ open class BreinifyManager: NSObject, UNUserNotificationCenterDelegate {
533533
return nil
534534
}
535535

536-
var retVal: Dictionary<String, Any> = [:]
537-
let notiDic = BreinUtil.convertToDictionary(text: prettyPrinted)
538-
notiDic?.forEach {
539-
let key = ($0)
540-
if key.contains("breinify") {
541-
BreinLogger.shared.log("Breinify Tag detected in notification")
542-
if let innerValue = ($1) as? String {
543-
if innerValue != nil {
544-
let innerDic = BreinUtil.convertToDictionary(text: innerValue)
545-
innerDic?.forEach {
546-
let key = $0
547-
let val = $1
548-
if key.contains("campaign") {
549-
if let campaignDic = val as? Dictionary<String, Any> {
550-
retVal = campaignDic
551-
BreinLogger.shared.log("Breinify Campaign content is \(campaignDic)")
536+
do {
537+
var retVal: Dictionary<String, Any> = [:]
538+
let notiDic = BreinUtil.convertToDictionary(text: prettyPrinted)
539+
notiDic?.forEach {
540+
let key = ($0)
541+
if key.contains("breinify") {
542+
BreinLogger.shared.log("Breinify Tag detected in notification")
543+
if let innerValue = ($1) as? String {
544+
if innerValue != nil {
545+
let innerDic = BreinUtil.convertToDictionary(text: innerValue)
546+
innerDic?.forEach {
547+
let key = $0
548+
let val = $1
549+
if key.contains("campaign") {
550+
if let campaignDic = val as? Dictionary<String, Any> {
551+
retVal = campaignDic
552+
BreinLogger.shared.log("Breinify Campaign content is \(campaignDic)")
553+
}
552554
}
553555
}
554556
}
555557
}
556558
}
557559
}
560+
561+
return retVal
562+
} catch {
563+
return nil
558564
}
559565

560-
return retVal
561566
}
562567

563568
public func didFailToRegisterForRemoteNotificationsWithError(_ error: Error) {

0 commit comments

Comments
 (0)