Releases: lithiumtech/ios-brandmessenger-sdk-dist
1.8.0
Breaking Changes:
KBMRichMessageStyles.KBMCardStyle.shared.actionButton.deactivatedTextStyle
has been removed.
Changes:
Added customization options for typing indicator
The typing indicator can be customized by adding your own animation images to loop through and setting animation duration for speed.
Use the below to configure:
var animationImages = [UIImage]()
animationImages.append(image1)
animationImages.append(image2)
animationImages.append(image3)
animationImages.append(image4)
/// Typing view default minimum height.
config.chatBar.typingViewStyle.typingViewMinimumHeight = 40.0
/// Animation duration in TimeInterval seconds.
config.chatBar.typingViewStyle.animationDuration = 1.3
/// If false, then it will show the typing string at the front of the anmiation dots.
config.chatBar.typingViewStyle.hideTypingString = true
/// Array of animation images for animating.
config.chatBar.typingViewStyle.animationImages = animationImages
/// Background color of Typing view.
config.chatBar.typingViewStyle.backgroundColor = .white
An optional string before the animation images can be added by turning off hideTypingString
config.chatBar.typingViewStyle.hideTypingString = false
and adding string to Localizable.string
.
/// You can change the suffix text
com.kbm.IsTyping = "%@ is typing";
/// You can change the prefix text
com.kbm.TypingStatusDefaultPrefixName = "Agent";
Added various customization options for rich card messages
/// Use this to set the background of the card view.
KBMRichMessageStyles.KBMCardStyle.shared.backgroundColor = .white
/// Border width of card view.
KBMRichMessageStyles.KBMCardStyle.shared.borderWidth = 0
/// Border color of card view
KBMRichMessageStyles.KBMCardStyle.shared.borderColor = UIColor.lightGray.cgColor
// Title Style
/// Use this to set the padding of the subtitle label.
KBMRichMessageStyles.KBMCardStyle.shared.titleLabel.outerPadding = Padding(left: 10.0, right: 10.0, top: 10.0, bottom: 0.0)
/// Use this to set the style of subtitle.
KBMRichMessageStyles.KBMCardStyle.shared.titleLabel.textStyle = Style(font: UIFontMetrics(forTextStyle: .title3).scaledFont(for: UIFont.font(.medium(size: 18))), text: UIColor(red: 20, green: 19, blue: 19))
// Subtitle Style
/// Use this to set the padding of the subtitle label.
KBMRichMessageStyles.KBMCardStyle.shared.subtitleLabel.padding = Padding(left: 10.0, right: 10.0, top: 10.0, bottom: 0.0)
/// Use this to set the style of subtitle.
KBMRichMessageStyles.KBMCardStyle.shared.subtitleLabel.textStyle = Style(font: UIFontMetrics(forTextStyle: .subheadline).scaledFont(for: UIFont.font(.normal(size: 14))), text: UIColor(red: 86, green: 84, blue: 84))
// Description Label Style
/// Use this to set the padding for description label.
KBMRichMessageStyles.KBMCardStyle.shared.descriptionLabel.padding = Padding(left: 10.0, right: 10.0, top: 10.0, bottom: 0.0)
KBMRichMessageStyles.KBMCardStyle.shared.descriptionLabel.textStyle = Style(font: UIFontMetrics(forTextStyle: .body).scaledFont(for: UIFont.font(.light(size: 14))), text:.black)
// Action button styles
/// Spacing between the buttons.
KBMRichMessageStyles.KBMCardStyle.shared.actionButton.spacing = 10
/// Corner radius of button.
KBMRichMessageStyles.KBMCardStyle.shared.actionButton.cornerRadius = 0
/// Border width of button.
KBMRichMessageStyles.KBMCardStyle.shared.actionButton.borderWidth = 1
/// Use this to set the border color of button.
KBMRichMessageStyles.KBMCardStyle.shared.actionButton.borderColor = UIColor.red.cgColor
/// Outer padding of button views.
KBMRichMessageStyles.KBMCardStyle.shared.actionButton.outerPadding = Padding(left: 10.0, right: 10.0, top: 10.0, bottom: 10.0)
/// Inner padding for action button text.
KBMRichMessageStyles.KBMCardStyle.shared.actionButton.padding = Padding(left: 20.0, right: 20.0, top: 10.0, bottom: 10.0)
/// Use this to style action button text.
KBMRichMessageStyles.KBMCardStyle.shared.actionButton.textStyle = Style(font: UIFontMetrics(forTextStyle: .subheadline).scaledFont(for: UIFont.font(.medium(size: 15))), text: .red)
Added padding customization options to quick reply, link, submit buttons
/// Spacing between the two horizontal buttons.
KBMRichMessageStyles.KBMQuickReplyButtonStyle.shared.horizontalSpacing = 10
/// Spacing between the two vertical buttons.
KBMRichMessageStyles.KBMQuickReplyButtonStyle.shared.verticalSpacing = 10
Added option to add icons to buttons.
Rich Card message link button:
/// Link button: Size of image.
/// Default size : width 12 and height 12.
KBMRichMessageStyles.KBMCardStyle.shared.actionButton.imageSize = CGSize(width: 12, height: 12)
/// Link button: Space between image and text.
/// Default Spacing: 10
KBMRichMessageStyles.KBMCardStyle.shared.actionButton.textImageSpace = 10
/// Link button: If true, then it will ignore applying `textStyle` text color and will use the actual image color
KBMRichMessageStyles.KBMCardStyle.shared.actionButton.disableImageTintColor = false
/// Link button: use this to set your own Icon of link button which is right of text.
/// Default icon: Added from SDK which has icon name `link`
KBMRichMessageStyles.KBMCardStyle.shared.actionButton.linkIcon = UIImage(named: "link", in: Bundle(for: SuggestedReplyView.self), compatibleWith: nil)
Quick Reply link button:
/// Link button: If true, then it will ignore applying the `curvedButtonTextStyle` text color and will use the actual image color
KBMRichMessageStyles.KBMQuickReplyButtonStyle.shared.disableImageTintColor = false
/// Link button: Space between image and text.
/// Default Spacing: 10
KBMRichMessageStyles.KBMQuickReplyButtonStyle.shared.textImageSpace = 10
/// Link button: Size of image.
/// Default size : width 12 and height 12.
KBMRichMessageStyles.KBMQuickReplyButtonStyle.shared.imageSize = .init(width: 12, height: 12)
/// Link button: use this to set your own Icon of the link button which is right of the text.
/// Default icon: Added from SDK which has icon name `link`
KBMRichMessageStyles.KBMQuickReplyButtonStyle.shared.linkIcon = UIImage(named: "link", in: Bundle(for: SuggestedReplyView.self), compatibleWith: nil)
Added grouping of consecutive messages from same sender
Improved logic with Suggested Reply Requests being hidden at a message-level when responded to
Bug Fixes:
- Fixed issue with new suggested reply message cards being disabled
- Fixed potential issue with notifications appearing on chat screen
- Fixed issue with opened images not loading properly first time
- Fixed issue with incoming messages not loading automatically
1.7.0
Breaking changes
Namespacing customizable strings
All customizable strings in Localizable.strings have been prefixed with com.kbm.
Removed ListTemplateStyle textStyle
KBMRichMessageStyles.KBMListTemplateStyle.shared.headerText.textStyle
has been removed. Uses KBMRichMessageStyles.KBMListTemplateStyle.shared.headerText.activeButtonTextStyle
and KBMRichMessageStyles.KBMListTemplateStyle.shared.headerText.deactivatedButtonTextStyle
instead.
Changes:
Date formatting
Date section separator
Added customization option for date-separator am/pm symbol. Customize by adding to Localizable.strings
com.kbm.DateSectionHeaderDateFormat = "dd MMM yyyy, h:mma";
com.kbm.DateSectionHeaderAMSymbol = "am"
com.kbm.DateSectionHeaderPMSymbol = "pm"
Message
Added customization option for message-level timestamp. Customize by adding to Localizable.strings
com.kbm.MessageTimestampDateFormat = "h:mm a"
com.kbm.MessageTimestampAMSymbol = "am"
com.kbm.MessageTimestampPMSymbol = "pm"
Suggested Replies
Suggested-Reply responses now have added postback metadata.
Suggested-Reply buttons are disabled when responded to.
Action buttons styling
With suggested replies postback, new disabled styling options have been added.
KBMRichMessageStyles.KBMListTemplateStyle.shared.actionButton.activeButtonTextStyle = Style(font: UIFontMetrics(forTextStyle: .subheadline).scaledFont(for: UIFont.font(.bold(size: 15))), text: UIColor(red: 255, green: 0, blue: 0))
KBMRichMessageStyles.KBMListTemplateStyle.shared.actionButton.deactivatedButtonTextStyle = Style(font: UIFontMetrics(forTextStyle: .subheadline).scaledFont(for: UIFont.font(.bold(size: 15))), text: UIColor.red)
KBMRichMessageStyles.KBMCardStyle.shared.actionButton.textStyle = Style(font: UIFontMetrics(forTextStyle: .subheadline).scaledFont(for: UIFont.font(.medium(size: 15))), text: UIColor(red: 255, green: 0, blue: 0))
KBMRichMessageStyles.KBMCardStyle.shared.actionButton.deactivatedTextStyle = Style(font: UIFontMetrics(forTextStyle: .subheadline).scaledFont(for: UIFont.font(.medium(size: 15))), text: UIColor.red)
KBMRichMessageStyles.KBMQuickReplyButtonStyle.shared.buttonColor.deactivatedButtonColor = UIColor.red
Bug fixes:
- Fixed height inconsistency on Suggested-Reply buttons.
- Adjusted received message timestamp alignment.
- Adjusted padding between name and bubble to match bubble and timestamp
- Fixed spacing between messages for image-messages.
- Adjusted padding between timestamp and message-sent-status icon
- Fixed various conflicting constraint warning in rich messages.
- Fixed system-header height issue with accessibility.
1.6.0
Changes
Improved voice-over assist for messages with split focus points.
Add option to change date-format in conversation date separator.
To customize, add following format into to Localizable.strings
.
DateSectionHeaderDateFormat = "dd MMM yyyy, h:mma";
Added option to hide line above chatbar.
var config = KBMConfiguration()
config.chatBar.hideAboveLineView = true
BrandMessengerManager.setDefaultConfiguration(config)
Adjusted default padding on conversation screen. Padding can be customized with following:
KBMMessageStyle.sentBubble.cellMargin = .init(left: 20, right: 20)
KBMMessageStyle.receivedBubble.cellMargin = .init(left: 20, right: 20)
Updated default sent-status icon size and color. Icon size can be customized with following:
KBMMessageStyle.messageStatus.stateViewSize = CGSize(width: 20, height: 20)
Updated default message-time-status text color. Time text style can be customized with following:
KBMMessageStyle.time = Style(font: UIFontMetrics(forTextStyle: .footnote).scaledFont(for: UIFont.font(.italic(size: 12))), text: UIColor.red)
Bug fixes
- Fixed system-header edge insets.
- Fixed system-header custom text-colors not applying.
- Fixed certificate-pinning on authentication-handler endpoints not applying.
- Fixed issue with image messages overlapping next message.
- Fixed multiple suggested-reply rendering issue on last item.
- Fixed height on Card ActionButton rows.
This can be further customized withKBMRichMessageStyles.KBMCardStyle.shared.actionButton.verticalPadding = 10
1.5.0
Changes
- Added NotificationCenter broadcast for back-button event.
NotificationCenter.default.post(name: Notification.Name(rawValue: "KBMConversationViewController.backTapped"), object: nil)
- Generic notification text for new messages has been updated.
- Added device-key to use KBMEncryptionDelegate when delegate is implemented, with key
KBM_DEVICE_KEY
.
Accessibility fixes
- Fixed voice callout of Buttons.
- Fixed hit-area size of Buttons.
- Fixes text-size scaling with large font accessibility.
- Fixed voice callout of text-input-area.
- Fixed hint-text color contrast
Breaking changes
pinnedHeaderHeight
KBMPinnedSystemHeaderConfig().pinnedHeaderHeight has been removed. It is now calculated dynamically based on text length and font size.
Rich Message Styling
Some rich message Styles settings have changed.
Customize Quick-Reply and AppLink buttons
KBMRichMessageStyles.KBMQuickReplyButtonStyle.shared.buttonColor.border = UIColor.red.cgColor
KBMRichMessageStyles.KBMQuickReplyButtonStyle.shared.buttonColor.background = .white
KBMRichMessageStyles.KBMQuickReplyButtonStyle.shared.borderWidth = 1
KBMRichMessageStyles.KBMQuickReplyButtonStyle.shared.cornerRadius = 2
KBMRichMessageStyles.KBMQuickReplyButtonStyle.shared.buttonColor.tint = .orange
KBMRichMessageStyles.KBMQuickReplyButtonStyle.shared.curvedButtonTextStyle = Style(font: UIFontMetrics(forTextStyle: .subheadline).scaledFont(for: UIFont(name: "HelveticaNeue", size: CGFloat(14)) ?? .systemFont(ofSize: 14)), text: UIColor.systemPink)
Customize Card rich messages
KBMRichMessageStyles.KBMCardStyle.shared.overlayLabel.textStyle = Style(font: UIFontMetrics(forTextStyle: .body).scaledFont(for: UIFont.font(.medium(size: 12))), text: .red)
KBMRichMessageStyles.KBMCardStyle.shared.overlayLabel.backgroundColor = .white
KBMRichMessageStyles.KBMCardStyle.shared.ratingLabel.textStyle = Style(font: UIFontMetrics(forTextStyle: .footnote).scaledFont(for: UIFont.font(.normal(size: 12))), text: .red)
KBMRichMessageStyles.KBMCardStyle.shared.titleLabel.textStyle = Style(font: UIFontMetrics(forTextStyle: .title3).scaledFont(for: UIFont.font(.medium(size: 18))), text: .red)
KBMRichMessageStyles.KBMCardStyle.shared.subtitleLabel.textStyle = Style(font: UIFontMetrics(forTextStyle: .subheadline).scaledFont(for: UIFont.font(.normal(size: 14))), text: .red)
KBMRichMessageStyles.KBMCardStyle.shared.descriptionLabel.textStyle = Style(font: UIFontMetrics(forTextStyle: .subheadline).scaledFont(for: UIFont.font(.light(size: 14))), text: UIColor(red: 121, green: 116, blue: 116))
KBMRichMessageStyles.KBMCardStyle.shared.actionButton.textStyle = Style(font: UIFontMetrics(forTextStyle: .subheadline).scaledFont(for: UIFont.font(.medium(size: 15))), text: .red)
KBMRichMessageStyles.KBMCardStyle.shared.actionButton.backgroundColor = .white
Customize List template rich messages
KBMRichMessageStyles.KBMListTemplateStyle.shared.headerText.textStyle = Style(font: UIFontMetrics(forTextStyle: .subheadline).scaledFont(for: UIFont.font(.normal(size: 15))), text: .red)
KBMRichMessageStyles.KBMListTemplateStyle.shared.headerText.backgroundColor = .yellow
KBMRichMessageStyles.KBMListTemplateStyle.shared.actionButton.backgroundColor = .blue
KBMRichMessageStyles.KBMListTemplateStyle.shared.actionButton.textStyle = Style(font: UIFontMetrics(forTextStyle: .subheadline).scaledFont(for: UIFont.font(.bold(size: 15))), text: .white)
KBMRichMessageStyles.KBMListTemplateStyle.shared.listTemplateElementViewStyle.backgroundColor = .white
KBMRichMessageStyles.KBMListTemplateStyle.shared.listTemplateElementViewStyle.titleTextStyle = Style(font: UIFontMetrics(forTextStyle: .subheadline).scaledFont(for: UIFont.font(.normal(size: 14))), text: UIColor(red: 86, green: 84, blue: 84))
KBMRichMessageStyles.KBMListTemplateStyle.shared.listTemplateElementViewStyle.subtitleTextStyle = Style(font: UIFontMetrics(forTextStyle: .subheadline).scaledFont(for: UIFont.font(.normal(size: 14))), text: UIColor(red: 121, green: 116, blue: 116))
Bug fixes
- Fixed issue with Login skipping steps if previous session token was still valid.
- Fixed a crash when KBM_PASSWORD was nil.
- Fixed an issue with Virtual Agent avatar not displaying.
- Fixed an issue with message attachments sometimes not showing.
1.4.0
Notification Customization
A way to customize the push-notification banner on the front-end has been added. This requires the following steps to enable on the app consuming the BrandMessenger SDK.
1) Create new Notification Service Extension target
From Xcode, in project TARGETS
, add a new target of type Notification Service Extension
. Official instructions are https://developer.apple.com/documentation/usernotifications/modifying_content_in_newly_delivered_notifications?language=objc
2) Update NotificationService file
A new NotificationService
class file should be created. This class should be updated to look like below.
import UserNotifications
class NotificationService: UNNotificationServiceExtension {
var contentHandler: ((UNNotificationContent) -> Void)?
var bestAttemptContent: UNMutableNotificationContent?
override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) {
self.contentHandler = contentHandler
bestAttemptContent = (request.content.mutableCopy() as? UNMutableNotificationContent)
if let bestAttemptContent = bestAttemptContent {
// Modify the notification content here...
/// Brand messenger notification
if isBrandMessengerChatNotificaiton(content: request.content) {
bestAttemptContent.title = NSLocalizedString("GenericNotificationTitle", tableName: nil, bundle: .main, value: "Chat", comment: "")
bestAttemptContent.body = NSLocalizedString("GenericNotificationContentText", tableName: nil, bundle: .main, value: "You have a new message.", comment: "")
}
contentHandler(bestAttemptContent)
}
}
override func serviceExtensionTimeWillExpire() {
// Called just before the extension will be terminated by the system.
// Use this as an opportunity to deliver your "best attempt" at modified content, otherwise the original push payload will be used.
if let contentHandler = contentHandler, let bestAttemptContent = bestAttemptContent {
contentHandler(bestAttemptContent)
}
}
/// Use this method to check for notification for Brand Messenger.
/// - Parameter content:Pass `UNNotificationContent` object for notification userInfo payload.
/// - Returns: Returns `true` if it's a Brand Messenger notification otherwise `false`.
func isBrandMessengerChatNotificaiton(content: UNNotificationContent) -> Bool {
let prefix = "BRANDMESSENGER_"
let notificationKey = "AL_KEY"
guard let brandMessengerPrefix = content.userInfo[notificationKey] as? String, brandMessengerPrefix.hasPrefix(prefix) else {
return false
}
return true
}
}
3) Bundle Localizable.strings into extension
In Xcode, in Project settings, select the newly created Notification Service Extension TARGET
. Go to Build Phases
tab, and in Copy Bundle Resources
, add the app's Localizable.strings
file.
4) Modify the notification string values
In the Localizable.strings
file, add values for GenericNotificationTitle
and GenericNotificationContentText
to set them on the incoming push-notification banners.
GenericNotificationTitle = "Khoros Chat";
GenericNotificationContentText = "You have a new message!";
Welcome-Header
Previous welcome-header message, set with StartOfConversation
scrolled with the conversation. This is still in place with default values changed to empty, and a new 'pinned' system message has been added. Remove StartOfConversation
, LinkText
and LinkValue
from Localizable.strings to hide the scrolling welcome-header message.
Pinned system message
This is hidden by default. Use the following to enable and configure:
Set the show by setting hidePinnedSystemMessageHeader
to false and configure style
var config = KBMConfiguration()
var headerConfig = KBMPinnedSystemHeaderConfig()
headerConfig.pinnedHeaderHeight = 80
headerConfig.pinnedSystemMessageIcon = UIImage(named: "iconChat")
config.pinnedHeaderConfig = headerConfig
config.hidePinnedSystemMessageHeader = false
BrandMessengerManager.setDefaultConfiguration(config)
The default KBMPinnedSystemHeaderConfig
is as follows:
public struct KBMPinnedSystemHeaderConfig {
public var textColor = UIColor.black
public var headerBackgroundColor = UIColor.white
public var kLabelInsets = UIEdgeInsets(top: 12, left: 10, bottom: 0, right: 12)
public var kLabelLineSpacing = 2.0
public var kLabelParagraphSpacing = 7.0
public var textStyle = Style(
font: Font.normal(size: 12.0).font(),
text: .text(.black00)
)
public var pinnedSystemMessageIcon = UIImage(named: "placeholder")
public var kIconWidth = 10.0
public var kIconHeight = 10.0
public var linkTextColor = UIColor.black
public var linkUnderlineColor = UIColor.black
///height of pinned system message, can be customised here
public var pinnedHeaderHeight = 45.0
public init(){}
}
Set the text and link by adding following into Localizable.strings
PinnedSystemMessageText = "Welcome, click the link to go to www.khoros.com";
PinnedLinkText = "www.khoros.com";
PinnedLinkValue = "https://www.khoros.com";
Message Customization
Link Text Color
linkTextColor value has been added to the Style in sent and received messages.
KBMMessageStyle.sentMessage = Style(font: UIFont.systemFont(ofSize: 13), text: .white, linkTextColor: .red)
KBMMessageStyle.receivedMessage = Style(font: UIFont.systemFont(ofSize: 13), text: .black, linkTextColor: .red)
Other Changes
- Fixed an issue with where when unreadCount is unset (nil), notification would fail.
- Previously,
KBMUserDefaultsHandler.setBASEURL
requiredhttps://
prefix andKBMUserDefaultsHandler.setCustomAuthHandlerUrl
required not having it. This has changed to allow both to include or exclude and SDK will adjust for it. - Fixed issue with custom baseURL and authURL being forgotten during logout.
- Styling update on typing-notice-view (Typing activity indicator)
1.3.0
Message-Level-Branding
When configured on Care, each message can have different avatar/display name
Navigation Bar styling
Profile image icon has been removed.
Title has been centered.
Styling configuration options added.
let navigationBarProxy = UINavigationBar.appearance(whenContainedInInstancesOf: [KBMBaseNavigationViewController.self])
navigationBarProxy.barTintColor= .white
navigationBarProxy.tintColor = .red
navigationBarProxy.isTranslucent = false
let style = NSMutableParagraphStyle()
/// Line height
style.minimumLineHeight = 24
style.maximumLineHeight = 24
/// Title style
navigationBarProxy.titleTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.red, NSAttributedString.Key.font : UIFont.systemFont(ofSize: 18), NSAttributedString.Key.paragraphStyle :style]
Setting custom Navigation-Bar title
Add and update in Localizable.strings
:
ProfileName = "ECOECO";
Send-Button configuration
Button has been modified to a default black-text 'Send' button. The following is example on how to style some elements of this button.
var config = KBMConfiguration()
config.chatBar.messageInputViewStyle.sendButton = ButtonStyle(font: .systemFont(ofSize: 16),
titleColor: .green,
titleColorDisabled: .lightGray,
titleColorHighlighted: .blue,
background: .brown,
title: "BUTTON")
BrandMessengerManager.setDefaultConfiguration(config)
Back button configuration
Back button customization option has been added.
var config = KBMConfiguration()
config.chatBar.optionsToShow = .none
/// Set conversationViewControllerBackIcon to desired UIImage
config.conversationViewControllerBackIcon = UIImage(named: "close-icon-name-here", in: .main, compatibleWith: nil)
BrandMessengerManager.setDefaultConfiguration(config)
Styling configuration for Quick-Reply or AppLink buttons
KBMRichMessageStyles.KBMQuickReplyButtonStyle.shared.buttonColor.border = UIColor.red.cgColor
KBMRichMessageStyles.KBMQuickReplyButtonStyle.shared.buttonColor.text = UIColor.systemPink
KBMRichMessageStyles.KBMQuickReplyButtonStyle.shared.buttonColor.background = .white
KBMRichMessageStyles.KBMQuickReplyButtonStyle.shared.borderWidth = 1
KBMRichMessageStyles.KBMQuickReplyButtonStyle.shared.cornerRadius = 2
KBMRichMessageStyles.KBMQuickReplyButtonStyle.shared.buttonColor.tint = .orange
KBMRichMessageStyles.KBMQuickReplyButtonStyle.shared.font = .systemFont(ofSize: 16)
Styling configuration for Card rich messages
KBMRichMessageStyles.KBMCardStyle.shared.descriptionLabel.textColor = .red
KBMRichMessageStyles.KBMCardStyle.shared.ratingLabel.textColor = .red
KBMRichMessageStyles.KBMCardStyle.shared.actionButton.textColor = .white
KBMRichMessageStyles.KBMCardStyle.shared.actionButton.backgroundColor = .green
KBMRichMessageStyles.KBMCardStyle.shared.subtitleLabel.textColor = .red
KBMRichMessageStyles.KBMCardStyle.shared.titleLabel.textColor = .red
KBMRichMessageStyles.KBMCardStyle.shared.overlayLabel.textColor = .black
KBMRichMessageStyles.KBMCardStyle.shared.overlayLabel.backgroundColor = .systemPink
KBMRichMessageStyles.KBMCardStyle.shared.ratingLabel.textColor = .red
Styling configuration for List template rich messages
KBMRichMessageStyles.KBMListTemplateStyle.shared.actionButton.backgroundColor = .blue
KBMRichMessageStyles.KBMListTemplateStyle.shared.actionButton.textColor = .white
KBMRichMessageStyles.KBMListTemplateStyle.shared.headerText.textColor = .red
KBMRichMessageStyles.KBMListTemplateStyle.shared.headerText.backgroundColor = .yellow
KBMRichMessageStyles.KBMListTemplateStyle.shared.listTemplateElementViewStyle.backgroundColor = .brown
KBMRichMessageStyles.KBMListTemplateStyle.shared.listTemplateElementViewStyle.titleTextColor = .white
KBMRichMessageStyles.KBMListTemplateStyle.shared.listTemplateElementViewStyle.subtitleTextColor = .white
Welcome-message request
A new 'show' function has been added. To show conversation screen while making the request to show welcome-message, use
BrandMessengerManager.showWithWelcome(vc:UIViewController?)
Or to just send the welcome-message-request, use
BrandMessengerManager.sendWelcomeMessageRequest { response, error in }
The original BrandMessengerManager.show(vc:UIViewController?)
will NOT make the welcome-message request
Message Input Area redesign
Message input area has been redesigned. Following customization options have been added.
var config = KBMConfiguration()
config.chatBar.messageInputViewStyle.backgroundColor = .white
config.chatBar.messageInputViewStyle.textView = Style(font: .systemFont(ofSize: 15), text: .red)
config.chatBar.messageInputViewStyle.placeholder = Style(font: .systemFont(ofSize: 15), text: .red)
BrandMessengerManager.setDefaultConfiguration(config)
Certificate Pinning
Certificate pinning is turned off by default. On every app launch, enableDefaultCertificatePinning()
must be run in order to start pinning.
The Authentication and Message endpoints are pinned.
These endpoints can be customized, but must be done before calling enableDefaultCertificatePinning
. This is a permanent customization, and will likely require reinstalling the app to return those endpoints to their default values.
KBMUserDefaultsHandler.setBASEURL("brandmessenger.khoros.com")
KBMUserDefaultsHandler.setCustomAuthHandlerUrl("messaging-auth.khoros.com")
BrandMessengerManager.enableDefaultCertificatePinning()
Notification for Conversation Screen events
4 events notifications have been added from KBMConversationViewController
. viewWillAppear
/viewDidAppear
/viewWillDisappear
/viewDidDisappear
. Following is an example on how to start observing those notifications.
NotificationCenter.default.addObserver(self, selector: #selector(sel), name: NSNotification.Name(rawValue: "KBMConversationViewController.viewWillAppear"), object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(sel), name: NSNotification.Name(rawValue: "KBMConversationViewController.viewDidAppear"), object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(sel), name: NSNotification.Name(rawValue: "KBMConversationViewController.viewWillDisappear"), object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(sel), name: NSNotification.Name(rawValue: "KBMConversationViewController.viewDidDisappear"), object: nil)
Notification for unread-count change events
Notifications have been added when unreadCount is being updated. The updated value may same as the original value.
The notification is posted as such:
[[NSNotificationCenter defaultCenter] postNotificationName:@"BRAND_MESSENGER_UNREAD_COUNT" object:@{@"unreadCount":unreadCount}];
Following is an example on how to start observing.
NotificationCenter.default.addObserver(self, selector: #selector(onUnreadCount(obj:)), name: NSNotification.Name("BRAND_MESSENGER_UNREAD_COUNT"), object: nil)
Updated KBMEncryptionDelegate:
KBMEncryptionDelegate
's putSecureValueWithKey
has a boolean return value now. If encryption/storage fails, return false.
Other changes:
- Fixes some instances where 'http' would be used instead of 'https'
- Fixed some constraint conflicts causing app to arbitrarily breaking one to resolve.
- Fixed the default metadata placement in post body
1.2.0
Encryption Delegate
A KBMEncryptionDelegate protocol can be implemented to handle encrypting and storing auth-tokens and passwords, instead of handling it inside the SDK.
BrandMessengerManager.setEncryptionDelegate(self);
...
func putSecureValue(withKey key: String!, withValue value: String!) {
}
func getSecureValue(withKey key: String!) -> String! {
return ""
}
func hasSecureValue(withKey key: String!) -> Bool {
return false
}
func clearAll() {
}
Other changes
- Added metadata to Auth-Handler endpoint.
- Applied global metadata more consistently. This is in contrast to setting metadata on each individual message via BrandMessengerManager.setConversationDelegate(id). All metadata dictionaries are merged. To set global metadata for each message and auth-handler:
let metadata = NSMutableDictionary();
BrandMessengerSettings.setMessageMetadata(metadata);
1.0.0
Message Actions
Message actions from the build-in KBMConversationViewController, such as tapping on link-buttons, can be intercepted by setting a KBMConversationViewControllerDelegate and handled outside of the SDK.
BrandMessengerManager.setMessageActionDelegate(self)
...
// Return false to let SDK handle action. Return true to handle it here.
func handleMessageAction(index: Int?, title: String?, message: KBMMessageViewModel?, cardTemplate: CardTemplate?, listAction: ListTemplate.Action?, isButtonDisabled: Bool?) -> Bool {
// Depending on the type of message action, different objects and templates will be populated.
if let index = index, let message = message, let payload = message.payloadFromMetadata() {
let selectedButton = payload[index]
// case when it's a URL link.
if let type = selectedButton["type"] as? String, type == "link" {
openUrl(selectedButton["url"])
return true
}
// other rich action messages will have different payloads to determine what action it is. eg
if let message = selectedButton["message"] {
// suggested-response button will have selectedButton["title"].
return false
}
if let replyText = selectedButton["replyText"] {
return false
}
}
return false;
}
Unread Count
A new way to synchronize unread-count with server has been added.
BrandMessengerManager.getTotalUnreadCount { count, error in
}
System Message
A new textview at the top of the conversation screen has been added, for messages such as welcome, privacy policy and/or terms and conditions.
Create a Localizable.string
file if it doesn't already exist, and add the following key/values.
StartOfConversation = "This is the start of the conversation. Click here";
LinkText = "Click here";
LinkValue = "https://www.google.com";
The LinkText
substring will be replaced with an interactive element that will open LinkValue
url in an external browser.
Default Agent Avatar
Default agent avatar, for when its profile does not include a thumbnail url, is now customizable.
var config = KBMConfiguration()
... // add other configurations.
config.defaultAvatar = UIImage(named: "new-avatar")
BrandMessengerManager.setDefaultConfiguration(config)
0.3.0
Metadata
Default Metadata
From 0.3.0, BrandMessenger SDK includes default metadata per message.
metadata[@"vendor"] = @"brandMessenger";
metadata[@"os"] = @"iOS";
metadata[@"sdkVersion"] = sdkVersion; // eg: 0.3.0
metadata[@"appId"] = appId; // eg: com.app.brandmessenger
metadata[@"appVersion"] = majorAppVersion; // eg: 1.0
metadata[@"client.appName"] = appName; // eg: Khoros App
metadata[@"client.osVersion"] = osVersion; // eg: Version 15.3 (Build 19D49)
metadata[@"client.devicePlatform"] = deviceName; // eg: Test iPhone 12 mini
metadata[@"client.buildNumber"] = buildNumber; // eg: 10
metadata[@"client.carrier"] = [carrier carrierName]; //
metadata[@"client.platform"] = @"ios";
Custom metadata
KBMConversationDelegate can be implemented to intercept each message before send and add new metadata.
BrandMessengerManager.setConversationDelegate(self)
...
func modifyMessage(beforeSend message: KBMMessage) -> KBMMessage {
// message.metadata contains default metadata that can be overwritten/removed here
message.metadata?.setValue("customVal1", forKey: "customKey1")
return message
}
Subscribing on application:didFinishLaunchingWithOptions:
When BrandMessengerManager.application(application, didFinishLaunchingWithOptions: launchOptions)
is called on application: didFinishLaunchingWithOptions:, the default behavior subscribes to UIApplicationDidBecomeActiveNotification
and reconnects to existing conversation channel immediately as UIApplicationDidBecomeActiveNotification occurs after. This reconnect behavior can be disabled by using BrandMessengerManager.doNotAutosubscribeOnLaunch(true);
before BrandMessengerManager.application(application, didFinishLaunchingWithOptions: launchOptions)
is called.
Other
- Fixed bug with logout losing region value
0.2.0
0.2.0
Updated Authentication
Implemented Khoros Auth-Handler.
Setting Region. This will switch the Khoros Auth-Handler endpoint that BrandMessengerManager.login will use. Options are KBM_REGION_US or KBM_REGION_APAC, will default to KBM_REGION_APAC if not set.
BrandMessengerManager.setRegion(KBM_REGION_US);
Login
BrandMessengerManager.login("accessToken") { response, error in }
Checking authentication status. This will call refresh-token if current JWT is expired.
[BrandMessengerManager isAuthenticatedWithCompletion:^(BOOL authenticated) {
if (authenticated) {
// user is authenticated
}
}];
Authentication Delegate. When set, failed refresh-token calls will reroute to delegate and attempt a fresh login with provided access-token.
[BrandMessengerManager setAuthenticationDelegate:self];
...
-(void)onRefreshFail:(void (^)(NSString* accessToken))completion {
completion(@"<accesstoken>");
}
Other
- Minor default UI Updates to image messages.