Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
O
OffcnIMSDKiOS
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
opensource
OffcnIMSDKiOS
Commits
0187e396
Commit
0187e396
authored
Aug 24, 2020
by
zhangyunjie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
上传改为传路径
parent
46495bfd
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
45 additions
and
17 deletions
+45
-17
OffcnIMSDKiOS.h
OffcnIMSDKiOS/ExposedInterface-(外放接口)/OffcnIMSDKiOS.h
+3
-3
OffcnIMSDKiOS.m
OffcnIMSDKiOS/ExposedInterface-(外放接口)/OffcnIMSDKiOS.m
+3
-3
OffcnUploadManager.h
OffcnIMSDKiOS/ExposedInterface-(外放接口)/OffcnUploadManager.h
+2
-2
OffcnUploadManager.m
OffcnIMSDKiOS/ExposedInterface-(外放接口)/OffcnUploadManager.m
+6
-6
Info.plist
OffcnIMSDKiOS/Info.plist
+2
-0
ViewController.mm
OffcnIMSDKiOS/ViewController.mm
+29
-3
No files found.
OffcnIMSDKiOS/ExposedInterface-(外放接口)/OffcnIMSDKiOS.h
View file @
0187e396
//
//
...
...
@@ -60,8 +60,8 @@ typedef void(^OffcnSDKReachabilityStatusCallBack)(OffcnSDKReachabilityStatus sta
/// @param msg_toID 接收人ID
/// @param msg_type 发送消息类型
/// @param text 文本
/// @param file
Data 图片/音频/视频/文件
/// @param file
Path 图片/音频/视频/文件路径
/// @param finished 结果回调
-
(
void
)
sendMsgWithMsg_fromID
:(
NSString
*
)
msg_fromID
msg_toID
:(
NSString
*
)
msg_toID
msg_type
:(
OffcnSDKMsgType
)
msg_type
text
:(
NSString
*
)
text
file
Data
:(
NSData
*
)
fileData
Finished
:(
void
(
^
)(
BOOL
success
,
id
response
,
NSString
*
errorMessage
))
finished
;
-
(
void
)
sendMsgWithMsg_fromID
:(
NSString
*
)
msg_fromID
msg_toID
:(
NSString
*
)
msg_toID
msg_type
:(
OffcnSDKMsgType
)
msg_type
text
:(
NSString
*
)
text
file
Path
:(
NSString
*
)
filePath
Finished
:(
void
(
^
)(
BOOL
success
,
id
response
,
NSString
*
errorMessage
))
finished
;
@end
OffcnIMSDKiOS/ExposedInterface-(外放接口)/OffcnIMSDKiOS.m
View file @
0187e396
//
//
...
...
@@ -104,7 +104,7 @@ static OffcnIMSDKiOS *liveTelecastSDK;
}
#pragma mark - 操作事件
-
(
void
)
sendMsgWithMsg_fromID
:
(
NSString
*
)
msg_fromID
msg_toID
:
(
NSString
*
)
msg_toID
msg_type
:
(
OffcnSDKMsgType
)
msg_type
text
:
(
NSString
*
)
text
file
Data
:
(
NSData
*
)
fileData
Finished
:
(
void
(
^
)(
BOOL
success
,
id
response
,
NSString
*
errorMessage
))
finished
{
-
(
void
)
sendMsgWithMsg_fromID
:
(
NSString
*
)
msg_fromID
msg_toID
:
(
NSString
*
)
msg_toID
msg_type
:
(
OffcnSDKMsgType
)
msg_type
text
:
(
NSString
*
)
text
file
Path
:
(
NSString
*
)
filePath
Finished
:
(
void
(
^
)(
BOOL
success
,
id
response
,
NSString
*
errorMessage
))
finished
{
//发送消息
if
(
msg_type
==
OffcnSDKMsgTypeText
)
{
...
...
@@ -119,7 +119,7 @@ static OffcnIMSDKiOS *liveTelecastSDK;
finished
(
success
,
nil
,
baseResponse
.
errorMessage
);
}];
}
else
{
[[
OffcnUploadManager
defaultService
]
uploadToQNFile
Data
:
fileData
Finished
:
^
(
BOOL
success
,
id
_Nonnull
response
,
NSString
*
_Nonnull
errorMessage
)
{
[[
OffcnUploadManager
defaultService
]
uploadToQNFile
Path
:
filePath
Finished
:
^
(
BOOL
success
,
id
_Nonnull
response
,
NSString
*
_Nonnull
errorMessage
)
{
if
(
success
)
{
NSString
*
responseStr
=
@""
;
if
(
response
)
{
...
...
OffcnIMSDKiOS/ExposedInterface-(外放接口)/OffcnUploadManager.h
View file @
0187e396
//
//
...
...
@@ -14,7 +14,7 @@ NS_ASSUME_NONNULL_BEGIN
+
(
OffcnUploadManager
*
)
defaultService
;
-
(
void
)
uploadToQNFile
Data
:(
NSData
*
)
fileData
Finished
:(
void
(
^
)(
BOOL
success
,
id
response
,
NSString
*
errorMessage
))
finished
;
-
(
void
)
uploadToQNFile
Path
:(
NSString
*
)
filePath
Finished
:(
void
(
^
)(
BOOL
success
,
id
response
,
NSString
*
errorMessage
))
finished
;
@end
NS_ASSUME_NONNULL_END
OffcnIMSDKiOS/ExposedInterface-(外放接口)/OffcnUploadManager.m
View file @
0187e396
//
//
...
...
@@ -35,18 +35,18 @@ static OffcnUploadManager *uploadManager;
return
self
;
}
-
(
void
)
uploadToQNFile
Data
:
(
NSData
*
)
fileData
Finished
:
(
void
(
^
)(
BOOL
success
,
id
response
,
NSString
*
errorMessage
))
finished
{
-
(
void
)
uploadToQNFile
Path
:
(
NSString
*
)
filePath
Finished
:
(
void
(
^
)(
BOOL
success
,
id
response
,
NSString
*
errorMessage
))
finished
{
__weak
typeof
(
self
)
weakSelf
=
self
;
if
(
self
.
QNToken
)
{
[
self
uploadToQNWithQNToken
:
self
.
QNToken
file
Data
:
fileData
Finished
:^
(
BOOL
success
,
id
response
,
NSString
*
errorMessage
)
{
[
self
uploadToQNWithQNToken
:
self
.
QNToken
file
Path
:
filePath
Finished
:^
(
BOOL
success
,
id
response
,
NSString
*
errorMessage
)
{
finished
(
success
,
response
,
errorMessage
);
}];
}
else
{
[
self
getQNTokenFinished
:
^
(
BOOL
success
,
NSString
*
errorMessage
)
{
if
(
success
)
{
[
weakSelf
uploadToQNWithQNToken
:
weakSelf
.
QNToken
file
Data
:
fileData
Finished
:^
(
BOOL
success
,
id
response
,
NSString
*
errorMessage
)
{
[
weakSelf
uploadToQNWithQNToken
:
weakSelf
.
QNToken
file
Path
:
filePath
Finished
:^
(
BOOL
success
,
id
response
,
NSString
*
errorMessage
)
{
finished
(
success
,
response
,
errorMessage
);
}];
...
...
@@ -72,12 +72,12 @@ static OffcnUploadManager *uploadManager;
}];
}
-
(
void
)
uploadToQNWithQNToken
:
(
NSString
*
)
QNToken
file
Data
:
(
NSData
*
)
fileData
Finished
:
(
void
(
^
)(
BOOL
success
,
id
response
,
NSString
*
errorMessage
))
finished
{
-
(
void
)
uploadToQNWithQNToken
:
(
NSString
*
)
QNToken
file
Path
:
(
NSString
*
)
filePath
Finished
:
(
void
(
^
)(
BOOL
success
,
id
response
,
NSString
*
errorMessage
))
finished
{
QNUploadOption
*
uploadOption
=
[[
QNUploadOption
alloc
]
initWithMime
:
nil
progressHandler
:
^
(
NSString
*
key
,
float
percent
)
{
NSLog
(
@"percent == %.2f"
,
percent
);
}
params
:
nil
checkCrc
:
NO
cancellationSignal
:
nil
];
[
self
.
upManager
put
Data
:
fileData
key
:
nil
token
:
QNToken
complete
:^
(
QNResponseInfo
*
info
,
NSString
*
key
,
NSDictionary
*
resp
)
{
[
self
.
upManager
put
File
:
filePath
key
:
nil
token
:
QNToken
complete
:^
(
QNResponseInfo
*
info
,
NSString
*
key
,
NSDictionary
*
resp
)
{
NSLog
(
@"info ===== %@"
,
info
);
NSLog
(
@"key ===== %@"
,
key
);
NSLog
(
@"resp ===== %@"
,
resp
);
...
...
OffcnIMSDKiOS/Info.plist
View file @
0187e396
...
...
@@ -2,6 +2,8 @@
<
!
D
O
C
TYP
E
plist
PU
B
LI
C
"-//
A
ppl
e
//
D
T
D
PLIST
1
.
0
//
E
N"
"http://www.
a
ppl
e
.
c
om/
D
T
D
s/Prop
e
rtyList-
1
.
0
.
d
t
d
"
>
<
plist
v
e
rsion="
1
.
0
"
>
<
d
i
c
t
>
<
k
e
y
>
NSMicrophoneUsageDescription
<
/k
e
y
>
<
string
>
App
需要您的同意,才能访问麦克风
<
/string
>
<
k
e
y
>
NSPhotoLibraryUsageDescription
<
/k
e
y
>
<
string
>
App
需要您的同意,才能访问相册
<
/string
>
<
k
e
y
>
CFBundleDevelopmentRegion
<
/k
e
y
>
...
...
OffcnIMSDKiOS/ViewController.mm
View file @
0187e396
...
...
@@ -69,7 +69,7 @@
-
(
IBAction
)
sendMeg
:(
UIButton
*
)
sender
{
//发送消息
[[
OffcnIMSDKiOS
defaultService
]
sendMsgWithMsg_fromID
:
self
.
fromId
msg_toID
:
self
.
toId
msg_type
:
OffcnSDKMsgTypeText
text
:
@"你好"
file
Data
:
nil
Finished
:^
(
BOOL
success
,
id
response
,
NSString
*
errorMessage
)
{
[[
OffcnIMSDKiOS
defaultService
]
sendMsgWithMsg_fromID
:
self
.
fromId
msg_toID
:
self
.
toId
msg_type
:
OffcnSDKMsgTypeText
text
:
@"你好"
file
Path
:
nil
Finished
:^
(
BOOL
success
,
id
response
,
NSString
*
errorMessage
)
{
}];
}
...
...
@@ -117,8 +117,8 @@
-
(
IBAction
)
uploadFile
:(
UIButton
*
)
sender
{
//上传
NS
Data
*
imageData
=
UIImageJPEGRepresentation
(
self
.
pickImage
,
0
.
5
)
;
[[
OffcnIMSDKiOS
defaultService
]
sendMsgWithMsg_fromID
:
self
.
fromId
msg_toID
:
self
.
toId
msg_type
:
OffcnSDKMsgTypePicture
text
:
nil
file
Data
:
imageData
Finished
:^
(
BOOL
success
,
id
response
,
NSString
*
errorMessage
)
{
NS
String
*
filePath
=
[
self
getImagePath
:
self
.
pickImage
]
;
[[
OffcnIMSDKiOS
defaultService
]
sendMsgWithMsg_fromID
:
self
.
fromId
msg_toID
:
self
.
toId
msg_type
:
OffcnSDKMsgTypePicture
text
:
nil
file
Path
:
filePath
Finished
:^
(
BOOL
success
,
id
response
,
NSString
*
errorMessage
)
{
}];
}
...
...
@@ -157,6 +157,32 @@
NSLog
(
@"访问相册错误"
);
}
}
//照片获取本地路径转换
-
(
NSString
*
)
getImagePath
:
(
UIImage
*
)
Image
{
NSString
*
filePath
=
nil
;
NSData
*
data
=
nil
;
if
(
UIImagePNGRepresentation
(
Image
)
==
nil
)
{
data
=
UIImageJPEGRepresentation
(
Image
,
1
.
0
);
}
else
{
data
=
UIImagePNGRepresentation
(
Image
);
}
//图片保存的路径
//这里将图片放在沙盒的documents文件夹中
NSString
*
DocumentsPath
=
[
NSHomeDirectory
()
stringByAppendingPathComponent
:
@"Documents"
];
//文件管理器
NSFileManager
*
fileManager
=
[
NSFileManager
defaultManager
];
//把刚刚图片转换的data对象拷贝至沙盒中
[
fileManager
createDirectoryAtPath
:
DocumentsPath
withIntermediateDirectories
:
YES
attributes
:
nil
error
:
nil
];
NSString
*
ImagePath
=
[[
NSString
alloc
]
initWithFormat
:
@"/theFirstImage.png"
];
[
fileManager
createFileAtPath
:[
DocumentsPath
stringByAppendingString
:
ImagePath
]
contents
:
data
attributes
:
nil
];
//得到选择后沙盒中图片的完整路径
filePath
=
[[
NSString
alloc
]
initWithFormat
:
@"%@%@"
,
DocumentsPath
,
ImagePath
];
return
filePath
;
}
//可旋转屏幕
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment