diff --git a/UdeskSDK.podspec b/UdeskSDK.podspec index 7ec7607..42dcad9 100644 --- a/UdeskSDK.podspec +++ b/UdeskSDK.podspec @@ -8,7 +8,7 @@ Pod::Spec.new do |s| s.name = 'UdeskSDK' - s.version = '5.2.5' + s.version = '5.2.6' s.license = 'MIT' s.summary = 'Udesk SDK for iOS' s.homepage = 'https://github.com/udesk/UdeskSDK-iOS' diff --git a/UdeskSDK/SDK/libUdesk.a b/UdeskSDK/SDK/libUdesk.a index 4ed92bc..88e1c68 100644 Binary files a/UdeskSDK/SDK/libUdesk.a and b/UdeskSDK/SDK/libUdesk.a differ diff --git a/UdeskSDK/UDChatMessage/UDIM/Controller/UdeskChatViewController.m b/UdeskSDK/UDChatMessage/UDIM/Controller/UdeskChatViewController.m index e7ffe9d..a7cd1b1 100755 --- a/UdeskSDK/UDChatMessage/UDIM/Controller/UdeskChatViewController.m +++ b/UdeskSDK/UDChatMessage/UDIM/Controller/UdeskChatViewController.m @@ -182,8 +182,7 @@ - (void)didUpdateAgentModel:(UdeskAgent *)agent { //收到客服发送的满意度调查 - (void)didReceiveSurveyWithAgentId:(NSString *)agentId { - - [self servicesFeedbackSurveyWithAgentId:agentId]; + [self showSurveyViewWithAgentId:agentId]; } //无消息会话标题 diff --git a/UdeskSDK/UDChatMessage/UDIM/Models/Messages/Robot/UdeskRichMessage.m b/UdeskSDK/UDChatMessage/UDIM/Models/Messages/Robot/UdeskRichMessage.m index b83b405..3141405 100644 --- a/UdeskSDK/UDChatMessage/UDIM/Models/Messages/Robot/UdeskRichMessage.m +++ b/UdeskSDK/UDChatMessage/UDIM/Models/Messages/Robot/UdeskRichMessage.m @@ -44,7 +44,8 @@ - (void)layoutRichTextMessage { CGFloat spacing = ud_isIOS11 ? 0 : kUDRichMendSpacingOne; - self.attributedString = [self getAttributedStringWithText:self.message.content font:[UdeskSDKConfig customConfig].sdkStyle.messageContentFont]; + UIFont *textFont = [self preferredRichTextFont]; + self.attributedString = [self getAttributedStringWithText:self.message.content font:textFont]; CGSize richSize = [self getAttributedStringSizeWithAttr:self.attributedString size:CGSizeMake([self textMaxWidth], CGFLOAT_MAX)]; switch (self.message.messageFrom) { case UDMessageTypeSending:{ @@ -105,4 +106,56 @@ - (UITableViewCell *)getCellWithReuseIdentifier:(NSString *)cellReuseIdentifer { return [[UdeskRichCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellReuseIdentifer]; } +- (UIFont *)preferredRichTextFont +{ + UIFont *messageFont =[UdeskSDKConfig customConfig].sdkStyle.messageContentFont; + if (!messageFont) { + return nil; + } + UIFont *preferredFont = messageFont; + + BOOL fontFix = ![self isLocaleChineseLanguage]; + static NSString *systemFontFamilyName; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + UIFont *sysFont = [UIFont systemFontOfSize:1]; + systemFontFamilyName = sysFont.familyName; + }); + + //非中文环境下默认消息字体强制 苹方 + if (fontFix && systemFontFamilyName && [systemFontFamilyName isEqualToString:messageFont.familyName]) { + UIFontDescriptor *fontDescriptor = [messageFont fontDescriptor]; + NSMutableDictionary *atts = [[fontDescriptor fontAttributes] mutableCopy]; + [atts setValue:nil forKey:UIFontDescriptorTextStyleAttribute]; + [atts setValue:@"PingFang SC" forKey:UIFontDescriptorFamilyAttribute]; + [atts setValue:@"PingFangSC-Regular" forKey:UIFontDescriptorNameAttribute]; + UIFontDescriptorSymbolicTraits traits = fontDescriptor.symbolicTraits; + UIFontDescriptor *preferrDescriptor = [UIFontDescriptor fontDescriptorWithFontAttributes:atts]; + preferrDescriptor = [preferrDescriptor fontDescriptorWithSymbolicTraits:traits]; + + preferredFont = [UIFont fontWithDescriptor:preferrDescriptor size:messageFont.pointSize]; + } + + return preferredFont; +} + +- (BOOL)isLocaleChineseLanguage +{ + NSArray *languages = [NSLocale preferredLanguages]; + NSString *pfLanguageCode = [languages objectAtIndex:0]; + if ([pfLanguageCode isEqualToString:@"zh-Hant"] || + [pfLanguageCode hasPrefix:@"zh-Hant"] || + [pfLanguageCode hasPrefix:@"yue-Hant"] || + [pfLanguageCode isEqualToString:@"zh-HK"] || + [pfLanguageCode isEqualToString:@"zh-TW"]|| + [pfLanguageCode isEqualToString:@"zh-Hans"] || + [pfLanguageCode hasPrefix:@"yue-Hans"] || + [pfLanguageCode hasPrefix:@"zh-Hans"] + ) + { + return YES; + } + return NO; +} + @end diff --git a/UdeskSDK/UDChatMessage/UDTools/Category/NSAttributedString/NSAttributedString+UdeskHTML.m b/UdeskSDK/UDChatMessage/UDTools/Category/NSAttributedString/NSAttributedString+UdeskHTML.m index 85374c1..f2c6ae9 100644 --- a/UdeskSDK/UDChatMessage/UDTools/Category/NSAttributedString/NSAttributedString+UdeskHTML.m +++ b/UdeskSDK/UDChatMessage/UDTools/Category/NSAttributedString/NSAttributedString+UdeskHTML.m @@ -90,7 +90,9 @@ + (NSAttributedString *)attributedStringFromNode:(xmlNodePtr)xmlNode customFont: //加粗标签 if (strncmp("strong", (const char *)xmlNode->name, strlen((const char *)xmlNode->name)) == 0) { if (customFont) { - UIFont *boldFont = [UIFont boldSystemFontOfSize:customFont.pointSize]; + UIFontDescriptor *fontDescriptor = [customFont fontDescriptor]; + UIFontDescriptor *bodlDescriptor = [fontDescriptor fontDescriptorWithSymbolicTraits:fontDescriptor.symbolicTraits | UIFontDescriptorTraitBold]; + UIFont *boldFont = [UIFont fontWithDescriptor:bodlDescriptor size:customFont.pointSize]; [nodeAttributedString addAttribute:NSFontAttributeName value:boldFont range:nodeAttributedStringRange]; } } @@ -353,4 +355,13 @@ + (NSAttributedString *)attributedStringFromNode:(xmlNodePtr)xmlNode customFont: return nodeAttributedString; } + +- (UIFont *)bodyFont:(UIFont *)baseFont +{ + UIFontDescriptor *fontDescriptor = [baseFont fontDescriptor]; + UIFontDescriptor *bodlDescriptor = [fontDescriptor fontDescriptorWithSymbolicTraits:fontDescriptor.symbolicTraits | UIFontDescriptorTraitBold]; + UIFont *boldFont = [UIFont fontWithDescriptor:bodlDescriptor size:baseFont.pointSize]; + return boldFont; +} + @end diff --git a/UdeskSDKExample/UdeskSDKExample.xcodeproj/project.pbxproj b/UdeskSDKExample/UdeskSDKExample.xcodeproj/project.pbxproj index ee5b56b..e8166ec 100644 --- a/UdeskSDKExample/UdeskSDKExample.xcodeproj/project.pbxproj +++ b/UdeskSDKExample/UdeskSDKExample.xcodeproj/project.pbxproj @@ -2499,7 +2499,7 @@ "$(inherited)", "\"$(SRCROOT)/../UdeskSDK/SDK\"", ); - MARKETING_VERSION = 5.2.5; + MARKETING_VERSION = 5.2.6; OTHER_LDFLAGS = ( "$(inherited)", "-l\"c++\"", @@ -2592,7 +2592,7 @@ "$(inherited)", "\"$(SRCROOT)/../UdeskSDK/SDK\"", ); - MARKETING_VERSION = 5.2.5; + MARKETING_VERSION = 5.2.6; OTHER_LDFLAGS = ( "$(inherited)", "-l\"c++\"",