diff --git a/Sources/WEContentExtension/Common/WEConstants.swift b/Sources/WEContentExtension/Common/WEConstants.swift index d082436..60eac10 100644 --- a/Sources/WEContentExtension/Common/WEConstants.swift +++ b/Sources/WEContentExtension/Common/WEConstants.swift @@ -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" } diff --git a/Sources/WEContentExtension/Layouts/Carousel/Helper.swift b/Sources/WEContentExtension/Layouts/Carousel/Helper.swift index 3840cb8..38f906e 100644 --- a/Sources/WEContentExtension/Layouts/Carousel/Helper.swift +++ b/Sources/WEContentExtension/Layouts/Carousel/Helper.swift @@ -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) } } } diff --git a/Sources/WEContentExtension/WEContentExtension.swift b/Sources/WEContentExtension/WEContentExtension.swift index 2ae412a..147567e 100644 --- a/Sources/WEContentExtension/WEContentExtension.swift +++ b/Sources/WEContentExtension/WEContentExtension.swift @@ -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. diff --git a/WEContentExtension.podspec b/WEContentExtension.podspec index 102e657..6886e54 100644 --- a/WEContentExtension.podspec +++ b/WEContentExtension.podspec @@ -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