YBImManager.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. //
  2. // YBImManager.h
  3. // YBHiMo
  4. //
  5. // Created by YB007 on 2021/9/15.
  6. // Copyright © 2021 YB007. All rights reserved.
  7. //
  8. #import <Foundation/Foundation.h>
  9. #import "TConversationCell.h"
  10. #import <ImSDK_Plus/ImSDK_Plus.h>
  11. #import "TMessageCell.h"
  12. #pragma mark - 自定义消息 action
  13. /// 用户发起
  14. static const int IMAction_CallUserReq = 0;
  15. /// 用户取消
  16. static const int IMAction_CallUserCancel = 1;
  17. /// 主播发起
  18. static const int IMAction_CallAnchorReq = 2;
  19. /// 主播取消
  20. static const int IMAction_CallAnchorCancel = 3;
  21. /// 主播接听
  22. static const int IMAction_CallAnchorAgree = 4;
  23. /// 主播拒绝
  24. static const int IMAction_CallAnchorReject = 5;
  25. /// 用户接听
  26. static const int IMAction_CallUserAgree = 6;
  27. /// 用户拒绝
  28. static const int IMAction_CallUserReject = 7;
  29. /// 主播挂断
  30. static const int IMAction_CallAnchorHang = 8;
  31. /// 用户挂断
  32. static const int IMAction_CallUserHang = 9;
  33. /// 拍乐云检测实现
  34. /// 关闭摄像
  35. //static const int IMAction_CallCameraClose = 10;
  36. /// 打开摄像
  37. //static const int IMAction_CallCameraOpen = 11;
  38. /**
  39. * 可以使用 TIMProfileTypeKey_Custom_Prefix 来获取IM的前缀
  40. * Tag_Profile_Custom_age 年龄
  41. * Tag_Profile_Custom_avatar 头像
  42. * Tag_Profile_Custom_city 城市
  43. * Tag_Profile_Custom_nickname 昵称
  44. * Tag_Profile_Custom_sex 性别
  45. * Tag_Profile_Custom_sign 签名(交友心声)
  46. */
  47. /// 这里定义了用户信息后缀,请勿改动,需要和腾讯IM控制台统一
  48. #define IMKey_Custom_Suffix_Age @"age"
  49. #define IMKey_Custom_Suffix_Avatar @"avatar"
  50. #define IMKey_Custom_Suffix_City @"city"
  51. #define IMKey_Custom_Suffix_Nickname @"nickname"
  52. #define IMKey_Custom_Suffix_Sex @"sex"
  53. #define IMKey_Custom_Suffix_Sign @"sign"
  54. /// 私信推送【0-按照默认规则进行推送 1-不推送】
  55. #define IM_Msg_Push 1
  56. typedef NS_ENUM(NSInteger,ImCallType) {
  57. ImCallType_Audio,
  58. ImCallType_Video,
  59. };
  60. typedef void (^ImStatusBlock)(BOOL isSucc);
  61. typedef void (^ImGroupListBlock)(NSArray *groupList);
  62. typedef void (^ImTransformBlock)(NSString *transformStr);
  63. typedef void (^ImTransformArrayBlock)(NSArray *transformArray);
  64. typedef void (^ImGetUnreadBlock)(int allUnread);
  65. typedef void (^ImGetConversationListBlock)(NSMutableArray *CovList, BOOL isSuccess);
  66. typedef void (^ImRecevNewMsgBlock)(TMessageCellData *receData); //获取新消息
  67. typedef void (^ImSendV2MsgBlock)(BOOL isSuccess, V2TIMMessage*sendMsg, NSString *desc); //发送消息
  68. @interface YBImManager : NSObject
  69. +(instancetype)shareInstance;
  70. #pragma mark - 登录、登出
  71. @property(nonatomic,assign)BOOL isLogin;
  72. -(void)imLogin;
  73. -(void)imLogout;
  74. #pragma mark - 推送相关
  75. @property(nonatomic,assign)uint32_t cer_dev;
  76. @property(nonatomic,assign)uint32_t cer_pro;
  77. @property(nonatomic,strong)NSData *deviceToken;
  78. //-(void)setIMPushConfig;
  79. ////-(void)changeAppActive:(BOOL)isActive;
  80. //
  81. //#pragma mark - 自定义消息公共方法
  82. //-(void)pulicSendMsgWith:(NSDictionary *)msgDic receiver:(NSString *)receiverid complete:(ImStatusBlock)status;
  83. //
  84. ///// 播放、停止响铃
  85. //-(void)playAudioCall;
  86. //-(void)stopAudioCall;
  87. //
  88. ///// 消息提示
  89. //- (void)tryPlayMsgAlertWithSenderid:(NSString *)senderUid;
  90. //
  91. //#pragma mark - 消息处理
  92. //-(void)addNoti;
  93. //
  94. //#pragma mark - 获取最后一条消息
  95. //- (void)getLastDisplayStringWith:(dispatch_group_t)imListGroup finish:(ImTransformArrayBlock)finish;
  96. //
  97. //#pragma mark - 更新腾讯云用户资料
  98. //-(void)updateUserInfoToTxWithParam:(NSDictionary *)param;
  99. //
  100. //#pragma mark - 获取加入的群组
  101. //-(void)getJoinGroupList:(ImGroupListBlock)imGroupList;
  102. //
  103. //#pragma mark - 群消息转换
  104. //-(void)transformInfoWithList:(NSArray *)list finish:(ImTransformBlock)finish;
  105. //
  106. //
  107. //#pragma mark - 清除未读
  108. //-(void)clearUnreadConvId:(NSString *)convid sendNot:(BOOL)send;
  109. //-(void)sendClearNot;
  110. #pragma mark - V2TIM 发送消息
  111. -(void)sendV2ImMsg:(TMessageCellData *)msg andReceiver:(NSString *)receiverID complete:(ImSendV2MsgBlock)sendFinish;
  112. #pragma mark - V2TIM 发送自定义消息
  113. -(void)sendV2CustomMsg:(V2TIMCustomElem *)customMsg andReceiver:(NSString *)receiverID complete:(ImSendV2MsgBlock)sendFinish;
  114. #pragma mark - 消息转换
  115. - (V2TIMMessage *)transIMMsgFromUIMsg:(TMessageCellData *)data;
  116. #pragma mark - V2TIM 收到新消息
  117. -(void)onRecvNewMessage:(V2TIMMessage *)msg complete:(ImRecevNewMsgBlock)newMsg;
  118. #pragma mark - 获取未读消息数
  119. -(void)getAllUnredNumExceptUser:(NSArray *)userList complete:(ImGetUnreadBlock)finish;
  120. #pragma mark - 获取会话列表
  121. -(void)getConversationList:(ImGetConversationListBlock)covBlock;
  122. #pragma mark - 获取所有用户会话列表
  123. -(void)getAllConversationList:(ImGetConversationListBlock)covBlock;
  124. #pragma mark - 清空所有会话的未读消息数。
  125. -(void)clearAllUnreadConv;
  126. #pragma mark - 清除某一个用户未读
  127. -(void)clearUnreadConvId:(NSString *)convid sendNot:(BOOL)send;
  128. #pragma mark - 创建一个占位CellData
  129. -(TConversationCellData *)createEmptyCellDataWithId:(NSString *)convid;
  130. @end