TUITool.m 65 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106
  1. //
  2. // THelper.m
  3. // TUIKit
  4. //
  5. // Created by kennethmiao on 2018/11/1.
  6. // Copyright © 2018 Tencent. All rights reserved.
  7. //
  8. #import <SDWebImage/SDImageCoderHelper.h>
  9. #import "TUILogin.h"
  10. #import "TUIGlobalization.h"
  11. #import "TUIWeakProxy.h"
  12. #import "TUIDefine.h"
  13. #import "UIView+TUIToast.h"
  14. @import ImSDK_Plus;
  15. @implementation TUITool
  16. static NSMutableDictionary * gIMErrorMsgMap = nil;
  17. + (void)initialize {
  18. [self setupIMErrorMap];
  19. }
  20. + (void)configIMErrorMap {
  21. [self.class setupIMErrorMap];
  22. }
  23. + (void)setupIMErrorMap {
  24. NSMutableDictionary *map = [NSMutableDictionary dictionary];
  25. gIMErrorMsgMap = map;
  26. /////////////////////////////////////////////////////////////////////////////////
  27. //
  28. // (1)IM SDK
  29. //
  30. /////////////////////////////////////////////////////////////////////////////////
  31. //General error code
  32. [map setObject:TUIKitLocalizableString(TUIKitErrorInProcess) forKey:@(ERR_IN_PROGESS)];
  33. [map setObject:TUIKitLocalizableString(TUIKitErrorInvalidParameters) forKey:@(ERR_INVALID_PARAMETERS)];
  34. [map setObject:TUIKitLocalizableString(TUIKitErrorIOOperateFaild) forKey:@(ERR_IO_OPERATION_FAILED)];
  35. [map setObject:TUIKitLocalizableString(TUIKitErrorInvalidJson) forKey:@(ERR_INVALID_JSON)];
  36. [map setObject:TUIKitLocalizableString(TUIKitErrorOutOfMemory) forKey:@(ERR_OUT_OF_MEMORY)];
  37. [map setObject:TUIKitLocalizableString(TUIKitErrorParseResponseFaild) forKey:@(ERR_PARSE_RESPONSE_FAILED)];
  38. [map setObject:TUIKitLocalizableString(TUIKitErrorSerializeReqFaild) forKey:@(ERR_SERIALIZE_REQ_FAILED)];
  39. [map setObject:TUIKitLocalizableString(TUIKitErrorSDKNotInit) forKey:@(ERR_SDK_NOT_INITIALIZED)];
  40. [map setObject:TUIKitLocalizableString(TUIKitErrorLoadMsgFailed) forKey:@(ERR_LOADMSG_FAILED)];
  41. [map setObject:TUIKitLocalizableString(TUIKitErrorDatabaseOperateFailed) forKey:@(ERR_DATABASE_OPERATE_FAILED)];
  42. [map setObject:TUIKitLocalizableString(TUIKitErrorCrossThread) forKey:@(ERR_SDK_COMM_CROSS_THREAD)];
  43. [map setObject:TUIKitLocalizableString(TUIKitErrorTinyIdEmpty) forKey:@(ERR_SDK_COMM_TINYID_EMPTY)];
  44. [map setObject:TUIKitLocalizableString(TUIKitErrorInvalidIdentifier) forKey:@(ERR_SDK_COMM_INVALID_IDENTIFIER)];
  45. [map setObject:TUIKitLocalizableString(TUIKitErrorFileNotFound) forKey:@(ERR_SDK_COMM_FILE_NOT_FOUND)];
  46. [map setObject:TUIKitLocalizableString(TUIKitErrorFileTooLarge) forKey:@(ERR_SDK_COMM_FILE_TOO_LARGE)];
  47. [map setObject:TUIKitLocalizableString(TUIKitErrorEmptyFile) forKey:@(ERR_SDK_COMM_FILE_SIZE_EMPTY)];
  48. [map setObject:TUIKitLocalizableString(TUIKitErrorFileOpenFailed) forKey:@(ERR_SDK_COMM_FILE_OPEN_FAILED)];
  49. [map setObject:TUIKitLocalizableString(TUIKitErrorUnsupporInterface) forKey:@(ERR_SDK_INTERFACE_NOT_SUPPORT)];
  50. // Account
  51. [map setObject:TUIKitLocalizableString(TUIKitErrorNotLogin) forKey:@(ERR_SDK_NOT_LOGGED_IN)];
  52. [map setObject:TUIKitLocalizableString(TUIKitErrorNoPreviousLogin) forKey:@(ERR_NO_PREVIOUS_LOGIN)];
  53. [map setObject:TUIKitLocalizableString(TUIKitErrorUserSigExpired) forKey:@(ERR_USER_SIG_EXPIRED)];
  54. [map setObject:TUIKitLocalizableString(TUIKitErrorLoginKickedOffByOther) forKey:@(ERR_LOGIN_KICKED_OFF_BY_OTHER)];
  55. [map setObject:TUIKitLocalizableString(TUIKitErrorTLSSDKInit) forKey:@(ERR_SDK_ACCOUNT_TLS_INIT_FAILED)];
  56. [map setObject:TUIKitLocalizableString(TUIKitErrorTLSSDKUninit) forKey:@(ERR_SDK_ACCOUNT_TLS_NOT_INITIALIZED)];
  57. [map setObject:TUIKitLocalizableString(TUIKitErrorTLSSDKTRANSPackageFormat) forKey:@(ERR_SDK_ACCOUNT_TLS_TRANSPKG_ERROR)];
  58. [map setObject:TUIKitLocalizableString(TUIKitErrorTLSDecrypt) forKey:@(ERR_SDK_ACCOUNT_TLS_DECRYPT_FAILED)];
  59. [map setObject:TUIKitLocalizableString(TUIKitErrorTLSSDKRequest) forKey:@(ERR_SDK_ACCOUNT_TLS_REQUEST_FAILED)];
  60. [map setObject:TUIKitLocalizableString(TUIKitErrorTLSSDKRequestTimeout) forKey:@(ERR_SDK_ACCOUNT_TLS_REQUEST_TIMEOUT)];
  61. // Message
  62. [map setObject:TUIKitLocalizableString(TUIKitErrorInvalidConveration) forKey:@(ERR_INVALID_CONVERSATION)];
  63. [map setObject:TUIKitLocalizableString(TUIKitErrorFileTransAuthFailed) forKey:@(ERR_FILE_TRANS_AUTH_FAILED)];
  64. [map setObject:TUIKitLocalizableString(TUIKitErrorFileTransNoServer) forKey:@(ERR_FILE_TRANS_NO_SERVER)];
  65. [map setObject:TUIKitLocalizableString(TUIKitErrorFileTransUploadFailed) forKey:@(ERR_FILE_TRANS_UPLOAD_FAILED)];
  66. [map setObject:TUIKitLocalizableString(TUIKitErrorFileTransUploadFailedNotImage) forKey:@(ERR_IMAGE_UPLOAD_FAILED_NOTIMAGE)];
  67. [map setObject:TUIKitLocalizableString(TUIKitErrorFileTransDownloadFailed) forKey:@(ERR_FILE_TRANS_DOWNLOAD_FAILED)];
  68. [map setObject:TUIKitLocalizableString(TUIKitErrorHTTPRequestFailed) forKey:@(ERR_HTTP_REQ_FAILED)];
  69. [map setObject:TUIKitLocalizableString(TUIKitErrorInvalidMsgElem) forKey:@(ERR_INVALID_MSG_ELEM)];
  70. [map setObject:TUIKitLocalizableString(TUIKitErrorInvalidSDKObject) forKey:@(ERR_INVALID_SDK_OBJECT)];
  71. [map setObject:TUIKitLocalizableString(TUIKitSDKMsgBodySizeLimit) forKey:@(ERR_SDK_MSG_BODY_SIZE_LIMIT)];
  72. [map setObject:TUIKitLocalizableString(TUIKitErrorSDKMsgKeyReqDifferRsp) forKey:@(ERR_SDK_MSG_KEY_REQ_DIFFER_RSP)];
  73. // Group
  74. [map setObject:TUIKitLocalizableString(TUIKitErrorSDKGroupInvalidID) forKey:@(ERR_SDK_GROUP_INVALID_ID)];
  75. [map setObject:TUIKitLocalizableString(TUIKitErrorSDKGroupInvalidName) forKey:@(ERR_SDK_GROUP_INVALID_NAME)];
  76. [map setObject:TUIKitLocalizableString(TUIKitErrorSDKGroupInvalidIntroduction) forKey:@(ERR_SDK_GROUP_INVALID_INTRODUCTION)];
  77. [map setObject:TUIKitLocalizableString(TUIKitErrorSDKGroupInvalidNotification) forKey:@(ERR_SDK_GROUP_INVALID_NOTIFICATION)];
  78. [map setObject:TUIKitLocalizableString(TUIKitErrorSDKGroupInvalidFaceURL) forKey:@(ERR_SDK_GROUP_INVALID_FACE_URL)];
  79. [map setObject:TUIKitLocalizableString(TUIKitErrorSDKGroupInvalidNameCard) forKey:@(ERR_SDK_GROUP_INVALID_NAME_CARD)];
  80. [map setObject:TUIKitLocalizableString(TUIKitErrorSDKGroupMemberCountLimit) forKey:@(ERR_SDK_GROUP_MEMBER_COUNT_LIMIT)];
  81. [map setObject:TUIKitLocalizableString(TUIKitErrorSDKGroupJoinPrivateGroupDeny) forKey:@(ERR_SDK_GROUP_JOIN_PRIVATE_GROUP_DENY)];
  82. [map setObject:TUIKitLocalizableString(TUIKitErrorSDKGroupInviteSuperDeny) forKey:@(ERR_SDK_GROUP_INVITE_SUPER_DENY)];
  83. [map setObject:TUIKitLocalizableString(TUIKitErrorSDKGroupInviteNoMember) forKey:@(ERR_SDK_GROUP_INVITE_NO_MEMBER)];
  84. // Relationship
  85. [map setObject:TUIKitLocalizableString(TUIKitErrorSDKFriendShipInvalidProfileKey) forKey:@(ERR_SDK_FRIENDSHIP_INVALID_PROFILE_KEY)];
  86. [map setObject:TUIKitLocalizableString(TUIKitErrorSDKFriendshipInvalidAddRemark) forKey:@(ERR_SDK_FRIENDSHIP_INVALID_ADD_REMARK)];
  87. [map setObject:TUIKitLocalizableString(TUIKitErrorSDKFriendshipInvalidAddWording) forKey:@(ERR_SDK_FRIENDSHIP_INVALID_ADD_WORDING)];
  88. [map setObject:TUIKitLocalizableString(TUIKitErrorSDKFriendshipInvalidAddSource) forKey:@(ERR_SDK_FRIENDSHIP_INVALID_ADD_SOURCE)];
  89. [map setObject:TUIKitLocalizableString(TUIKitErrorSDKFriendshipFriendGroupEmpty) forKey:@(ERR_SDK_FRIENDSHIP_FRIEND_GROUP_EMPTY)];
  90. // Network
  91. [map setObject:TUIKitLocalizableString(TUIKitErrorSDKNetEncodeFailed) forKey:@(ERR_SDK_NET_ENCODE_FAILED)];
  92. [map setObject:TUIKitLocalizableString(TUIKitErrorSDKNetDecodeFailed) forKey:@(ERR_SDK_NET_DECODE_FAILED)];
  93. [map setObject:TUIKitLocalizableString(TUIKitErrorSDKNetAuthInvalid) forKey:@(ERR_SDK_NET_AUTH_INVALID)];
  94. [map setObject:TUIKitLocalizableString(TUIKitErrorSDKNetCompressFailed) forKey:@(ERR_SDK_NET_COMPRESS_FAILED)];
  95. [map setObject:TUIKitLocalizableString(TUIKitErrorSDKNetUncompressFaile) forKey:@(ERR_SDK_NET_UNCOMPRESS_FAILED)];
  96. [map setObject:TUIKitLocalizableString(TUIKitErrorSDKNetFreqLimit) forKey:@(ERR_SDK_NET_FREQ_LIMIT)];
  97. [map setObject:TUIKitLocalizableString(TUIKitErrorSDKnetReqCountLimit) forKey:@(ERR_SDK_NET_REQ_COUNT_LIMIT)];
  98. [map setObject:TUIKitLocalizableString(TUIKitErrorSDKNetDisconnect) forKey:@(ERR_SDK_NET_DISCONNECT)];
  99. [map setObject:TUIKitLocalizableString(TUIKitErrorSDKNetAllreadyConn) forKey:@(ERR_SDK_NET_ALLREADY_CONN)];
  100. [map setObject:TUIKitLocalizableString(TUIKitErrorSDKNetConnTimeout) forKey:@(ERR_SDK_NET_CONN_TIMEOUT)];
  101. [map setObject:TUIKitLocalizableString(TUIKitErrorSDKNetConnRefuse) forKey:@(ERR_SDK_NET_CONN_REFUSE)];
  102. [map setObject:TUIKitLocalizableString(TUIKitErrorSDKNetNetUnreach) forKey:@(ERR_SDK_NET_NET_UNREACH)];
  103. [map setObject:TUIKitLocalizableString(TUIKitErrorSDKNetSocketNoBuff) forKey:@(ERR_SDK_NET_SOCKET_NO_BUFF)];
  104. [map setObject:TUIKitLocalizableString(TUIKitERRORSDKNetResetByPeer) forKey:@(ERR_SDK_NET_RESET_BY_PEER)];
  105. [map setObject:TUIKitLocalizableString(TUIKitErrorSDKNetSOcketInvalid) forKey:@(ERR_SDK_NET_SOCKET_INVALID)];
  106. [map setObject:TUIKitLocalizableString(TUIKitErrorSDKNetHostGetAddressFailed) forKey:@(ERR_SDK_NET_HOST_GETADDRINFO_FAILED)];
  107. [map setObject:TUIKitLocalizableString(TUIKitErrorSDKNetConnectReset) forKey:@(ERR_SDK_NET_CONNECT_RESET)];
  108. [map setObject:TUIKitLocalizableString(TUIKitErrorSDKNetWaitInQueueTimeout) forKey:@(ERR_SDK_NET_WAIT_INQUEUE_TIMEOUT)];
  109. [map setObject:TUIKitLocalizableString(TUIKitErrorSDKNetWaitSendTimeout) forKey:@(ERR_SDK_NET_WAIT_SEND_TIMEOUT)];
  110. [map setObject:TUIKitLocalizableString(TUIKitErrorSDKNetWaitAckTimeut) forKey:@(ERR_SDK_NET_WAIT_ACK_TIMEOUT)];
  111. [map setObject:TUIKitLocalizableString(TUIKitErrorSDKWaitSendRemainingTimeout) forKey:@(ERR_SDK_NET_WAIT_SEND_REMAINING_TIMEOUT)];
  112. [map setObject:TUIKitLocalizableString(TUIKitErrorSDKNetPKGSizeLimit)
  113. forKey:@(ERR_SDK_NET_PKG_SIZE_LIMIT)];
  114. [map setObject:TUIKitLocalizableString(TUIKitErrorSDKNetWaitSendTimeoutNoNetwork) forKey:@(ERR_SDK_NET_WAIT_SEND_TIMEOUT_NO_NETWORK)];
  115. [map setObject:TUIKitLocalizableString(TUIKitErrorSDKNetWaitAckTimeoutNoNetwork) forKey:@(ERR_SDK_NET_WAIT_ACK_TIMEOUT_NO_NETWORK)];
  116. [map setObject:TUIKitLocalizableString(TUIKitErrorSDKNetRemainingTimeoutNoNetwork) forKey:@(ERR_SDK_NET_SEND_REMAINING_TIMEOUT_NO_NETWORK)];
  117. /////////////////////////////////////////////////////////////////////////////////
  118. //
  119. // (2)Server
  120. //
  121. /////////////////////////////////////////////////////////////////////////////////
  122. // SSO
  123. [map setObject:TUIKitLocalizableString(TUIKitErrorSDKSVRSSOConnectLimit) forKey:@(ERR_SVR_SSO_CONNECT_LIMIT)];
  124. [map setObject:TUIKitLocalizableString(TUIKitErrorSDKSVRSSOVCode) forKey:@(ERR_SVR_SSO_VCODE)];
  125. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRSSOEmpeyKey) forKey:@(ERR_SVR_SSO_EMPTY_KEY)];
  126. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRSSOUinInvalid) forKey:@(ERR_SVR_SSO_UIN_INVALID)];
  127. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRSSOVCodeTimeout) forKey:@(ERR_SVR_SSO_VCODE_TIMEOUT)];
  128. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRSSOCookieInvalid) forKey:@(ERR_SVR_SSO_COOKIE_INVALID)];
  129. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRSSODownTips) forKey:@(ERR_SVR_SSO_DOWN_TIP)];
  130. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRSSODisconnect) forKey:@(ERR_SVR_SSO_DISCONNECT)];
  131. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRSSOIdentifierInvalid) forKey:@(ERR_SVR_SSO_IDENTIFIER_INVALID)];
  132. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRSSOClientClose) forKey:@(ERR_SVR_SSO_CLIENT_CLOSE)];
  133. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRSSOMSFSDKQuit) forKey:@(ERR_SVR_SSO_MSFSDK_QUIT)];
  134. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRSSOUnsupport) forKey:@(ERR_SVR_SSO_UNSURPPORT)];
  135. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRSSOPrepaidArrears) forKey:@(ERR_SVR_SSO_PREPAID_ARREARS)];
  136. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRSSOPacketWrong) forKey:@(ERR_SVR_SSO_PACKET_WRONG)];
  137. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRSSOAppidBlackList) forKey:@(ERR_SVR_SSO_APPID_BLACK_LIST)];
  138. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRSSOCmdBlackList) forKey:@(ERR_SVR_SSO_CMD_BLACK_LIST)];
  139. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRSSOAppidWithoutUsing) forKey:@(ERR_SVR_SSO_APPID_WITHOUT_USING)];
  140. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRSSOFreqLimit) forKey:@(ERR_SVR_SSO_FREQ_LIMIT)];
  141. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRSSOOverload) forKey:@(ERR_SVR_SSO_OVERLOAD)];
  142. // Resource
  143. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRResNotFound) forKey:@(ERR_SVR_RES_NOT_FOUND)];
  144. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRResAccessDeny) forKey:@(ERR_SVR_RES_ACCESS_DENY)];
  145. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRResSizeLimit) forKey:@(ERR_SVR_RES_SIZE_LIMIT)];
  146. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRResSendCancel) forKey:@(ERR_SVR_RES_SEND_CANCEL)];
  147. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRResReadFailed) forKey:@(ERR_SVR_RES_READ_FAILED)];
  148. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRResTransferTimeout) forKey:@(ERR_SVR_RES_TRANSFER_TIMEOUT)];
  149. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRResInvalidParameters) forKey:@(ERR_SVR_RES_INVALID_PARAMETERS)];
  150. // Common
  151. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRCommonInvalidHttpUrl) forKey:@(ERR_SVR_COMM_INVALID_HTTP_URL)];
  152. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRCommomReqJsonParseFailed) forKey:@(ERR_SVR_COMM_REQ_JSON_PARSE_FAILED)];
  153. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRCommonInvalidAccount) forKey:@(ERR_SVR_COMM_INVALID_ACCOUNT)];
  154. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRCommonInvalidAccount) forKey:@(ERR_SVR_COMM_INVALID_ACCOUNT_EX)];
  155. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRCommonInvalidSdkappid) forKey:@(ERR_SVR_COMM_INVALID_SDKAPPID)];
  156. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRCommonRestFreqLimit) forKey:@(ERR_SVR_COMM_REST_FREQ_LIMIT)];
  157. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRCommonRequestTimeout) forKey:@(ERR_SVR_COMM_REQUEST_TIMEOUT)];
  158. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRCommonInvalidRes) forKey:@(ERR_SVR_COMM_INVALID_RES)];
  159. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRCommonIDNotAdmin) forKey:@(ERR_SVR_COMM_ID_NOT_ADMIN)];
  160. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRCommonSdkappidFreqLimit) forKey:@(ERR_SVR_COMM_SDKAPPID_FREQ_LIMIT)];
  161. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRCommonSdkappidMiss) forKey:@(ERR_SVR_COMM_SDKAPPID_MISS)];
  162. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRCommonRspJsonParseFailed) forKey:@(ERR_SVR_COMM_RSP_JSON_PARSE_FAILED)];
  163. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRCommonExchangeAccountTimeout) forKey:@(ERR_SVR_COMM_EXCHANGE_ACCOUNT_TIMEUT)];
  164. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRCommonInvalidIdFormat) forKey:@(ERR_SVR_COMM_INVALID_ID_FORMAT)];
  165. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRCommonSDkappidForbidden) forKey:@(ERR_SVR_COMM_SDKAPPID_FORBIDDEN)];
  166. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRCommonReqForbidden) forKey:@(ERR_SVR_COMM_REQ_FORBIDDEN)];
  167. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRCommonReqFreqLimit) forKey:@(ERR_SVR_COMM_REQ_FREQ_LIMIT)];
  168. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRCommonReqFreqLimit) forKey:@(ERR_SVR_COMM_REQ_FREQ_LIMIT_EX)];
  169. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRCommonInvalidService) forKey:@(ERR_SVR_COMM_INVALID_SERVICE)];
  170. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRCommonSensitiveText) forKey:@(ERR_SVR_COMM_SENSITIVE_TEXT)];
  171. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRCommonBodySizeLimit) forKey:@(ERR_SVR_COMM_BODY_SIZE_LIMIT)];
  172. // Account
  173. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRAccountUserSigExpired) forKey:@(ERR_SVR_ACCOUNT_USERSIG_EXPIRED)];
  174. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRAccountUserSigEmpty) forKey:@(ERR_SVR_ACCOUNT_USERSIG_EMPTY)];
  175. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRAccountUserSigCheckFailed) forKey:@(ERR_SVR_ACCOUNT_USERSIG_CHECK_FAILED)];
  176. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRAccountUserSigCheckFailed) forKey:@(ERR_SVR_ACCOUNT_USERSIG_CHECK_FAILED_EX)];
  177. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRAccountUserSigMismatchPublicKey) forKey:@(ERR_SVR_ACCOUNT_USERSIG_MISMATCH_PUBLICKEY)];
  178. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRAccountUserSigMismatchId) forKey:@(ERR_SVR_ACCOUNT_USERSIG_MISMATCH_ID)];
  179. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRAccountUserSigMismatchSdkAppid) forKey:@(ERR_SVR_ACCOUNT_USERSIG_MISMATCH_SDKAPPID)];
  180. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRAccountUserSigPublicKeyNotFound) forKey:@(ERR_SVR_ACCOUNT_USERSIG_PUBLICKEY_NOT_FOUND)];
  181. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRAccountUserSigSdkAppidNotFount) forKey:@(ERR_SVR_ACCOUNT_SDKAPPID_NOT_FOUND)];
  182. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRAccountInvalidUserSig) forKey:@(ERR_SVR_ACCOUNT_INVALID_USERSIG)];
  183. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRAccountNotFound) forKey:@(ERR_SVR_ACCOUNT_NOT_FOUND)];
  184. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRAccountSecRstr) forKey:@(ERR_SVR_ACCOUNT_SEC_RSTR)];
  185. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRAccountInternalTimeout) forKey:@(ERR_SVR_ACCOUNT_INTERNAL_TIMEOUT)];
  186. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRAccountInvalidCount) forKey:@(ERR_SVR_ACCOUNT_INVALID_COUNT)];
  187. [map setObject:TUIKitLocalizableString(TUIkitErrorSVRAccountINvalidParameters) forKey:@(ERR_SVR_ACCOUNT_INVALID_PARAMETERS)];
  188. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRAccountAdminRequired) forKey:@(ERR_SVR_ACCOUNT_ADMIN_REQUIRED)];
  189. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRAccountLowSDKVersion) forKey:@(ERR_SVR_ACCOUNT_LOW_SDK_VERSION)];
  190. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRAccountFreqLimit) forKey:@(ERR_SVR_ACCOUNT_FREQ_LIMIT)];
  191. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRAccountBlackList) forKey:@(ERR_SVR_ACCOUNT_BLACKLIST)];
  192. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRAccountCountLimit) forKey:@(ERR_SVR_ACCOUNT_COUNT_LIMIT)];
  193. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRAccountInternalError) forKey:@(ERR_SVR_ACCOUNT_INTERNAL_ERROR)];
  194. [map setObject:TUIKitLocalizableString(TUIKitErrorEnableUserStatusOnConsole) forKey:@(ERR_SVR_ACCOUNT_USER_STATUS_DISABLED)];
  195. // Profile
  196. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRProfileInvalidParameters) forKey:@(ERR_SVR_PROFILE_INVALID_PARAMETERS)];
  197. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRProfileAccountMiss) forKey:@(ERR_SVR_PROFILE_ACCOUNT_MISS)];
  198. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRProfileAccountNotFound) forKey:@(ERR_SVR_PROFILE_ACCOUNT_NOT_FOUND)];
  199. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRProfileAdminRequired) forKey:@(ERR_SVR_PROFILE_ADMIN_REQUIRED)];
  200. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRProfileSensitiveText) forKey:@(ERR_SVR_PROFILE_SENSITIVE_TEXT)];
  201. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRProfileInternalError) forKey:@(ERR_SVR_PROFILE_INTERNAL_ERROR)];
  202. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRProfileReadWritePermissionRequired) forKey:@(ERR_SVR_PROFILE_READ_PERMISSION_REQUIRED)];
  203. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRProfileReadWritePermissionRequired) forKey:@(ERR_SVR_PROFILE_WRITE_PERMISSION_REQUIRED)];
  204. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRProfileTagNotFound) forKey:@(ERR_SVR_PROFILE_TAG_NOT_FOUND)];
  205. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRProfileSizeLimit) forKey:@(ERR_SVR_PROFILE_SIZE_LIMIT)];
  206. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRProfileValueError) forKey:@(ERR_SVR_PROFILE_VALUE_ERROR)];
  207. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRProfileInvalidValueFormat) forKey:@(ERR_SVR_PROFILE_INVALID_VALUE_FORMAT)];
  208. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRFriendshipInvalidParameters) forKey:@(ERR_SVR_FRIENDSHIP_INVALID_PARAMETERS)];
  209. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRFriendshipInvalidSdkAppid) forKey:@(ERR_SVR_FRIENDSHIP_INVALID_SDKAPPID)];
  210. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRFriendshipAccountNotFound) forKey:@(ERR_SVR_FRIENDSHIP_ACCOUNT_NOT_FOUND)];
  211. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRFriendshipAdminRequired) forKey:@(ERR_SVR_FRIENDSHIP_ADMIN_REQUIRED)];
  212. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRFriendshipSensitiveText) forKey:@(ERR_SVR_FRIENDSHIP_SENSITIVE_TEXT)];
  213. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRAccountInternalError) forKey:@(ERR_SVR_FRIENDSHIP_INTERNAL_ERROR)];
  214. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRFriendshipNetTimeout) forKey:@(ERR_SVR_FRIENDSHIP_NET_TIMEOUT)];
  215. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRFriendshipWriteConflict) forKey:@(ERR_SVR_FRIENDSHIP_WRITE_CONFLICT)];
  216. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRFriendshipAddFriendDeny) forKey:@(ERR_SVR_FRIENDSHIP_ADD_FRIEND_DENY)];
  217. [map setObject:TUIKitLocalizableString(TUIkitErrorSVRFriendshipCountLimit) forKey:@(ERR_SVR_FRIENDSHIP_COUNT_LIMIT)];
  218. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRFriendshipGroupCountLimit) forKey:@(ERR_SVR_FRIENDSHIP_GROUP_COUNT_LIMIT)];
  219. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRFriendshipPendencyLimit) forKey:@(ERR_SVR_FRIENDSHIP_PENDENCY_LIMIT)];
  220. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRFriendshipBlacklistLimit) forKey:@(ERR_SVR_FRIENDSHIP_BLACKLIST_LIMIT)];
  221. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRFriendshipPeerFriendLimit) forKey:@(ERR_SVR_FRIENDSHIP_PEER_FRIEND_LIMIT)];
  222. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRFriendshipAlreadyFriends) forKey:@(ERR_SVR_FRIENDSHIP_ALREADY_FRIENDS)];
  223. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRFriendshipInSelfBlacklist) forKey:@(ERR_SVR_FRIENDSHIP_IN_SELF_BLACKLIST)];
  224. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRFriendshipAllowTypeDenyAny) forKey:@(ERR_SVR_FRIENDSHIP_ALLOW_TYPE_DENY_ANY)];
  225. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRFriendshipInPeerBlackList) forKey:@(ERR_SVR_FRIENDSHIP_IN_PEER_BLACKLIST)];
  226. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRFriendshipAllowTypeNeedConfirm) forKey:@(ERR_SVR_FRIENDSHIP_ALLOW_TYPE_NEED_CONFIRM)];
  227. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRFriendshipAddFriendSecRstr) forKey:@(ERR_SVR_FRIENDSHIP_ADD_FRIEND_SEC_RSTR)];
  228. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRFriendshipPendencyNotFound) forKey:@(ERR_SVR_FRIENDSHIP_PENDENCY_NOT_FOUND)];
  229. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRFriendshipDelFriendSecRstr) forKey:@(ERR_SVR_FRIENDSHIP_DEL_FRIEND_SEC_RSTR)];
  230. [map setObject:TUIKitLocalizableString(TUIKirErrorSVRFriendAccountNotFoundEx) forKey:@(ERR_SVR_FRIENDSHIP_ACCOUNT_NOT_FOUND_EX)];
  231. // Conversation
  232. [map setObject:TUIKitLocalizableString(TUIKirErrorSVRFriendAccountNotFoundEx) forKey:@(ERR_SVR_CONV_ACCOUNT_NOT_FOUND)];
  233. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRFriendshipInvalidParameters) forKey:@(ERR_SVR_CONV_INVALID_PARAMETERS)];
  234. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRFriendshipAdminRequired) forKey:@(ERR_SVR_CONV_ADMIN_REQUIRED)];
  235. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRAccountInternalError) forKey:@(ERR_SVR_CONV_INTERNAL_ERROR)];
  236. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRFriendshipNetTimeout) forKey:@(ERR_SVR_CONV_NET_TIMEOUT)];
  237. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRConvGroupNameLengthLimit) forKey:@(ERR_SVR_CONV_CONV_GROUP_NAME_EXCEED_LENGTH)];
  238. // Message
  239. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRMsgPkgParseFailed) forKey:@(ERR_SVR_MSG_PKG_PARSE_FAILED)];
  240. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRMsgInternalAuthFailed) forKey:@(ERR_SVR_MSG_INTERNAL_AUTH_FAILED)];
  241. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRMsgInvalidId) forKey:@(ERR_SVR_MSG_INVALID_ID)];
  242. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRMsgNetError) forKey:@(ERR_SVR_MSG_NET_ERROR)];
  243. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRMsgPushDeny) forKey:@(ERR_SVR_MSG_PUSH_DENY)];
  244. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRMsgInPeerBlackList) forKey:@(ERR_SVR_MSG_IN_PEER_BLACKLIST)];
  245. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRMsgBothNotFriend) forKey:@(ERR_SVR_MSG_BOTH_NOT_FRIEND)];
  246. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRMsgNotPeerFriend) forKey:@(ERR_SVR_MSG_NOT_PEER_FRIEND)];
  247. [map setObject:TUIKitLocalizableString(TUIkitErrorSVRMsgNotSelfFriend) forKey:@(ERR_SVR_MSG_NOT_SELF_FRIEND)];
  248. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRMsgShutupDeny) forKey:@(ERR_SVR_MSG_SHUTUP_DENY)];
  249. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRMsgRevokeTimeLimit) forKey:@(ERR_SVR_MSG_REVOKE_TIME_LIMIT)];
  250. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRMsgDelRambleInternalError) forKey:@(ERR_SVR_MSG_DEL_RAMBLE_INTERNAL_ERROR)];
  251. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRMsgJsonParseFailed) forKey:@(ERR_SVR_MSG_JSON_PARSE_FAILED)];
  252. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRMsgInvalidJsonBodyFormat) forKey:@(ERR_SVR_MSG_INVALID_JSON_BODY_FORMAT)];
  253. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRMsgInvalidToAccount) forKey:@(ERR_SVR_MSG_INVALID_TO_ACCOUNT)];
  254. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRMsgInvalidRand) forKey:@(ERR_SVR_MSG_INVALID_RAND)];
  255. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRMsgInvalidTimestamp) forKey:@(ERR_SVR_MSG_INVALID_TIMESTAMP)];
  256. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRMsgBodyNotArray) forKey:@(ERR_SVR_MSG_BODY_NOT_ARRAY)];
  257. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRAccountAdminRequired) forKey:@(ERR_SVR_MSG_ADMIN_REQUIRED)];
  258. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRMsgInvalidJsonFormat) forKey:@(ERR_SVR_MSG_INVALID_JSON_FORMAT)];
  259. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRMsgToAccountCountLimit) forKey:@(ERR_SVR_MSG_TO_ACCOUNT_COUNT_LIMIT)];
  260. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRMsgToAccountNotFound) forKey:@(ERR_SVR_MSG_TO_ACCOUNT_NOT_FOUND)];
  261. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRMsgTimeLimit) forKey:@(ERR_SVR_MSG_TIME_LIMIT)];
  262. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRMsgInvalidSyncOtherMachine) forKey:@(ERR_SVR_MSG_INVALID_SYNCOTHERMACHINE)];
  263. [map setObject:TUIKitLocalizableString(TUIkitErrorSVRMsgInvalidMsgLifeTime) forKey:@(ERR_SVR_MSG_INVALID_MSGLIFETIME)];
  264. [map setObject:TUIKitLocalizableString(TUIKirErrorSVRFriendAccountNotFoundEx) forKey:@(ERR_SVR_MSG_ACCOUNT_NOT_FOUND)];
  265. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRMsgBodySizeLimit) forKey:@(ERR_SVR_MSG_BODY_SIZE_LIMIT)];
  266. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRmsgLongPollingCountLimit) forKey:@(ERR_SVR_MSG_LONGPOLLING_COUNT_LIMIT)];
  267. // Group
  268. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRAccountInternalError) forKey:@(ERR_SVR_GROUP_INTERNAL_ERROR)];
  269. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRGroupApiNameError) forKey:@(ERR_SVR_GROUP_API_NAME_ERROR)];
  270. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRResInvalidParameters) forKey:@(ERR_SVR_GROUP_INVALID_PARAMETERS)];
  271. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRGroupAccountCountLimit) forKey:@(ERR_SVR_GROUP_ACOUNT_COUNT_LIMIT)];
  272. [map setObject:TUIKitLocalizableString(TUIkitErrorSVRGroupFreqLimit) forKey:@(ERR_SVR_GROUP_FREQ_LIMIT)];
  273. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRGroupPermissionDeny) forKey:@(ERR_SVR_GROUP_PERMISSION_DENY)];
  274. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRGroupInvalidReq) forKey:@(ERR_SVR_GROUP_INVALID_REQ)];
  275. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRGroupSuperNotAllowQuit) forKey:@(ERR_SVR_GROUP_SUPER_NOT_ALLOW_QUIT)];
  276. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRGroupNotFound) forKey:@(ERR_SVR_GROUP_NOT_FOUND)];
  277. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRGroupJsonParseFailed) forKey:@(ERR_SVR_GROUP_JSON_PARSE_FAILED)];
  278. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRGroupInvalidId) forKey:@(ERR_SVR_GROUP_INVALID_ID)];
  279. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRGroupAllreadyMember) forKey:@(ERR_SVR_GROUP_ALLREADY_MEMBER)];
  280. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRGroupFullMemberCount) forKey:@(ERR_SVR_GROUP_FULL_MEMBER_COUNT)];
  281. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRGroupInvalidGroupId) forKey:@(ERR_SVR_GROUP_INVALID_GROUPID)];
  282. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRGroupRejectFromThirdParty) forKey:@(ERR_SVR_GROUP_REJECT_FROM_THIRDPARTY)];
  283. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRGroupShutDeny) forKey:@(ERR_SVR_GROUP_SHUTUP_DENY)];
  284. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRGroupRspSizeLimit) forKey:@(ERR_SVR_GROUP_RSP_SIZE_LIMIT)];
  285. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRGroupAccountNotFound) forKey:@(ERR_SVR_GROUP_ACCOUNT_NOT_FOUND)];
  286. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRGroupGroupIdInUse) forKey:@(ERR_SVR_GROUP_GROUPID_IN_USED)];
  287. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRGroupSendMsgFreqLimit) forKey:@(ERR_SVR_GROUP_SEND_MSG_FREQ_LIMIT)];
  288. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRGroupReqAllreadyBeenProcessed) forKey:@(ERR_SVR_GROUP_REQ_ALLREADY_BEEN_PROCESSED)];
  289. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRGroupGroupIdUserdForSuper) forKey:@(ERR_SVR_GROUP_GROUPID_IN_USED_FOR_SUPER)];
  290. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRGroupSDkAppidDeny) forKey:@(ERR_SVR_GROUP_SDKAPPID_DENY)];
  291. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRGroupRevokeMsgNotFound) forKey:@(ERR_SVR_GROUP_REVOKE_MSG_NOT_FOUND)];
  292. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRGroupRevokeMsgTimeLimit) forKey:@(ERR_SVR_GROUP_REVOKE_MSG_TIME_LIMIT)];
  293. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRGroupRevokeMsgDeny) forKey:@(ERR_SVR_GROUP_REVOKE_MSG_DENY)];
  294. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRGroupNotAllowRevokeMsg) forKey:@(ERR_SVR_GROUP_NOT_ALLOW_REVOKE_MSG)];
  295. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRGroupRemoveMsgDeny) forKey:@(ERR_SVR_GROUP_REMOVE_MSG_DENY)];
  296. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRGroupNotAllowRemoveMsg) forKey:@(ERR_SVR_GROUP_NOT_ALLOW_REMOVE_MSG)];
  297. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRGroupAvchatRoomCountLimit) forKey:@(ERR_SVR_GROUP_AVCHATROOM_COUNT_LIMIT)];
  298. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRGroupCountLimit) forKey:@(ERR_SVR_GROUP_COUNT_LIMIT)];
  299. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRGroupMemberCountLimit) forKey:@(ERR_SVR_GROUP_MEMBER_COUNT_LIMIT)];
  300. /////////////////////////////////////////////////////////////////////////////////
  301. //
  302. // (3)Version 3 deprecated
  303. //
  304. /////////////////////////////////////////////////////////////////////////////////
  305. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRNoSuccessResult) forKey:@(ERR_NO_SUCC_RESULT)];
  306. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRToUserInvalid) forKey:@(ERR_TO_USER_INVALID)];
  307. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRInitCoreFail) forKey:@(ERR_INIT_CORE_FAIL)];
  308. [map setObject:TUIKitLocalizableString(TUIKitErrorExpiredSessionNode) forKey:@(ERR_EXPIRED_SESSION_NODE)];
  309. [map setObject:TUIKitLocalizableString(TUIKitErrorLoggedOutBeforeLoginFinished) forKey:@(ERR_LOGGED_OUT_BEFORE_LOGIN_FINISHED)];
  310. [map setObject:TUIKitLocalizableString(TUIKitErrorTLSSDKNotInitialized) forKey:@(ERR_TLSSDK_NOT_INITIALIZED)];
  311. [map setObject:TUIKitLocalizableString(TUIKitErrorTLSSDKUserNotFound) forKey:@(ERR_TLSSDK_USER_NOT_FOUND)];
  312. [map setObject:TUIKitLocalizableString(TUIKitErrorBindFaildRegTimeout) forKey:@(ERR_BIND_FAIL_REG_TIMEOUT)];
  313. [map setObject:TUIKitLocalizableString(TUIKitErrorBindFaildIsBinding) forKey:@(ERR_BIND_FAIL_ISBINDING)];
  314. [map setObject:TUIKitLocalizableString(TUIKitErrorPacketFailUnknown) forKey:@(ERR_PACKET_FAIL_UNKNOWN)];
  315. [map setObject:TUIKitLocalizableString(TUIKitErrorPacketFailReqNoNet) forKey:@(ERR_PACKET_FAIL_REQ_NO_NET)];
  316. [map setObject:TUIKitLocalizableString(TUIKitErrorPacketFailRespNoNet) forKey:@(ERR_PACKET_FAIL_RESP_NO_NET)];
  317. [map setObject:TUIKitLocalizableString(TUIKitErrorPacketFailReqNoAuth) forKey:@(ERR_PACKET_FAIL_REQ_NO_AUTH)];
  318. [map setObject:TUIKitLocalizableString(TUIKitErrorPacketFailSSOErr) forKey:@(ERR_PACKET_FAIL_SSO_ERR)];
  319. [map setObject:TUIKitLocalizableString(TUIKitErrorSVRRequestTimeout) forKey:@(ERR_PACKET_FAIL_REQ_TIMEOUT)];
  320. [map setObject:TUIKitLocalizableString(TUIKitErrorPacketFailRespTimeout) forKey:@(ERR_PACKET_FAIL_RESP_TIMEOUT)];
  321. [map setObject:TUIKitLocalizableString(TUIKitErrorFriendshipProxySyncing) forKey:@(ERR_FRIENDSHIP_PROXY_SYNCING)];
  322. [map setObject:TUIKitLocalizableString(TUIKitErrorFriendshipProxySyncedFail) forKey:@(ERR_FRIENDSHIP_PROXY_SYNCED_FAIL)];
  323. [map setObject:TUIKitLocalizableString(TUIKitErrorFriendshipProxyLocalCheckErr) forKey:@(ERR_FRIENDSHIP_PROXY_LOCAL_CHECK_ERR)];
  324. [map setObject:TUIKitLocalizableString(TUIKitErrorGroupInvalidField) forKey:@(ERR_GROUP_INVALID_FIELD)];
  325. [map setObject:TUIKitLocalizableString(TUIKitErrorGroupStoreageDisabled) forKey:@(ERR_GROUP_STORAGE_DISABLED)];
  326. [map setObject:TUIKitLocalizableString(TUIKitErrorLoadGrpInfoFailed) forKey:@(ERR_LOADGRPINFO_FAILED)];
  327. [map setObject:TUIKitLocalizableString(TUIKitErrorReqNoNetOnReq) forKey:@(ERR_REQ_NO_NET_ON_REQ)];
  328. [map setObject:TUIKitLocalizableString(TUIKitErrorReqNoNetOnResp) forKey:@(ERR_REQ_NO_NET_ON_RSP)];
  329. [map setObject:TUIKitLocalizableString(TUIKitErrorServiceNotReady) forKey:@(ERR_SERIVCE_NOT_READY)];
  330. [map setObject:TUIKitLocalizableString(TUIKitErrorLoginAuthFailed) forKey:@(ERR_LOGIN_AUTH_FAILED)];
  331. [map setObject:TUIKitLocalizableString(TUIKitErrorNeverConnectAfterLaunch) forKey:@(ERR_NEVER_CONNECT_AFTER_LAUNCH)];
  332. [map setObject:TUIKitLocalizableString(TUIKitErrorReqFailed) forKey:@(ERR_REQ_FAILED)];
  333. [map setObject:TUIKitLocalizableString(TUIKitErrorReqInvaidReq) forKey:@(ERR_REQ_INVALID_REQ)];
  334. [map setObject:TUIKitLocalizableString(TUIKitErrorReqOnverLoaded) forKey:@(ERR_REQ_OVERLOADED)];
  335. [map setObject:TUIKitLocalizableString(TUIKitErrorReqKickOff) forKey:@(ERR_REQ_KICK_OFF)];
  336. [map setObject:TUIKitLocalizableString(TUIKitErrorReqServiceSuspend) forKey:@(ERR_REQ_SERVICE_SUSPEND)];
  337. [map setObject:TUIKitLocalizableString(TUIKitErrorReqInvalidSign) forKey:@(ERR_REQ_INVALID_SIGN)];
  338. [map setObject:TUIKitLocalizableString(TUIKitErrorReqInvalidCookie) forKey:@(ERR_REQ_INVALID_COOKIE)];
  339. [map setObject:TUIKitLocalizableString(TUIKitErrorLoginTlsRspParseFailed) forKey:@(ERR_LOGIN_TLS_RSP_PARSE_FAILED)];
  340. [map setObject:TUIKitLocalizableString(TUIKitErrorLoginOpenMsgTimeout) forKey:@(ERR_LOGIN_OPENMSG_TIMEOUT)];
  341. [map setObject:TUIKitLocalizableString(TUIKitErrorLoginOpenMsgRspParseFailed) forKey:@(ERR_LOGIN_OPENMSG_RSP_PARSE_FAILED)];
  342. [map setObject:TUIKitLocalizableString(TUIKitErrorLoginTslDecryptFailed) forKey:@(ERR_LOGIN_TLS_DECRYPT_FAILED)];
  343. [map setObject:TUIKitLocalizableString(TUIKitErrorWifiNeedAuth) forKey:@(ERR_WIFI_NEED_AUTH)];
  344. [map setObject:TUIKitLocalizableString(TUIKitErrorUserCanceled) forKey:@(ERR_USER_CANCELED)];
  345. [map setObject:TUIKitLocalizableString(TUIkitErrorRevokeTimeLimitExceed) forKey:@(ERR_REVOKE_TIME_LIMIT_EXCEED)];
  346. [map setObject:TUIKitLocalizableString(TUIKitErrorLackUGExt) forKey:@(ERR_LACK_UGC_EXT)];
  347. [map setObject:TUIKitLocalizableString(TUIKitErrorAutoLoginNeedUserSig) forKey:@(ERR_AUTOLOGIN_NEED_USERSIG)];
  348. [map setObject:TUIKitLocalizableString(TUIKitErrorQALNoShortConneAvailable) forKey:@(ERR_QAL_NO_SHORT_CONN_AVAILABLE)];
  349. [map setObject:TUIKitLocalizableString(TUIKitErrorReqContentAttach) forKey:@(ERR_REQ_CONTENT_ATTACK)];
  350. [map setObject:TUIKitLocalizableString(TUIKitErrorLoginSigExpire) forKey:@(ERR_LOGIN_SIG_EXPIRE)];
  351. [map setObject:TUIKitLocalizableString(TUIKitErrorSDKHadInit) forKey:@(ERR_SDK_HAD_INITIALIZED)];
  352. [map setObject:TUIKitLocalizableString(TUIKitErrorOpenBDHBase) forKey:@(ERR_OPENBDH_BASE)];
  353. [map setObject:TUIKitLocalizableString(TUIKitErrorRequestNoNetOnReq) forKey:@(ERR_REQUEST_NO_NET_ONREQ)];
  354. [map setObject:TUIKitLocalizableString(TUIKitErrorRequestNoNetOnRsp) forKey:@(ERR_REQUEST_NO_NET_ONRSP)];
  355. [map setObject:TUIKitLocalizableString(TUIKitErrorRequestOnverLoaded) forKey:@(ERR_REQUEST_OVERLOADED)];
  356. [map setObject:TUIKitLocalizableString(TUIKitErrorReqKickOff) forKey:@(ERR_REQUEST_KICK_OFF)];
  357. [map setObject:TUIKitLocalizableString(TUIKitErrorReqServiceSuspend) forKey:@(ERR_REQUEST_SERVICE_SUSPEND)];
  358. [map setObject:TUIKitLocalizableString(TUIKitErrorReqInvalidSign) forKey:@(ERR_REQUEST_INVALID_SIGN)];
  359. [map setObject:TUIKitLocalizableString(TUIKitErrorReqInvalidCookie) forKey:@(ERR_REQUEST_INVALID_COOKIE)];
  360. }
  361. + (NSData *)dictionary2JsonData:(NSDictionary *)dict {
  362. if ([NSJSONSerialization isValidJSONObject:dict]) {
  363. NSError *error = nil;
  364. NSData *data = [NSJSONSerialization dataWithJSONObject:dict options:0 error:&error];
  365. if (error) {
  366. NSLog(@"[%@] Post Json Error", [self class]);
  367. }
  368. return data;
  369. } else {
  370. NSLog(@"[%@] Post Json is not valid", [self class]);
  371. }
  372. return nil;
  373. }
  374. + (NSString *)dictionary2JsonStr:(NSDictionary *)dict {
  375. return [[NSString alloc] initWithData:[self dictionary2JsonData:dict] encoding:NSUTF8StringEncoding];
  376. ;
  377. }
  378. + (NSDictionary *)jsonSring2Dictionary:(NSString *)jsonString {
  379. if (jsonString == nil) {
  380. return nil;
  381. }
  382. NSData *data = [jsonString dataUsingEncoding:NSUTF8StringEncoding];
  383. NSError *err = nil;
  384. NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:&err];
  385. if (err || ![dic isKindOfClass:[NSDictionary class]]) {
  386. NSLog(@"Json parse failed: %@", jsonString);
  387. return nil;
  388. }
  389. return dic;
  390. }
  391. + (NSDictionary *)jsonData2Dictionary:(NSData *)jsonData {
  392. if (jsonData == nil) {
  393. return nil;
  394. }
  395. NSError *err = nil;
  396. NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:jsonData options:NSJSONReadingMutableContainers error:&err];
  397. if (err || ![dic isKindOfClass:[NSDictionary class]]) {
  398. NSLog(@"Json parse failed");
  399. return nil;
  400. }
  401. return dic;
  402. }
  403. + (void)asyncDecodeImage:(NSString *)path complete:(TAsyncImageComplete)complete {
  404. static dispatch_queue_t queue;
  405. static dispatch_once_t onceToken;
  406. dispatch_once(&onceToken, ^{
  407. queue = dispatch_queue_create("com.tuikit.asyncDecodeImage", DISPATCH_QUEUE_SERIAL);
  408. });
  409. // callback on main thread
  410. void (^callback)(NSString *, UIImage *) = ^(NSString *path, UIImage *image) {
  411. if (complete == nil) {
  412. return;
  413. }
  414. dispatch_async(dispatch_get_main_queue(), ^{
  415. complete(path, image);
  416. });
  417. };
  418. if (path == nil) {
  419. callback(nil, nil);
  420. return;
  421. }
  422. dispatch_async(queue, ^{
  423. // The path ends with gif:
  424. if ([path tui_containsString:@".gif"]) {
  425. UIImage *image = [UIImage sd_imageWithGIFData:[NSData dataWithContentsOfFile:path]];
  426. callback(path, image);
  427. return;
  428. }
  429. // load origin image
  430. UIImage *image = [UIImage imageWithContentsOfFile:path];
  431. // There is no path ending, but it may actually be a gif image
  432. if (image == nil) {
  433. NSString *formatPath = [path stringByAppendingString:@".gif"];
  434. image = [UIImage sd_imageWithGIFData:[NSData dataWithContentsOfFile:formatPath]];
  435. callback(formatPath, image);
  436. return;
  437. }
  438. if (image == nil) {
  439. callback(path, image);
  440. return;
  441. }
  442. if (image.sd_imageFormat == SDImageFormatGIF) {
  443. image = [UIImage sd_imageWithGIFData:[NSData dataWithContentsOfFile:path]];
  444. callback(path, image);
  445. return;
  446. }
  447. // SDWebImage is priority
  448. UIImage *decodeImage = [SDImageCoderHelper decodedImageWithImage:image];
  449. if (decodeImage) {
  450. callback(path, decodeImage);
  451. return;
  452. }
  453. // Bitmap
  454. CGImageRef cgImage = image.CGImage;
  455. if (cgImage) {
  456. CGImageAlphaInfo alphaInfo = CGImageGetAlphaInfo(cgImage) & kCGBitmapAlphaInfoMask;
  457. BOOL hasAlpha = NO;
  458. if (alphaInfo == kCGImageAlphaPremultipliedLast || alphaInfo == kCGImageAlphaPremultipliedFirst || alphaInfo == kCGImageAlphaLast ||
  459. alphaInfo == kCGImageAlphaFirst) {
  460. hasAlpha = YES;
  461. }
  462. CGBitmapInfo bitmapInfo = kCGBitmapByteOrder32Host;
  463. bitmapInfo |= hasAlpha ? kCGImageAlphaPremultipliedFirst : kCGImageAlphaNoneSkipFirst;
  464. size_t width = CGImageGetWidth(cgImage);
  465. size_t height = CGImageGetHeight(cgImage);
  466. CGContextRef context = CGBitmapContextCreate(NULL, width, height, 8, 0, CGColorSpaceCreateDeviceRGB(), bitmapInfo);
  467. if (context) {
  468. CGContextDrawImage(context, CGRectMake(0, 0, width, height), cgImage);
  469. cgImage = CGBitmapContextCreateImage(context);
  470. decodeImage = [UIImage imageWithCGImage:cgImage scale:image.scale orientation:image.imageOrientation];
  471. CGContextRelease(context);
  472. CGImageRelease(cgImage);
  473. }
  474. }
  475. callback(path, decodeImage);
  476. });
  477. }
  478. + (void)makeToast:(NSString *)str {
  479. if ([TUIConfig defaultConfig].enableToast) {
  480. [[UIApplication sharedApplication].keyWindow makeToast:str];
  481. }
  482. }
  483. + (void)makeToast:(NSString *)str duration:(NSTimeInterval)duration {
  484. if ([TUIConfig defaultConfig].enableToast) {
  485. [[UIApplication sharedApplication].keyWindow makeToast:str duration:duration];
  486. }
  487. }
  488. + (void)makeToast:(NSString *)str duration:(NSTimeInterval)duration position:(CGPoint)position {
  489. if ([TUIConfig defaultConfig].enableToast) {
  490. [[UIApplication sharedApplication].keyWindow makeToast:str duration:duration position:[NSValue valueWithCGPoint:position]];
  491. }
  492. }
  493. + (void)makeToast:(NSString *)str duration:(NSTimeInterval)duration idposition:(id)position {
  494. if ([TUIConfig defaultConfig].enableToast) {
  495. [[UIApplication sharedApplication].keyWindow makeToast:str duration:duration position:position];
  496. }
  497. }
  498. + (void)makeToastError:(NSInteger)error msg:(NSString *)msg {
  499. if ([TUIConfig defaultConfig].enableToast) {
  500. [[UIApplication sharedApplication].keyWindow makeToast:[self convertIMError:error msg:msg]];
  501. }
  502. }
  503. + (void)hideToast {
  504. if ([TUIConfig defaultConfig].enableToast) {
  505. [[UIApplication sharedApplication].keyWindow hideToast];
  506. }
  507. }
  508. + (void)makeToastActivity {
  509. if ([TUIConfig defaultConfig].enableToast) {
  510. [[UIApplication sharedApplication].keyWindow makeToastActivity:TUICSToastPositionCenter];
  511. }
  512. }
  513. + (void)hideToastActivity {
  514. if ([TUIConfig defaultConfig].enableToast) {
  515. [[UIApplication sharedApplication].keyWindow hideToastActivity];
  516. }
  517. }
  518. + (NSString *)convertDateToStr:(NSDate *)date {
  519. if (!date) {
  520. return nil;
  521. }
  522. if ([date isEqualToDate:[NSDate distantPast]]) {
  523. return @"";
  524. }
  525. static NSDateFormatter *dateFmt = nil;
  526. if (dateFmt == nil) {
  527. dateFmt = [[NSDateFormatter alloc] init];
  528. }
  529. dateFmt.locale = nil;
  530. NSCalendar *calendar = [NSCalendar currentCalendar];
  531. calendar.firstWeekday = 7;
  532. NSDateComponents *nowComponent = [calendar components:NSCalendarUnitDay | NSCalendarUnitMonth | NSCalendarUnitYear | NSCalendarUnitWeekOfMonth
  533. fromDate:NSDate.new];
  534. NSDateComponents *dateCompoent = [calendar components:NSCalendarUnitDay | NSCalendarUnitMonth | NSCalendarUnitYear | NSCalendarUnitWeekOfMonth
  535. fromDate:date];
  536. if (nowComponent.year == dateCompoent.year) {
  537. // Same year
  538. if (nowComponent.month == dateCompoent.month) {
  539. // Same month
  540. if (nowComponent.weekOfMonth == dateCompoent.weekOfMonth) {
  541. // Same week
  542. if (nowComponent.day == dateCompoent.day) {
  543. // Same day
  544. dateFmt.dateFormat = @"HH:mm";
  545. } else {
  546. // Not same day
  547. dateFmt.dateFormat = @"EEEE";
  548. NSString *identifer = [TUIGlobalization getPreferredLanguage];
  549. dateFmt.locale = [NSLocale localeWithLocaleIdentifier:identifer];
  550. }
  551. } else {
  552. // Not same weeek
  553. dateFmt.dateFormat = @"MM/dd";
  554. }
  555. } else {
  556. // Not same month
  557. dateFmt.dateFormat = @"MM/dd";
  558. }
  559. } else {
  560. // Not same year
  561. dateFmt.dateFormat = @"yyyy/MM/dd";
  562. }
  563. NSString *str = [dateFmt stringFromDate:date];
  564. return str;
  565. }
  566. + (NSString *)convertDateToDetailStr:(NSDate *)date {
  567. if (!date) {
  568. return nil;
  569. }
  570. if ([date isEqualToDate:[NSDate distantPast]]) {
  571. return @"";
  572. }
  573. NSDateFormatter *dateFmt = [[NSDateFormatter alloc] init];
  574. dateFmt.dateFormat = @"yyyy-MM-dd HH:mm";
  575. NSString *str = [dateFmt stringFromDate:date];
  576. return str;
  577. }
  578. + (NSString *)convertDateToHMStr:(NSDate *)date {
  579. if (!date) {
  580. return nil;
  581. }
  582. if ([date isEqualToDate:[NSDate distantPast]]) {
  583. return @"";
  584. }
  585. NSDateFormatter *dateFmt = [[NSDateFormatter alloc] init];
  586. dateFmt.dateFormat = @"HH:mm";
  587. NSString *str = [dateFmt stringFromDate:date];
  588. return str;
  589. }
  590. + (NSString *)convertIMError:(NSInteger)code msg:(NSString *)msg {
  591. NSString *resultMsg = @"";
  592. resultMsg = gIMErrorMsgMap[@(code)];
  593. if (resultMsg.length > 0) {
  594. return resultMsg;
  595. }
  596. return msg;
  597. }
  598. + (void)dispatchMainAsync:(dispatch_block_t)block {
  599. if ([NSThread isMainThread]) {
  600. block();
  601. } else {
  602. dispatch_async(dispatch_get_main_queue(), block);
  603. }
  604. }
  605. + (NSString *)genImageName:(NSString *)uuid {
  606. NSString *identifier = [[V2TIMManager sharedInstance] getLoginUser];
  607. if (uuid == nil) {
  608. int value = arc4random() % 1000;
  609. uuid = [NSString stringWithFormat:@"%ld_%d", (long)[[NSDate date] timeIntervalSince1970], value];
  610. }
  611. NSString *name = [NSString stringWithFormat:@"%d_%@_image_%@", [TUILogin getSdkAppID], identifier, uuid];
  612. return name;
  613. }
  614. + (NSString *)genImageExtenionName:(UIImage *)image {
  615. if (!image) {
  616. return @"";
  617. }
  618. static NSDictionary *imageFormatExtensionMap = nil;
  619. if (imageFormatExtensionMap == nil) {
  620. imageFormatExtensionMap = @{
  621. @(SDImageFormatUndefined) : @"",
  622. @(SDImageFormatJPEG) : @"jpeg",
  623. @(SDImageFormatPNG) : @"png",
  624. @(SDImageFormatGIF) : @"gif",
  625. @(SDImageFormatTIFF) : @"tiff",
  626. @(SDImageFormatWebP) : @"webp",
  627. @(SDImageFormatHEIC) : @"heic",
  628. @(SDImageFormatHEIF) : @"heif",
  629. @(SDImageFormatPDF) : @"pdf",
  630. @(SDImageFormatSVG) : @"svg",
  631. @(SDImageFormatBMP) : @"bmp",
  632. @(SDImageFormatRAW) : @"raw"
  633. };
  634. }
  635. return [imageFormatExtensionMap objectForKey:@(image.sd_imageFormat)];
  636. }
  637. + (NSString *)genSnapshotName:(NSString *)uuid {
  638. NSString *identifier = [[V2TIMManager sharedInstance] getLoginUser];
  639. if (uuid == nil) {
  640. int value = arc4random() % 1000;
  641. uuid = [NSString stringWithFormat:@"%ld_%d", (long)[[NSDate date] timeIntervalSince1970], value];
  642. }
  643. NSString *name = [NSString stringWithFormat:@"%d_%@_snapshot_%@", [TUILogin getSdkAppID], identifier, uuid];
  644. return name;
  645. }
  646. + (NSString *)genVideoName:(NSString *)uuid {
  647. NSString *identifier = [[V2TIMManager sharedInstance] getLoginUser];
  648. if (uuid == nil) {
  649. uuid = [NSString stringWithFormat:@"%ld", (long)[[NSDate date] timeIntervalSince1970]];
  650. }
  651. NSString *name = [NSString stringWithFormat:@"%d_%@_video_%@", [TUILogin getSdkAppID], identifier, uuid];
  652. return name;
  653. }
  654. + (NSString *)genVoiceName:(NSString *)uuid withExtension:(NSString *)extent {
  655. NSString *identifier = [[V2TIMManager sharedInstance] getLoginUser];
  656. if (uuid == nil) {
  657. uuid = [NSString stringWithFormat:@"%ld", (long)[[NSDate date] timeIntervalSince1970]];
  658. }
  659. NSString *name = [NSString stringWithFormat:@"%d_%@_voice_%@.%@", [TUILogin getSdkAppID], identifier, uuid, extent];
  660. return name;
  661. }
  662. + (NSString *)genFileName:(NSString *)uuid {
  663. NSString *identifier = [[V2TIMManager sharedInstance] getLoginUser];
  664. if (uuid == nil) {
  665. uuid = [NSString stringWithFormat:@"%ld", (long)[[NSDate date] timeIntervalSince1970]];
  666. }
  667. NSString *name = [NSString stringWithFormat:@"%d_%@_file_%@", [TUILogin getSdkAppID], identifier, uuid];
  668. return name;
  669. }
  670. + (NSString *)deviceModel {
  671. static NSString *deviceModel;
  672. static dispatch_once_t onceToken;
  673. dispatch_once(&onceToken, ^{
  674. deviceModel = [[UIDevice currentDevice] model];
  675. });
  676. return deviceModel;
  677. }
  678. + (NSString *)deviceVersion {
  679. static NSString *deviceVersion;
  680. static dispatch_once_t onceToken;
  681. dispatch_once(&onceToken, ^{
  682. deviceVersion = [[UIDevice currentDevice] systemVersion];
  683. });
  684. return deviceVersion;
  685. }
  686. + (NSString *)deviceName {
  687. static NSString *deviceName;
  688. static dispatch_once_t onceToken;
  689. dispatch_once(&onceToken, ^{
  690. deviceName = [[UIDevice currentDevice] name];
  691. });
  692. return deviceName;
  693. }
  694. + (void)openLinkWithURL:(NSURL *)url {
  695. if (@available(iOS 10.0, *)) {
  696. [[UIApplication sharedApplication] openURL:url
  697. options:@{}
  698. completionHandler:^(BOOL success) {
  699. if (success) {
  700. NSLog(@"Opened url");
  701. }
  702. }];
  703. } else {
  704. [[UIApplication sharedApplication] openURL:url];
  705. }
  706. }
  707. + (void)addUnsupportNotificationInVC:(UIViewController *)vc {
  708. [self addUnsupportNotificationInVC:vc debugOnly:YES];
  709. }
  710. + (void)addUnsupportNotificationInVC:(UIViewController *)vc debugOnly:(BOOL)debugOnly {
  711. BOOL enable = YES;
  712. if (debugOnly) {
  713. #if DEBUG
  714. enable = YES;
  715. #else
  716. enable = NO;
  717. #endif
  718. }
  719. if (!enable) {
  720. return;
  721. }
  722. TUIWeakProxy *weakVC = [TUIWeakProxy proxyWithTarget:vc];
  723. [[NSNotificationCenter defaultCenter] addObserverForName:TUIKitNotification_onReceivedUnsupportInterfaceError
  724. object:nil
  725. queue:nil
  726. usingBlock:^(NSNotification *_Nonnull note) {
  727. NSDictionary *userInfo = note.userInfo;
  728. NSString *service = [userInfo objectForKey:@"service"];
  729. NSString *serviceDesc = [userInfo objectForKey:@"serviceDesc"];
  730. if (weakVC.target) {
  731. [TUITool showUnsupportAlertOfService:service serviceDesc:serviceDesc onVC:weakVC.target];
  732. }
  733. }];
  734. }
  735. + (void)postUnsupportNotificationOfService:(NSString *)service {
  736. [self postUnsupportNotificationOfService:service serviceDesc:nil debugOnly:YES];
  737. }
  738. + (void)postUnsupportNotificationOfService:(NSString *)service serviceDesc:(NSString *)serviceDesc debugOnly:(BOOL)debugOnly {
  739. BOOL enable = YES;
  740. if (debugOnly) {
  741. #if DEBUG
  742. enable = YES;
  743. #else
  744. enable = NO;
  745. #endif
  746. }
  747. if (!enable) {
  748. return;
  749. }
  750. if (!service) {
  751. NSLog(@"postNotificationOfService, service is nil");
  752. return;
  753. }
  754. [[NSNotificationCenter defaultCenter] postNotificationName:TUIKitNotification_onReceivedUnsupportInterfaceError
  755. object:nil
  756. userInfo:@{@"service" : service ?: @"", @"serviceDesc" : serviceDesc ?: @""}];
  757. }
  758. + (void)showUnsupportAlertOfService:(NSString *)service serviceDesc:(NSString *)serviceDesc onVC:(UIViewController *)vc {
  759. NSString *key = [NSString stringWithFormat:@"show_unsupport_alert_%@", service];
  760. BOOL isShown = [[NSUserDefaults standardUserDefaults] boolForKey:key];
  761. if (isShown) {
  762. return;
  763. }
  764. NSString *desc = [NSString stringWithFormat:@"%@%@%@", service, TUIKitLocalizableString(TUIKitErrorUnsupportIntefaceDesc), serviceDesc ?: @""];
  765. NSArray *buttons = @[ TUIKitLocalizableString(TUIKitErrorUnsupportIntefaceIGotIt), TUIKitLocalizableString(TUIKitErrorUnsupportIntefaceNoMoreAlert) ];
  766. UIAlertController *alertController = [UIAlertController alertControllerWithTitle:TUIKitLocalizableString(TUIKitErrorUnsupportIntefaceTitle)
  767. message:desc
  768. preferredStyle:UIAlertControllerStyleAlert];
  769. NSMutableAttributedString *attrStr = [[NSMutableAttributedString alloc] initWithString:desc];
  770. [attrStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:14] range:NSMakeRange(0, desc.length)];
  771. [attrStr addAttribute:NSLinkAttributeName value:@"https://" range:[desc rangeOfString:TUIKitLocalizableString(TUIKitErrorUnsupportIntefaceGuidelines)]];
  772. [alertController setValue:attrStr forKey:@"attributedMessage"];
  773. UILabel *msgLabel = [TUITool messageLabelInAlertController:alertController];
  774. msgLabel.userInteractionEnabled = YES;
  775. msgLabel.textAlignment = NSTextAlignmentLeft;
  776. UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:TUITool.class action:@selector(onTapLabel:)];
  777. [msgLabel addGestureRecognizer:tap];
  778. UIAlertAction *left = [UIAlertAction actionWithTitle:buttons[0]
  779. style:UIAlertActionStyleDefault
  780. handler:^(UIAlertAction *_Nonnull action){
  781. }];
  782. UIAlertAction *right = [UIAlertAction actionWithTitle:buttons[1]
  783. style:UIAlertActionStyleDefault
  784. handler:^(UIAlertAction *_Nonnull action) {
  785. [[NSUserDefaults standardUserDefaults] setBool:YES forKey:key];
  786. [[NSUserDefaults standardUserDefaults] synchronize];
  787. }];
  788. [alertController tuitheme_addAction:left];
  789. [alertController tuitheme_addAction:right];
  790. [vc presentViewController:alertController animated:NO completion:nil];
  791. }
  792. + (void)onTapLabel:(UIGestureRecognizer *)ges {
  793. NSString *chinesePurchase = @"https://cloud.tencent.com/document/product/269/11673#.E5.9F.BA.E7.A1.80.E6.9C.8D.E5.8A.A1.E8.AF.A6.E6.83.85";
  794. NSString *englishPurchase = @"https://intl.cloud.tencent.com/document/product/1047/36021?lang=en&pg=#changing-configuration";
  795. NSString *language = [TUIGlobalization tk_localizableLanguageKey];
  796. NSURL *url = [NSURL URLWithString:chinesePurchase];
  797. if (![language tui_containsString:@"zh-"]) {
  798. url = [NSURL URLWithString:englishPurchase];
  799. }
  800. [TUITool openLinkWithURL:url];
  801. }
  802. + (void)addValueAddedUnsupportNeedContactNotificationInVC:(UIViewController *)vc debugOnly:(BOOL)debugOnly {
  803. BOOL enable = YES;
  804. if (debugOnly) {
  805. #if DEBUG
  806. enable = YES;
  807. #else
  808. enable = NO;
  809. #endif
  810. }
  811. if (!enable) {
  812. return;
  813. }
  814. [[NSNotificationCenter defaultCenter] addObserverForName:TUIKitNotification_onReceivedValueAddedUnsupportContactNeededError
  815. object:nil
  816. queue:nil
  817. usingBlock:^(NSNotification *_Nonnull note) {
  818. NSDictionary *userInfo = note.userInfo;
  819. NSString *service = [userInfo objectForKey:@"service"];
  820. [TUITool showValueAddedUnsupportNeedContactAlertOfService:service onVC:vc];
  821. }];
  822. }
  823. + (void)addValueAddedUnsupportNeedPurchaseNotificationInVC:(UIViewController *)vc debugOnly:(BOOL)debugOnly {
  824. BOOL enable = YES;
  825. if (debugOnly) {
  826. #if DEBUG
  827. enable = YES;
  828. #else
  829. enable = NO;
  830. #endif
  831. }
  832. if (!enable) {
  833. return;
  834. }
  835. __weak __typeof(vc) weakVC = vc;
  836. [[NSNotificationCenter defaultCenter] addObserverForName:TUIKitNotification_onReceivedValueAddedUnsupportPurchaseNeededError
  837. object:nil
  838. queue:nil
  839. usingBlock:^(NSNotification *_Nonnull note) {
  840. __strong __typeof(weakVC) strongVC = weakVC;
  841. NSDictionary *userInfo = note.userInfo;
  842. NSString *service = [userInfo objectForKey:@"service"];
  843. [TUITool showValueAddedUnsupportNeedPurchaseAlertOfService:service onVC:strongVC];
  844. }];
  845. }
  846. + (void)postValueAddedUnsupportNeedContactNotification:(NSString *)service {
  847. [self postValueAddedUnsupportNotification:TUIKitNotification_onReceivedValueAddedUnsupportContactNeededError
  848. service:service
  849. serviceDesc:nil
  850. debugOnly:YES];
  851. }
  852. + (void)postValueAddedUnsupportNeedPurchaseNotification:(NSString *)service {
  853. [self postValueAddedUnsupportNotification:TUIKitNotification_onReceivedValueAddedUnsupportPurchaseNeededError
  854. service:service
  855. serviceDesc:nil
  856. debugOnly:YES];
  857. }
  858. + (void)postValueAddedUnsupportNotification:(NSString *)notification service:(NSString *)service serviceDesc:(NSString *)serviceDesc debugOnly:(BOOL)debugOnly {
  859. BOOL enable = YES;
  860. if (debugOnly) {
  861. #if DEBUG
  862. enable = YES;
  863. #else
  864. enable = NO;
  865. #endif
  866. }
  867. if (!enable) {
  868. return;
  869. }
  870. if (!service) {
  871. NSLog(@"postNotificationOfService, service is nil");
  872. return;
  873. }
  874. [[NSNotificationCenter defaultCenter] postNotificationName:notification
  875. object:nil
  876. userInfo:@{@"service" : service ?: @"",
  877. @"serviceDesc" : serviceDesc ?: @""}];
  878. }
  879. + (void)showValueAddedUnsupportNeedContactAlertOfService:(NSString *)service onVC:(UIViewController *)vc {
  880. [self showValueAddedUnsupportAlertOfService:service
  881. serviceDesc:TUIKitLocalizableString(TUIKitErrorValueAddedUnsupportIntefaceContactDesc)
  882. onVC:vc
  883. highlightText:TUIKitLocalizableString(TUIKitErrorValueAddedUnsupportIntefaceContactDescHighlight)
  884. sel:@selector(onTapValueAddedContactLabel)];
  885. }
  886. + (void)showValueAddedUnsupportNeedPurchaseAlertOfService:(NSString *)service onVC:(UIViewController *)vc {
  887. [self showValueAddedUnsupportAlertOfService:service
  888. serviceDesc:TUIKitLocalizableString(TUIKitErrorValueAddedUnsupportIntefacePurchaseDesc)
  889. onVC:vc
  890. highlightText:TUIKitLocalizableString(TUIKitErrorValueAddedUnsupportIntefacePurchaseDescHighlight)
  891. sel:@selector(onTapValueAddedPurchaseLabel)];
  892. }
  893. + (void)showValueAddedUnsupportAlertOfService:(NSString *)service serviceDesc:(NSString *)serviceDesc onVC:(UIViewController *)vc
  894. highlightText:(NSString *)text sel:(SEL)selector {
  895. NSString *desc = [NSString stringWithFormat:@"%@%@", service, serviceDesc ?: @""];
  896. NSString *button = TUIKitLocalizableString(TUIKitErrorUnsupportIntefaceIGotIt);
  897. UIAlertController *alertController = [UIAlertController alertControllerWithTitle:TUIKitLocalizableString(TUIKitErrorUnsupportIntefaceTitle)
  898. message:desc
  899. preferredStyle:UIAlertControllerStyleAlert];
  900. NSMutableAttributedString *attrStr = [[NSMutableAttributedString alloc] initWithString:desc];
  901. [attrStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:14] range:NSMakeRange(0, desc.length)];
  902. [attrStr addAttribute:NSLinkAttributeName value:@"https://" range:[desc rangeOfString:text]];
  903. [alertController setValue:attrStr forKey:@"attributedMessage"];
  904. UILabel *msgLabel = [TUITool messageLabelInAlertController:alertController];
  905. msgLabel.userInteractionEnabled = YES;
  906. msgLabel.textAlignment = NSTextAlignmentLeft;
  907. UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:TUITool.class action:selector];
  908. [msgLabel addGestureRecognizer:tap];
  909. UIAlertAction *ok = [UIAlertAction actionWithTitle:button
  910. style:UIAlertActionStyleDefault
  911. handler:^(UIAlertAction *_Nonnull action){
  912. }];
  913. [alertController tuitheme_addAction:ok];
  914. [vc presentViewController:alertController animated:NO completion:nil];
  915. }
  916. + (void)onTapValueAddedContactLabel {
  917. NSURL *url = [NSURL URLWithString:@"https://zhiliao.qq.com"];
  918. [TUITool openLinkWithURL:url];
  919. }
  920. + (void)onTapValueAddedPurchaseLabel {
  921. NSURL *url = [NSURL URLWithString:@"https://buy.cloud.tencent.com/avc?activeId=plugin&regionId=1"];
  922. [TUITool openLinkWithURL:url];
  923. }
  924. + (void)checkCommercialAbility:(long long)param succ:(void (^)(BOOL enabled))succ fail:(void (^)(int code, NSString *desc))fail {
  925. NSLog(@"checkCommercialAbility param: %lld", param);
  926. dispatch_async(dispatch_get_main_queue(), ^{
  927. NSNumber *paramNum = [NSNumber numberWithLongLong:param];
  928. [[V2TIMManager sharedInstance] callExperimentalAPI:@"isCommercialAbilityEnabled"
  929. param:paramNum
  930. succ:^(NSObject *result) {
  931. dispatch_async(dispatch_get_main_queue(), ^{
  932. BOOL isEnabled = [(NSNumber *)result boolValue];
  933. NSLog(@"checkCommercialAbility enabled: %d", isEnabled);
  934. if (succ) {
  935. succ(isEnabled);
  936. }
  937. });
  938. }
  939. fail:^(int code, NSString *desc) {
  940. dispatch_async(dispatch_get_main_queue(), ^{
  941. NSLog(@"checkCommercialAbility error, code:%d, desc:%@", code, desc);
  942. if (fail) {
  943. fail(code, desc);
  944. }
  945. });
  946. }];
  947. });
  948. }
  949. + (UILabel *)messageLabelInAlertController:(UIAlertController *)alert {
  950. UIView *target = [TUITool targetSubviewInAlertController:alert];
  951. NSArray *subviews = [target subviews];
  952. if (subviews.count == 0) {
  953. return nil;
  954. }
  955. for (UIView *view in subviews) {
  956. if ([view isKindOfClass:UILabel.class]) {
  957. UILabel *label = (UILabel *)view;
  958. if (label.text.length > 10) {
  959. return label;
  960. }
  961. }
  962. }
  963. return nil;
  964. }
  965. + (UIView *)targetSubviewInAlertController:(UIAlertController *)alert {
  966. UIView *view = alert.view;
  967. for (int i = 0; i < 5; i++) {
  968. view = view.subviews.firstObject;
  969. }
  970. return view;
  971. }
  972. + (UIWindow *)applicationKeywindow {
  973. UIWindow *keywindow = UIApplication.sharedApplication.keyWindow;
  974. if (keywindow == nil) {
  975. if (@available(iOS 13.0, *)) {
  976. for (UIWindowScene *scene in UIApplication.sharedApplication.connectedScenes) {
  977. if (scene.activationState == UISceneActivationStateForegroundActive) {
  978. UIWindow *tmpWindow = nil;
  979. if (@available(iOS 15.0, *)) {
  980. tmpWindow = scene.keyWindow;
  981. }
  982. if (tmpWindow == nil) {
  983. for (UIWindow *window in scene.windows) {
  984. if (window.windowLevel == UIWindowLevelNormal && window.hidden == NO &&
  985. CGRectEqualToRect(window.bounds, UIScreen.mainScreen.bounds)) {
  986. tmpWindow = window;
  987. break;
  988. }
  989. }
  990. }
  991. }
  992. }
  993. }
  994. }
  995. if (keywindow == nil) {
  996. for (UIWindow *window in UIApplication.sharedApplication.windows) {
  997. if (window.windowLevel == UIWindowLevelNormal && window.hidden == NO && CGRectEqualToRect(window.bounds, UIScreen.mainScreen.bounds)) {
  998. keywindow = window;
  999. break;
  1000. }
  1001. }
  1002. }
  1003. return keywindow;
  1004. }
  1005. @end