IMAMsg.h 17.9 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424
//
//  IMAMsg.h
//  CNLiveNewIMAManagerKit
//
//  Created by AlexiChen on 16/1/29.
//  Copyright © 2016年 AlexiChen. All rights reserved.
//


typedef NS_ENUM(NSInteger, IMAMSGType) {
    EIMAMSG_Unknown,            // 未知消息类型
    EIMAMSG_Text,               // 文本
    EIMAMSG_Image,              // 图片
    EIMAMSG_File,               // 文件
    EIMAMSG_Sound,              // 语音
    EIMAMSG_Face,               // 表情
    EIMAMSG_Location,           // 定位
    EIMAMSG_Video,              // 视频消息
    EIMAMSG_Custom,             // 自定义
    EIMAMSG_TimeTip,            // 时间提醒标签,不存在于IMSDK缓存的数据库中,业务动态生成
    EIMAMSG_GroupTips,          // 群提醒
    EIMAMSG_GroupSystem,        // 群系统消息
    EIMAMSG_SNSSystem,          // 关系链消息
    EIMAMSG_ProfileSystem,      // 资料变更消息
    EIMAMSG_InputStatus,        // 对方输入状态
    EIMAMSG_SaftyTip,           // 敏感词消息提醒标签,不存在缓存中,退出聊天界面再进入,则不存在了
    
    //zl_订单相关类型
    EIMAMSG_OrderConfirm,       // 核对确认
    EIMAMSG_OrderCnee,          // 收货人信息
    EIMAMSG_OrderStatus,        // 提示语(包含: 订单取消、有误、提交,强制加好友成功,全部禁言成功,解除全部禁言。。。)
    
    EIMAMSG_AiteStatus,         // @ 自定义消息
    EIMAMSG_LivePeopleNumStatus,// 直播聊天人数
#pragma mark - TODO:定义直播预约人数
    EIMAMSG_LiveBookingCount,   //直播预约人数
    EIMAMSG_LiveDisableSendMsg, //PGC直播间禁言消息
    
    EIMAMSG_UGCLivePlayEnd,     //UGC直播结束
    EIMAMSG_UGCLivePlayShare,   //UGC直播分享
    
    EIMAMSG_LivePlayerStatus,   // 直播状态
    
    EIMAMSG_FriendshipVerify,   //好友验证
    EIMAMSG_AddFriend,          //添加好友成功
    EIMAMSG_AgreeApply,         //同意申请
    EIMAMSG_SendAddFriendInvitation, //发送添加对方为好友邀请 (如果是单项好友,对方好友里有自己,则会自动添加成功)
    //特色群消息类型
    EIMAMSG_DissolveGroup,      //投票解散群
    EIMAMSG_Payment     ,       //付款类型(投票)
    EIMAMSG_Receipt     ,       //收款
    EIMAMSG_GroupPaySuccess  ,  //群成员付款成功
    
    EIMAMSG_ShareLink   ,       //分享链接
    EIMAMSG_SendCard    ,       //发送个人名片
    //自定义表情
    EIMAMSG_CustomFace,
    
    EIMAMSG_BlackTip ,          //被拉黑后,发送消息进行提示
    
    EIMAMSG_VoiceWords,         //语音转文字消息,不存在缓存中,退出聊天界面再进                                                入,则不存在了

#if kTestChatAttachment
    EIMAMSG_Multi,              // 富文消息,后期所有聊天消息全部使用富文本显示
#endif

    EIMAMSG_SendCurrentlocation,    //发送当前位置
//    EIMAMSG_Sharelocation,         //发起共享位置
//    EIMAMSG_Currentlocation,         //共享位置:发送当前位置
//    EIMAMSG_SharelocationEndTip,     //共享位置结束后发送消息进行提示
    
#pragma mark - 音视频
    EIMAMSG_SenderInvitationReceiver,               //发起者要请接收者进入房间
    EIMAMSG_OutRoom,                                //退出房间
    EIMAMSG_SwitchAudio,                            //切换音频
    EIMAMSG_ReceiverBusy,                           //接收者繁忙
    EIMAMSG_ReceiverOutRoom,                        //接收方退出房间
    
#pragma mark 电商订单相关
    EIMAMSG_ReceiveE_BusinessOrder,                 //接收到电商订单消息
    EIMAMSG_E_BusinessOrderPaySuceess,              //电商订单支付成功消息提醒
#pragma mark 分享子群组
    EIMAMSG_ShareSubGroup,                          //分享子群组
#pragma mark 分享电商商品
    EIMAMSG_ShareGoods,                             //分享电商商品
#pragma mark 分享礼物相关
    EIMAMSG_ShareGift ,                             //分享礼物
    EIMAMSG_SendGiftSuccess  ,                      //送礼成功
    EIMAMSG_ReceviedGiftSuccess ,                  //收礼成功
#pragma mark 转余额相关消息
    EIMAMSG_TransferBalance,                       //转余额
    EIMAMSG_TransferExpired,                       //转余额过期无人领取消息
    
#pragma mark 话题新消息提醒
    EIMAMSG_TopicTip  ,                            //话题提醒
#pragma mark 特群有新的直播
    EIMAMSG_NewLiveVideo ,             //特群有新的直播
#pragma mark 互助话题消息相关
    EIMAMSG_MutualTopicSysMsg     ,    //互助话题系统通知
    EIMAMSG_MutualTopicCommentMsg ,    //互助话题 评论/回复
    EIMAMSG_MutualTopicAuditMsg   ,    //互助话题审核提醒
#pragma mark 亲情群相关
    EIMAMSG_FamilyHealthyStep     ,    //健康步数
    EIMAMSG_HaveCoupon            ,    //有代领优惠券
#pragma mark 电商原生商品详情,电商原生订单详情
    EIMAMSG_ShopGoodsInfo         ,    //电商原生商品详情
    EIMAMSG_ShopOrderDetail       ,    //电商原生订单详情
#pragma mark 商家版消息类型
    EIMAMSG_OrederPaySuccess      ,    //订单支付成功
    EIMAMSG_OrederRepast          ,    //餐厅收款成功 (自己构造 服务器和电商订单一致用的3001)
    EIMAMSG_OrederRepastReceipt   ,    //餐厅核销订单成功
    EIMAMSG_OrederApplyForRefund  ,    //申请退款
    EIMAMSG_OrederQrcodeReceived  ,    //二维码收款
    EIMAMSG_OrederReminder        ,    //推单
};


//自定义消息类型
typedef NS_ENUM(NSUInteger, CustomMsgType) {
    CustomMsgTypeConfirm                = 1001,         //核对订单
    CustomMsgTypeCnee                   = 1002,         //收货人信息(弃用)
    CustomMsgTypeOrderStatus            = 1003,         //提示语(包含: 取消、有误、提交,强制加好友成功,禁言,取消禁言 。。。。。)
    CustomMsgTypeFriendshipVerify       = 1004,         //好友验证
    CustomMsgTypeAddFriend              = 1005,         //添加好友请求(同意)
    CustomMsgTypeSendAddFriendInvitation= 1012,         //发送添加对方为好友邀请 (如果是单项好友,对方好友里有自己,则会自动添加成功)
    
    CustomMsgTypeRefreshFriendCircle    = 1006,         //刷新朋友圈
    CustomMsgTypeAddFriendSucc          = 1007,         //添加好友成功
    CustomMsgTypeFriendSendSucc         = 2001,         // 朋友圈上传发布成功
    CustomMsgTypeAite                   = 1008,         //@

    
    CustomMsgTypeWithdrawMessage        = 1009,         //撤回消息
    
    CustomMsgTypeSendCard               = 1011,         //发送名片
    
    CustomMsgTypeTransferBalance        = 1013,         //转余额
    CustomMsgTypeTransferExpired        = 1014,         //转余额过期,无人领取
    
    CustomMsgTypeReceiveE_BusinessOrder = 1021,         //接收到电商订单消息(弃用)
    CustomMsgTypeE_BusinessOrderPaySuceess = 1022,      //电商订单支付成功消息提醒
    
    CustomMsgTypeShareGoods             = 1030,         //分享电商商品
    
    CustomMsgTypeShopGoodsInfo          = 11005,        //电商原生商品详情
    CustomMsgTypeShopOrderDetail        = 11006,        //电商原生订单详情
    
    CustomMsgTypeDeleteGroupMember      = 2100,         //有群成员退出
    
    CustomMsgTypeShareSubGroup          = 2200,         //分享子群
    
#pragma mark 智能音响
    CustomMsgTypeBind                   = 2101,        //绑定
    CustomMsgTypeUnbind                 = 2102,        //解绑
    CustomMsgTypeDeleteDevice           = 2103,        //删除设备
#pragma mark 话题提醒
    CustomMsgTypeTopicTip              =  2201,        //话题提醒
#pragma mark 有新直播消息通知
    CustomMsgTypeNewLiveVideo           = 2202,        //特群有新的直播
#pragma mark 互助话题消息相关
    CustomMsgTypeMutualTopic_SysMsg        = 2203,    //互助话题系统通知
    CustomMsgTypeMutualTopic_CommentMsg    = 2204,        //互助话题 评论/回复
    CustomMsgTypeMutualTopic_AuditMsg      = 2205,      //互助话题审核提醒
#pragma mark 领头雁报名成功
    CustomMsgTypeLtyRegistrationSuccess    = 2210,      //领头雁报名成功
#pragma mark 特色群相关消息类型
    CustomMsgTypeDissolveGroup          = 3001,         //C端为解散群,B端为用户订单支付成功
    CustomMsgTypePayment                = 3002,         //C端为付款类型(投票),B端为餐厅收款成功消息
    CustomMsgTypeReceipt                = 3003,         //C端为收款消息,B端为餐厅核销消息
    CustomMsgTypeGroupPaySuccess        = 3004,         //群成员付款成功
    
#pragma mark 情亲群相关消息
    CustomMsgTypeFamilyHealthyStep      = 3006,         //健康步数
    CustomMsgTypeHaveCoupon             = 3007,         //有代领优惠券
    


#pragma mark 直播聊天室相关消息通知
    CustomMsgTypeLiveOneLineCount       = 4001,         //聊天室在线人数通知
    CustomMsgTypeLiveStatus             = 4002,         //聊天室的直播视频状态消息类型
#pragma mark - TODO: 添加预约人数通知
    CustomMsgTypeLiveBookingCount       = 4003,         //直播预约人数
    CustomMsgTypeLiveDisableSendMsg     = 4004,         //PGC直播间禁言消息
    
    CustomMsgTypeUGCLivePlayShare       = 4005,         //UGC直播分享
    CustomMsgTypeUGCLivePlayEnd         = 4006,         //UGC直播结束
    CustomMsgTypeScanCodePay            = 5001,         //扫码支付消息
    CustomMsgTypeShareLink              = 6001,        //分享链接
    
    CustomMsgTypeCustomFace             = 7000,        //自定义表情

    CustomMsgTypeBlackTip               = 6002,        //被拉黑后,发送消息进行提示
    
    CustomMsgTypeBlackStatusChange      = 5003,        //添加或者移除黑名单,系统通知

    CustomMsgTypeSendCurrentLocation    = 8000,         // 发送当前位置
    
//    CustomMsgTypeInitiatingSharedLocation      = 8001,        //发起位置共享
//    CustomMsgTypeCurrentSharedLocation      = 8002,        //共享位置:发送当前位置
//    CustomMsgTypeSharedLocationEndTip   = 8003,//共享位置结束后发送消息进行提示


    
#pragma mark - 音视频
    CustomMsgTypeSenderInvitationReceiver   = 9001,      //发送方向接收方发起音视频邀请
    CustomMsgTypeSendOrReceiverOutRoom      = 9002,      //退出=拒绝(发送方倒计时结束,接收方倒计时结束,双方有一人退出房间)
    CustomMsgTypeSendOrReceiverSwitchAudio  = 9003,      //切换为音频(发送方,接收方)
    CustomMsgTypeReceiverBusy               = 9004,      //接收者繁忙
    CustomMsgTypeReceiverOutRoom            = 9005,      //接收方发送退出
    
#pragma mark 送礼相关
    CustomMsgTypeShareGift                  = 11001,      //分享礼物
    CustomMsgTypeSendGiftSuccess            = 11002,      //对方填写送礼收货地址成功
    CustomMsgTypeReceiveGiftSuccess         = 11003,      //自己填写收礼地址成功
    CustomMsgTypeUpdateUnpayFreightGiftOrderNum  = 11004, //更新未支付运费的礼物订单数
#pragma mark 群主收的邀请券
    CustomMsgTypeFamilyGroupCoupon        = 3005,         // 发送当前位置
    
#pragma mark 商家版相关消息
    CustomMsgTypeApplyForRefund         = 3111,         //申请退款消息
    CustomMsgTypeReminder               = 3222,         //催单
};

/**
 *  消息状态
 */
typedef NS_ENUM(NSInteger, IMAMsgStatus)
{
    EIMAMsg_Init = -1,                              // 初始化, 为兼容TIMMessageStatus,从-1开始,创建的消息
    EIMAMsg_WillSending,                            // 即将发送,加入到IMAConversation的_msgList,但未发送,如发送语音,可以用于先在界面上显示,
    EIMAMsg_Sending = TIM_MSG_STATUS_SENDING,       // 消息发送中
    EIMAMsg_SendSucc = TIM_MSG_STATUS_SEND_SUCC,    // 消息发送成功
    EIMAMsg_SendFail = TIM_MSG_STATUS_SEND_FAIL,    // 消息发送失败
//    EIMAMsg_Deleted = TIM_MSG_STATUS_HAS_DELETED,   // 消息被删除 已经废除,以前删除消息是仅仅把状态置为delete,现在是直接删除存储
};
//语音转换
typedef NS_ENUM(NSInteger, CNVoiceToWordsStatus){
    CNVoiceToWordsStatusBegin = 0,       //语音转文字开始
    CNVoiceToWordsStatusTransforming = 1,//语音转文字中
    CNVoiceToWordsStatusFinish = 2,      //语音转文字成功
    CNVoiceToWordsStatusFail = 3,        //语音转文字失败
    CNVoiceToWordsStatusCancel = 4,      //语音转文字取消
};
@interface IMAMsg : TIMCodingModel
{
@protected
    TIMMessage      *_msg;
    
@protected
    IMAMSGType      _type;
    
    NSInteger       _status;
    
@protected
    // 附加参数,因IMSDK底层有保护机制,从底层获取到的信息,每次都会copy一份
    // 使用此参数来优化界面更新
    NSMutableDictionary *_affixParams;
    
}

/// 消息类型
@property (nonatomic, readonly) IMAMSGType type;

/// IM 原始消息
@property (nonatomic, readonly) TIMMessage *msg;

/// 消息状态
@property (nonatomic, readonly) NSInteger status;

/// 是否正在播放语音
@property (nonatomic, assign)   BOOL isPlayingSuond;

/// 图片,视频消息发送进度,供外部监听做 UI变化
@property (nonatomic, assign) uint32_t msgProgress;

/// 达人或陌生人用户
@property (nonatomic, strong) IMAUser *stranger;

/// 消息时间
@property (nonatomic, copy) NSString *msgTime;

/// 会话列表最后一条消息展示的 内容
@property (nonatomic, strong) NSAttributedString *attributeMsgTip;

/** -------语音转文字时用的的一些属性--------*/

@property (nonatomic, assign) BOOL isVoiceToWords;                     //是语音转文字
@property (nonatomic, strong) IMAMsg *voiceMsg;                        //被转成文字的语音消息
@property (nonatomic, copy) NSString *voiceText;                       // 语音文字
@property (nonatomic, assign) CNVoiceToWordsStatus vioceToWordStatus;  //语音转文字状态
@property (nonatomic, copy) NSString *vioceToWordErrorMsg;             // 语音文字


/// 根据 TIMMessage 生成 IMAMsg 对象
/// @param msg 腾讯IM 原始消息
/// @param type 消息类型
- (instancetype)initWith:(TIMMessage *)msg type:(IMAMSGType)type;

/// 根据 TIMMessage 生成 IMAMsg 对象
/// @param msg 腾讯IM 原始消息
+ (instancetype)msgWith:(TIMMessage *)msg;


/// 根据文字生成普通文本消息
/// @param text 文本
+ (instancetype)msgWithText:(NSString *)text;

/// 根据图片生成图片消息
/// @param image 要发送的图片
/// @param origal 是否是原图
/// @param conversationId 会话id
+ (instancetype)msgWithImage:(UIImage *)image isOrignal:(BOOL)origal conversationId:(NSString *)conversationId;

/// 图片发送失败,重新发送图片消息
/// @param msg 消息
/// @param conversationId 会话id
+ (instancetype)msgWithFailMsg:(IMAMsg *)msg conversationId:(NSString *)conversationId;

/// 创建视频消息
/// @param videoPath 视频本地地址
/// @param conversationId 会话id
+ (instancetype)msgWithVideoPath:(NSString *)videoPath conversationId:(NSString *)conversationId;

/// 根据时间生成一个时间提示消息,这个消息是自定义消息
/// @param timetip 时间
+ (instancetype)msgWithDate:(NSDate *)timetip;

/// 根据文件路径生成一条文件消息
/// @param filePath 本地文件路径
+ (instancetype)msgWithFilePath:(NSURL *)filePath;

/// 根据音频路径生成一条语音消息
/// @param filePath 录音的语音本地地址
/// @param dur 语音时长
/// @param msg 创建一个语音TIMMessage
+ (instancetype)msgWithSound:(NSString *)filePath duration:(NSInteger)dur message:(TIMMessage *)msg;

/// 创建一个空的语音消息
+ (instancetype)msgWithEmptySound;

/// 生成一个自定义消息
/// @param command 自定义消息的type值
+ (instancetype)msgWithCustom:(NSInteger)command;

/// 生成一个自定义消息
/// @param command 自定义消息的type值
/// @param param 自定义消息包含的数据参数
+ (instancetype)msgWithCustom:(NSInteger)command param:(NSString *)param;

/// 生成一条自定义消息
/// @param dic 自定义消息的数据
/// @param cusdDesc 通知栏显示的文本
/// @param type 消息类型
+ (instancetype)msgWithCustomDic:(NSDictionary *)dic desc:(NSString *)cusdDesc type:(IMAMSGType)type;

/// 音视频自定义消息
/// @param dic 消息数据
/// @param cusdDesc 通知栏显示的文本
/// @param type 消息类型
+ (instancetype)msgWithAudioOrVedioCustomDic:(NSDictionary *)dic desc:(NSString *)cusdDesc type:(IMAMSGType)type;

/// 消息提示
- (NSString *)messageTip;

/// 改变消息状态
/// @param status 参考 IMAMsgStatus
/// @param need 是否需要刷新
- (void)changeTo:(IMAMsgStatus)status needRefresh:(BOOL)need;

/// 删除消息
- (void)remove;

/// 获取发送消息的人
- (IMAUser *)getSender;

/// 更新消息
/// @param msg 消息体
- (void)updateMsg:(TIMMessage *)msg;

/// 是否为我发的消息
- (BOOL)isMineMsg;

/// 是否是单聊消息
- (BOOL)isC2CMsg;

/// 是否是群聊消息
- (BOOL)isGroupMsg;

/// 是否是系统消息
- (BOOL)isSystemMsg;

/// 消息是否是   非 时间,提醒 的消息,用于过滤会话列表最后一条消息
- (BOOL)isVailedType;

/// 是否为撤回消息
- (BOOL)isWithdrawMsg;

///语音消息是否已读
- (BOOL)isVioceReaded;

/// 是否包含多个文本
- (BOOL)isMultiMsg;



// 外部不调用,只限于CNLiveNewIMAManagerKit文件目录下代码调用
// affix param method

- (void)addString:(NSString *)aValue forKey:(id<NSCopying>)aKey;

- (void)addInteger:(NSInteger)aValue forKey:(id<NSCopying>)aKey;

- (void)addCGFloat:(CGFloat)aValue forKey:(id<NSCopying>)aKey;

- (void)addBOOL:(BOOL)aValue forKey:(id<NSCopying>)aKey;

- (NSString *)stringForKey:(id<NSCopying>)key;
- (NSInteger)integerForKey:(id<NSCopying>)key;
- (BOOL)boolForKey:(id<NSCopying>)key;
- (CGFloat)floatForKey:(id<NSCopying>)key;

@end