Skip to content

Commit

Permalink
Merge pull request #3 from WebEngage/develop
Browse files Browse the repository at this point in the history
cta deeplink issue fix
  • Loading branch information
MilindWebEngage authored Jul 29, 2024
2 parents 271de2e + dbf57b1 commit 3e8acc0
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 32 deletions.
2 changes: 1 addition & 1 deletion Sources/WEContentExtension/Common/WEConstants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ struct WEConstants{
static let WENOTIFICATIONGROUP = "WEGNotificationGroup"
static let WEBENGAGE = "webengage"
static let WEX_APP_GROUP = "WEX_APP_GROUP"
static let WEX_CONTENT_EXTENSION_VERSION = "1.1.0"
static let WEX_CONTENT_EXTENSION_VERSION = "1.1.1"
static let WEX_CONTENT_EXTENSION_VERSION_STRING = "WEContentExtension_version"
static let WHITECOLOR = "#FFFFFF"
}
17 changes: 6 additions & 11 deletions Sources/WEContentExtension/Layouts/Carousel/Helper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -195,17 +195,12 @@ extension WEXCarouselPushNotificationViewController{
}

func setCTAForIndex(_ index: Int) {
if let expandableDetails = notification?.request.content.userInfo[WEConstants.EXPANDABLEDETAILS] as? [String: Any],
let items = expandableDetails[WEConstants.ITEMS] as? [String: Any] {
let keys = Array(items.keys)
if index < keys.count, let viewController = self.viewController {
let key = keys[index]
if let item = items[key] as? [String: Any] {
let ctaId = item["id"] as? String ?? ""
let actionLink = item[WEConstants.ACTION_LINK] as? String ?? ""
viewController.setCTAWithId(ctaId, andLink: actionLink)
}
}
let expandableDetails = notification?.request.content.userInfo[WEConstants.EXPANDABLEDETAILS] as? [String: Any]
let items = expandableDetails?[WEConstants.ITEMS] as? [Any]
if let currentItem = items?[index] as? [String: Any] {
let ctaId = currentItem["id"] as? String ?? ""
let actionLink = currentItem[WEConstants.ACTION_LINK] as? String ?? ""
self.viewController?.setCTAWithId(ctaId, andLink: actionLink)
}
}
}
45 changes: 26 additions & 19 deletions Sources/WEContentExtension/WEContentExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -143,27 +143,34 @@ open class WEXRichPushNotificationViewController: UIViewController,UNNotificatio

// Returns an activity dictionary for the current notification.
func getActivityDictionaryForCurrentNotification() -> NSMutableDictionary {
guard let userInfo = notification?.request.content.userInfo as? [String: Any],
let expId = userInfo[WEConstants.EXPERIMENT_ID] as? String,
let notifId = userInfo[WEConstants.NOTIFICATION_ID] as? String else {
return NSMutableDictionary()
}

let finalNotifId = "\(expId)|\(notifId)"
let expandableDetails = userInfo[WEConstants.EXPANDABLEDETAILS]
let customData = userInfo[WEConstants.CUSTOM_DATA] as? [Any]

let dictionary = (richPushDefaults?.dictionary(forKey: finalNotifId) as? NSMutableDictionary) ?? NSMutableDictionary()
if dictionary.count == 0 {
dictionary[WEConstants.EXPERIMENT_ID] = expId
dictionary[WEConstants.NOTIFICATION_ID] = notifId
dictionary[WEConstants.EXPANDABLEDETAILS] = expandableDetails
if let customData = customData {
dictionary[WEConstants.CUSTOM_DATA] = customData

guard let userInfo = notification?.request.content.userInfo as? [String: Any],
let expId = userInfo[WEConstants.EXPERIMENT_ID] as? String,
let notifId = userInfo[WEConstants.NOTIFICATION_ID] as? String else {
return NSMutableDictionary()
}

let finalNotifId = "\(expId)|\(notifId)"
let expandableDetails = userInfo[WEConstants.EXPANDABLEDETAILS]
let customData = userInfo[WEConstants.CUSTOM_DATA] as? [Any]

var dictionary: NSMutableDictionary
if let storedDictionary = richPushDefaults?.dictionary(forKey: finalNotifId) {
dictionary = NSMutableDictionary(dictionary: storedDictionary)
} else {
dictionary = NSMutableDictionary()
}

if dictionary.count == 0 {
dictionary[WEConstants.EXPERIMENT_ID] = expId
dictionary[WEConstants.NOTIFICATION_ID] = notifId
dictionary[WEConstants.EXPANDABLEDETAILS] = expandableDetails
if let customData = customData {
dictionary[WEConstants.CUSTOM_DATA] = customData
}
}
return dictionary
}
return dictionary
}

/// - Parameters:
/// - object: The value to be set for the specified key in the activity dictionary.
Expand Down
2 changes: 1 addition & 1 deletion WEContentExtension.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'WEContentExtension'
s.version = '1.1.0'
s.version = '1.1.1'
s.summary = 'Extension Target SDK for adding WebEngage Rich Push Notifications support'

s.description = <<-DESC
Expand Down

0 comments on commit 3e8acc0

Please sign in to comment.