Commit 4e70cf5246b845cd3e6ee9dbf50606273d5af372

Authored by 王军波
1 parent e7f548f1

更新

CNLiveChatSDKDemo/CNLiveChatSDKDemo/AppDelegate.m
@@ -31,7 +31,7 @@ @@ -31,7 +31,7 @@
31 // } error:^(CNLiveChatConnectErrorCode errors) { 31 // } error:^(CNLiveChatConnectErrorCode errors) {
32 // NSLog(@"失败"); 32 // NSLog(@"失败");
33 // }]; 33 // }];
34 - 34 +
35 35
36 36
37 // loginServer 以用户信息登陆,不要和 connectServer 连接服务器方法一起调用,作用相同,只是一个有用户信息,一个没有相当于游客; 37 // loginServer 以用户信息登陆,不要和 connectServer 连接服务器方法一起调用,作用相同,只是一个有用户信息,一个没有相当于游客;
发布版SDK/CNLiveChatManager.framework/CNLiveChatManager
No preview for this file type
发布版SDK/CNLiveChatManager.framework/Headers/CNLiveChatManager.h
@@ -10,6 +10,7 @@ @@ -10,6 +10,7 @@
10 #import "CNLiveChatUserInfo.h" 10 #import "CNLiveChatUserInfo.h"
11 #import "CNLiveChatStatusDefine.h" 11 #import "CNLiveChatStatusDefine.h"
12 #import "CNLiveChatMessage.h" 12 #import "CNLiveChatMessage.h"
  13 +#import "CNliveChatImageMessage.h"
13 14
14 @protocol CNLiveChatManagerDelegate <NSObject> 15 @protocol CNLiveChatManagerDelegate <NSObject>
15 16
@@ -45,7 +46,7 @@ @@ -45,7 +46,7 @@
45 46
46 @param message 消息实体类型对象(包括消息内容,消息ID,会话类型,目标ID,发送者的用户信息) 47 @param message 消息实体类型对象(包括消息内容,消息ID,会话类型,目标ID,发送者的用户信息)
47 */ 48 */
48 -- (void)onReceived:(CNLiveChatMessage *)message; 49 +- (void)onReceived:(id)message;
49 50
50 51
51 /** 52 /**
@@ -107,7 +108,7 @@ @@ -107,7 +108,7 @@
107 108
108 109
109 /** 110 /**
110 - 初始化SDK方法 111 + 初始化SDK方法(同上,区别:可以选择测试环境/上线环境)
111 112
112 @param appKey 从视讯云平台获取到的appKey 113 @param appKey 从视讯云平台获取到的appKey
113 @param appId 从视讯云平台获取到的appId 114 @param appId 从视讯云平台获取到的appId
@@ -199,22 +200,41 @@ @@ -199,22 +200,41 @@
199 200
200 201
201 /** 202 /**
202 - 发送消息 203 + 发送文本或语音消息
203 204
204 - @param message 消息内容 205 + @param message 消息内容(文本消息 CNLiveChatMessage / 语音消息 CNLiveChatVoiceMessage)
205 @param type 会话类型(私聊 / 聊天室) 206 @param type 会话类型(私聊 / 聊天室)
206 @param targetId 会话目标ID(私聊:用户ID / 聊天室:聊天室ID) 207 @param targetId 会话目标ID(私聊:用户ID / 聊天室:聊天室ID)
207 @param successBlock 发送消息成功的回调,消息实体类型对象(包括消息内容,消息ID,会话类型,目标ID,发送者的用户信息) 208 @param successBlock 发送消息成功的回调,消息实体类型对象(包括消息内容,消息ID,会话类型,目标ID,发送者的用户信息)
208 @param errorBlock 发送消息失败的回调,返回错误码,消息ID,目标ID 209 @param errorBlock 发送消息失败的回调,返回错误码,消息ID,目标ID
209 */ 210 */
210 -- (void)sendMessage:(NSString *)message 211 +- (void)sendMessage:(id)message
211 type:(CNLiveConversationType)type 212 type:(CNLiveConversationType)type
212 targetId:(NSString *)targetId 213 targetId:(NSString *)targetId
213 - success:(void (^)(CNLiveChatMessage *message))successBlock 214 + success:(void (^)(id message))successBlock
214 error:(void (^)(CNLiveChatErrorCode errors, NSString *messageId, NSString *targetId))errorBlock; 215 error:(void (^)(CNLiveChatErrorCode errors, NSString *messageId, NSString *targetId))errorBlock;
215 216
216 217
217 /** 218 /**
  219 + 发送图片消息
  220 +
  221 + @param type 会话类型(私聊 / 聊天室)
  222 + @param targetId 会话目标ID(私聊:用户ID / 聊天室:聊天室ID)
  223 + @param content 消息内容(图片类型 CNliveChatImageMessage)
  224 + @param progressBlock 消息发送进度更新的回调
  225 + [progress:当前的发送进度, 0 <= progress <= 100, messageId:消息的ID]
  226 + @param successBlock 消息发送成功的回调
  227 + @param errorBlock 消息发送失败的回调
  228 + */
  229 +- (void)sendMediaMessage:(CNLiveConversationType)type
  230 + targetId:(NSString *)targetId
  231 + content:(CNliveChatImageMessage *)content
  232 + progress:(void (^)(int progress, NSString * messageId))progressBlock
  233 + success:(void (^)(CNliveChatImageMessage * message))successBlock
  234 + error:(void (^)(CNLiveChatErrorCode errorCode, NSString * messageId))errorBlock;
  235 +
  236 +
  237 +/**
218 获取当前SDK的连接状态 238 获取当前SDK的连接状态
219 239
220 @return 当前SDK的连接状态 240 @return 当前SDK的连接状态
@@ -223,13 +243,14 @@ @@ -223,13 +243,14 @@
223 243
224 244
225 /** 245 /**
226 - 获取某个会话中指定数量的最新消息 246 + 获取某个会话中指定数量的最新消息(私聊有效)
227 247
228 - @param conversationType 会话类型(私聊 / 聊天室)  
229 - @param targetId 会话目标ID(私聊:用户ID / 聊天室:聊天室ID) 248 + @param conversationType 会话类型(私聊)
  249 + @param targetId 会话目标ID(私聊:用户ID)
230 @param count 所要获取的消息数量 250 @param count 所要获取的消息数量
231 251
232 - @return 消息数组(CNLiveChatMessage类型) 252 + @return 消息数组
  253 + (包括 CNLiveChatMessage文本类型 / CNliveChatImageMessage图片类型 / CNLiveChatVoiceMessage语音类型)
233 @discussion 254 @discussion
234 此方法会获取该会话中指定数量的最新消息实体,返回的消息实体按照时间从新到旧排列。 255 此方法会获取该会话中指定数量的最新消息实体,返回的消息实体按照时间从新到旧排列。
235 如果会话中的消息数量小于参数count的值,会将该会话中的所有消息返回。 256 如果会话中的消息数量小于参数count的值,会将该会话中的所有消息返回。
发布版SDK/CNLiveChatManager.framework/Headers/CNLiveChatVoiceMessage.h 0 → 100644
  1 +//
  2 +// CNLiveChatVoiceMessage.h
  3 +// CNLiveChatManagerSDKDemo
  4 +//
  5 +// Created by cnliveJunBo on 17/7/12.
  6 +// Copyright © 2017年 cnlive. All rights reserved.
  7 +//
  8 +
  9 +#import <Foundation/Foundation.h>
  10 +#import "CNLiveChatStatusDefine.h"
  11 +#import "CNLiveChatUserInfo.h"
  12 +
  13 +@interface CNLiveChatVoiceMessage : NSObject
  14 +
  15 +/*!
  16 + wav格式的音频数据
  17 + */
  18 +@property(nonatomic, strong) NSData *wavAudioData;
  19 +
  20 +/*!
  21 + 语音消息的时长
  22 + */
  23 +@property(nonatomic, assign) long duration;
  24 +
  25 +/*!
  26 + 语音消息的附加信息
  27 + */
  28 +@property(nonatomic, strong) NSString *extra;
  29 +
  30 +// * 基础属性 *
  31 +/**
  32 + 会话类型(私聊 / 聊天室)
  33 + */
  34 +@property (nonatomic, assign) CNLiveConversationType conversationType;
  35 +
  36 +/**
  37 + 目标ID(消息来自聊天室的ID / 接收者ID)
  38 + */
  39 +@property (nonatomic, copy) NSString *targetId;
  40 +
  41 +/**
  42 + 消息ID(本地存储的消息的唯一值(数据库索引唯一值))
  43 + */
  44 +@property (nonatomic, copy) NSString *messageId;
  45 +
  46 +/**
  47 + 发送者的用户信息(userId, name, portraitUri)
  48 + */
  49 +@property (nonatomic, strong) CNLiveChatUserInfo *userInfo;
  50 +
  51 +/*!
  52 + 初始化语音消息
  53 +
  54 + @param audioData wav格式的音频数据
  55 + @param duration 语音消息的时长(单位:秒)
  56 + @return 语音消息对象
  57 +
  58 + @discussion
  59 + 如果您不是使用IMKit中的录音功能,则在初始化语音消息的时候,需要确保以下几点。
  60 + 1. audioData必须是单声道的wav格式音频数据;
  61 + 2. audioData的采样率必须是8000Hz,采样位数(精度)必须为16位。
  62 +
  63 + 您可以参考的录音参数:
  64 + NSDictionary *settings = @{AVFormatIDKey: @(kAudioFormatLinearPCM),
  65 + AVSampleRateKey: @8000.00f,
  66 + AVNumberOfChannelsKey: @1,
  67 + AVLinearPCMBitDepthKey: @16,
  68 + AVLinearPCMIsNonInterleaved: @NO,
  69 + AVLinearPCMIsFloatKey: @NO,
  70 + AVLinearPC'MIsBigEndianKey: @NO};
  71 + */
  72 ++ (instancetype)messageWithAudio:(NSData *)audioData duration:(long)duration;
  73 +
  74 +@end
发布版SDK/CNLiveChatManager.framework/Headers/CNliveChatImageMessage.h 0 → 100644
  1 +//
  2 +// CNliveChatImageMessage.h
  3 +// CNLiveChatManager
  4 +//
  5 +// Created by cnliveJunBo on 17/7/11.
  6 +// Copyright © 2017年 cnlive. All rights reserved.
  7 +//
  8 +
  9 +#import <Foundation/Foundation.h>
  10 +#import <UIKit/UIKit.h>
  11 +#import "CNLiveChatStatusDefine.h"
  12 +#import "CNLiveChatUserInfo.h"
  13 +
  14 +/*!
  15 + 图片消息类
  16 +
  17 + @discussion 图片消息类
  18 + */
  19 +@interface CNliveChatImageMessage : NSObject
  20 +
  21 +/*!
  22 + 图片消息的URL地址
  23 +
  24 + @discussion 发送方此字段为图片的本地路径,接收方此字段为网络URL地址。
  25 + */
  26 +@property(nonatomic, strong) NSString *imageUrl;
  27 +
  28 +/*!
  29 + 图片消息的缩略图
  30 + */
  31 +@property(nonatomic, strong) UIImage *thumbnailImage;
  32 +
  33 +/*!
  34 + 是否发送原图
  35 +
  36 + @discussion 在发送图片的时候,是否发送原图,默认值为NO。
  37 + */
  38 +@property(nonatomic, getter=isFull) BOOL full;
  39 +
  40 +/*!
  41 + 图片消息的附加信息
  42 + */
  43 +@property(nonatomic, strong) NSString *extra;
  44 +
  45 +/*!
  46 + 图片消息的原始图片信息
  47 + */
  48 +@property(nonatomic, strong) UIImage *originalImage;
  49 +
  50 +// * 基础属性 *
  51 +/**
  52 + 会话类型(私聊 / 聊天室)
  53 + */
  54 +@property (nonatomic, assign) CNLiveConversationType conversationType;
  55 +
  56 +/**
  57 + 目标ID(消息来自聊天室的ID / 接收者ID)
  58 + */
  59 +@property (nonatomic, copy) NSString *targetId;
  60 +
  61 +/**
  62 + 消息ID(本地存储的消息的唯一值(数据库索引唯一值))
  63 + */
  64 +@property (nonatomic, copy) NSString *messageId;
  65 +
  66 +/**
  67 + 发送者的用户信息(userId, name, portraitUri)
  68 + */
  69 +@property (nonatomic, strong) CNLiveChatUserInfo *userInfo;
  70 +
  71 +/*!
  72 + 初始化图片消息
  73 +
  74 + @param image 原始图片
  75 + @return 图片消息对象
  76 + */
  77 +// 发: originalImage thumbnailImage 有值 imageUrl 无值
  78 +// 收: thumbnailImage imageUrl 有值 originalImage 无值
  79 ++ (instancetype)messageWithImage:(UIImage *)image;
  80 +
  81 +/*!
  82 + 初始化图片消息
  83 +
  84 + @param imageURI 图片的本地路径
  85 + @return 图片消息对象
  86 + */
  87 +// 发(本地路径): originalImage thumbnailImage imageUrl 有值
  88 +// 收: originalImage 无值 thumbnailImage imageUrl 有值
  89 ++ (instancetype)messageWithImageURI:(NSString *)imageURI;
  90 +
  91 +@end
发布版SDK/CNLiveMsgTools.framework/CNLiveMsgTools
No preview for this file type
发布版SDK/CNLiveMsgTools.framework/Headers/CNLiveMsgManager.h
@@ -12,6 +12,7 @@ @@ -12,6 +12,7 @@
12 12
13 @property (nonatomic, readonly, assign) BOOL isTestEnvironment; 13 @property (nonatomic, readonly, assign) BOOL isTestEnvironment;
14 14
  15 +
15 + (NSString *)getCNLiveMsgVersion; 16 + (NSString *)getCNLiveMsgVersion;
16 17
17 18
@@ -25,6 +26,12 @@ @@ -25,6 +26,12 @@
25 - (NSDictionary *)getToolsInfo; 26 - (NSDictionary *)getToolsInfo;
26 27
27 28
  29 +- (NSDictionary *)messageWithImage:(id)image;
  30 +
  31 +
  32 +- (NSDictionary *)messageWithVoice:(NSData *)voiceData duration:(long)duration;
  33 +
  34 +
28 - (void)initCNLiveMsgToolsWithAppKey:(NSString *)appKey appId:(NSString *)appId; 35 - (void)initCNLiveMsgToolsWithAppKey:(NSString *)appKey appId:(NSString *)appId;
29 36
30 37
@@ -72,13 +79,23 @@ @@ -72,13 +79,23 @@
72 error:(void (^)(NSInteger errors, NSString *targetId))errorBlock; 79 error:(void (^)(NSInteger errors, NSString *targetId))errorBlock;
73 80
74 81
75 -- (void)sendCarrier:(NSString *)carrier 82 +- (void)sendCarrier:(NSDictionary *)carrier
76 type:(NSInteger)type 83 type:(NSInteger)type
77 targetId:(NSString *)targetId 84 targetId:(NSString *)targetId
78 success:(void (^)(NSString *carrier, NSString *messageId, NSString *targetId, NSInteger type, NSString *infoId, NSString *infoName, NSString *infoUrl, long long goTime, long long comeTime))successBlock 85 success:(void (^)(NSString *carrier, NSString *messageId, NSString *targetId, NSInteger type, NSString *infoId, NSString *infoName, NSString *infoUrl, long long goTime, long long comeTime))successBlock
79 error:(void (^)(NSInteger errors, NSString *messageId, NSString *targetId))errorBlock; 86 error:(void (^)(NSInteger errors, NSString *messageId, NSString *targetId))errorBlock;
80 87
81 88
  89 +- (void)sendMedia:(NSDictionary *)media type:(NSInteger)type
  90 + targetId:(NSString *)targetId
  91 + pushContent:(NSString *)pushContent
  92 + pushData:(NSString *)pushData
  93 + progress:(void (^)(int progress, NSString *messageId))progressBlock
  94 + success:(void (^)(NSString *messageId, NSString *targetId, NSInteger type, NSString *infoId, NSString *infoName, NSString *infoUrl))successBlock
  95 + error:(void (^)(NSInteger errorCode, NSString *messageId))errorBlock
  96 + cancel:(void (^)(NSString * messageId))cancelBlock;
  97 +
  98 +
82 - (NSInteger)getOnLineStatus; 99 - (NSInteger)getOnLineStatus;
83 100
84 101