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
e1fad979
Commit
e1fad979
authored
Sep 09, 2020
by
zhangyunjie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
推送
parent
426bf7b2
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
69 additions
and
33 deletions
+69
-33
project.pbxproj
OffcnIMSDKiOS.xcodeproj/project.pbxproj
+1
-1
AppDelegate.m
OffcnIMSDKiOS/AppDelegate.m
+5
-4
AppDelegate+OffcnIMPush.m
...MSDKiOS/ExposedInterface-(外放接口)/AppDelegate+OffcnIMPush.m
+9
-5
OffcnIMModel.h
OffcnIMSDKiOS/ExposedInterface-(外放接口)/OffcnIMModel.h
+25
-1
OffcnIMModel.m
OffcnIMSDKiOS/ExposedInterface-(外放接口)/OffcnIMModel.m
+8
-1
OffcnIMZYJFMDBHandler.h
...nIMSDKiOS/ExposedInterface-(外放接口)/OffcnIMZYJFMDBHandler.h
+2
-2
OffcnIMZYJFMDBHandler.m
...nIMSDKiOS/ExposedInterface-(外放接口)/OffcnIMZYJFMDBHandler.m
+6
-6
OffcnNetworkExecutor.m
...IMSDKiOS/Tools-(工具)/NetworkManager/OffcnNetworkExecutor.m
+13
-13
No files found.
OffcnIMSDKiOS.xcodeproj/project.pbxproj
View file @
e1fad979
...
...
@@ -923,9 +923,9 @@
children
=
(
A9D1B33324FD1308000F4662
/* ZYJQiniuManager */
,
A9661FE824EA80A50024EB54
/* OffcnZYJFMDBHandler */
,
A9661F8724EA7AD10024EB54
/* DSToast */
,
A9661FF624EA80A50024EB54
/* ZYJLibs */
,
A9661F8224EA7AD10024EB54
/* LoadingView */
,
A9661F8724EA7AD10024EB54
/* DSToast */
,
A9661F8A24EA7AD10024EB54
/* NetworkManager */
,
A9661F8F24EA7AD10024EB54
/* Category */
,
A9661FC324EA7AD10024EB54
/* GeneralTool */
,
...
...
OffcnIMSDKiOS/AppDelegate.m
View file @
e1fad979
...
...
@@ -117,6 +117,9 @@
-
(
void
)
application
:(
UIApplication
*
)
application
didReceiveRemoteNotification
:(
NSDictionary
*
)
userInfo
fetchCompletionHandler
:(
void
(
^
)(
UIBackgroundFetchResult
))
completionHandler
{
NSLog
(
@"接收到远程推送通知Background ---- %@"
,
userInfo
);
[
self
didReceiveRemoteNotification
:
userInfo
];
if
([
UIApplication
sharedApplication
].
applicationState
!=
UIApplicationStateActive
)
{
// [self pushNotificationDefaultController];
}
...
...
@@ -125,13 +128,11 @@
}
-
(
void
)
application
:(
UIApplication
*
)
application
didReceiveRemoteNotification
:(
NSDictionary
*
)
userInfo
{
NSLog
(
@"接收到远程推送通知 ---- %@"
,
userInfo
);
NSLog
(
@"接收到远程推送通知 ---- %@"
,
userInfo
);
[
self
didReceiveRemoteNotification
:
userInfo
];
/*
"name" : "YFPushTest",
"action_type" : "1",
"message" : "您的车辆京KKKKKK于2016-4-22 驶入邯郸",
"aps" : {
"alert" : "This is some fancy message.",
...
...
OffcnIMSDKiOS/ExposedInterface-(外放接口)/AppDelegate+OffcnIMPush.m
View file @
e1fad979
//
//
...
...
@@ -11,6 +11,7 @@
#import "ZYJMJExtension.h"
#import "DataSafe.h"
#import "OffcnIMZYJFMDBHandler.h"
#import "OffcnIMSocketManager.h"
@implementation
AppDelegate
(
OffcnIMPush
)
...
...
@@ -47,13 +48,16 @@
-
(
void
)
didReceiveRemoteNotification
:(
NSDictionary
*
)
userInfo
{
NSString
*
revStr
=
@""
;
OffcnIMModel
*
IMModel
=
[
OffcnIMModel
mj_ZYJobjectWithKeyValues
:
revStr
];
OffcnIMPushModel
*
IMModel
=
[
OffcnIMPushModel
mj_ZYJobjectWithKeyValues
:
userInfo
];
//存数据库
OffcnIMBodyModel
*
body
=
IMModel
.
body
;
OffcnIMBodyModel
*
body
=
IMModel
.
message
.
body
;
body
.
isSentSuccess
=
1
;
body
.
bymyself
=
0
;
if
([
body
.
msg_from
isEqualToString
:[
OffcnIMSocketManager
defaultService
].
msg_fromId
])
{
body
.
bymyself
=
1
;
}
else
{
body
.
bymyself
=
0
;
}
body
.
isRead
=
0
;
[[
OffcnIMZYJFMDBHandler
sharedInstance
]
insertChatInfoToFMDBWithModel
:
body
];
[[
OffcnIMZYJFMDBHandler
sharedInstance
]
chatlistCacheInfo
:
body
callback
:
nil
];
...
...
OffcnIMSDKiOS/ExposedInterface-(外放接口)/OffcnIMModel.h
View file @
e1fad979
//
//
...
...
@@ -95,6 +95,13 @@ NS_ASSUME_NONNULL_BEGIN
@property
(
nonatomic
,
strong
)
OffcnIMMsgModel
*
msg_content
;
//消息内容
@property
(
nonatomic
,
assign
)
NSInteger
msg_type
;
//消息类型
@property
(
nonatomic
,
copy
)
NSString
*
send_time
;
//时间
@property
(
nonatomic
,
copy
)
NSString
*
session_id
;
//会话ID
@property
(
nonatomic
,
copy
)
NSString
*
msg_id
;
//消息Id
@property
(
nonatomic
,
copy
)
NSString
*
version
;
@property
(
nonatomic
,
assign
)
NSInteger
msg_seq
;
//消息时序
@property
(
nonatomic
,
assign
)
NSInteger
msg_scope
;
// 区分单聊:1以及群聊:2
@property
(
nonatomic
,
copy
)
NSString
*
msg_from
;
//发送消息的用户id
@property
(
nonatomic
,
copy
)
NSString
*
msg_to
;
//接受消息的用户id
@end
//获取会话历史消息列表Model
...
...
@@ -104,4 +111,21 @@ NS_ASSUME_NONNULL_BEGIN
@property
(
nonatomic
,
strong
)
NSMutableArray
*
msg_list
;
@end
//推送Model
@class
OffcnIMPushApsModel
;
@interface
OffcnIMPushModel
:
NSObject
@property
(
nonatomic
,
strong
)
OffcnIMModel
*
message
;
@property
(
nonatomic
,
strong
)
OffcnIMPushApsModel
*
aps
;
@end
@interface
OffcnIMPushApsModel
:
NSObject
@property
(
nonatomic
,
strong
)
NSDictionary
*
alert
;
@property
(
nonatomic
,
copy
)
NSString
*
badge
;
@property
(
nonatomic
,
copy
)
NSString
*
sound
;
@end
NS_ASSUME_NONNULL_END
OffcnIMSDKiOS/ExposedInterface-(外放接口)/OffcnIMModel.m
View file @
e1fad979
//
//
...
...
@@ -79,3 +79,10 @@
}
@end
@implementation
OffcnIMPushModel
@end
@implementation
OffcnIMPushApsModel
@end
OffcnIMSDKiOS/ExposedInterface-(外放接口)/OffcnIMZYJFMDBHandler.h
View file @
e1fad979
//
//
...
...
@@ -66,7 +66,7 @@ typedef void (^callBackIsSuccess)(BOOL isSuccess);
/// @param messagesBack 结果回调
-
(
void
)
getChatRecordArrayWithFromUser
:(
NSString
*
)
fromUser
toUser
:(
NSString
*
)
toUser
limit
:(
NSString
*
)
limit
startIndex
:(
NSString
*
)
startIndex
callback
:(
getFMDBHistoryMessagesBlock
)
messagesBack
;
//查询聊天列表
//查询聊天列表
(按时间戳升序排序)
-
(
void
)
getChatListArrayCallback
:(
getFMDBHistoryMessagesBlock
)
messagesBack
;
//消息内容
...
...
OffcnIMSDKiOS/ExposedInterface-(外放接口)/OffcnIMZYJFMDBHandler.m
View file @
e1fad979
//
//
...
...
@@ -204,16 +204,16 @@ static OffcnIMZYJFMDBHandler *FMDBHandler;
BOOL
result
=
NO
;
if
(
tmpDataArray
.
count
)
{
NSString
*
sqlStr
=
@"update chatlist set lastmessage = ?,lastSendtime = ?,msg_seq = ?,session_id = ?,tid = ?,msg_id = ?,msg_type = ? where session_id = ?"
;
NSString
*
sqlStr
=
@"update chatlist set
msg_fromId = ?,msg_toId = ?,
lastmessage = ?,lastSendtime = ?,msg_seq = ?,session_id = ?,tid = ?,msg_id = ?,msg_type = ? where session_id = ?"
;
NSString
*
lastmessage
=
[
self
lastMessage
:
chatlistModel
];
result
=
[
db
executeUpdate
:
sqlStr
,
lastmessage
,
chatlistModel
.
send_time
,[
NSNumber
numberWithInteger
:
chatlistModel
.
msg_seq
],
chatlistModel
.
session_id
,
chatlistModel
.
tid
,
chatlistModel
.
msg_id
,[
NSNumber
numberWithInteger
:
chatlistModel
.
msg_type
],
chatlistModel
.
session_id
];
result
=
[
db
executeUpdate
:
sqlStr
,
chatlistModel
.
msg_from
,
chatlistModel
.
msg_to
,
lastmessage
,
chatlistModel
.
send_time
,[
NSNumber
numberWithInteger
:
chatlistModel
.
msg_seq
],
chatlistModel
.
session_id
,
chatlistModel
.
tid
,
chatlistModel
.
msg_id
,[
NSNumber
numberWithInteger
:
chatlistModel
.
msg_type
],
chatlistModel
.
session_id
];
//不存在,插库
}
else
{
NSString
*
sqlStr
=
@"insert into chatlist(msg_
toId,tid,session_id,msg_id,msg_type,lastmessage,lastSendtime,msg_seq)values(
?,?,?,?,?,?,?,?)"
;
NSString
*
sqlStr
=
@"insert into chatlist(msg_
fromId,msg_toId,tid,session_id,msg_id,msg_type,lastmessage,lastSendtime,msg_seq)values(?,
?,?,?,?,?,?,?,?)"
;
NSString
*
lastmessage
=
[
self
lastMessage
:
chatlistModel
];
result
=
[
db
executeUpdate
:
sqlStr
,
chatlistModel
.
msg_to
,
chatlistModel
.
tid
,
chatlistModel
.
session_id
,
chatlistModel
.
msg_id
,[
NSNumber
numberWithInteger
:
chatlistModel
.
msg_type
],
lastmessage
,
chatlistModel
.
send_time
,[
NSNumber
numberWithInteger
:
chatlistModel
.
msg_seq
]];
result
=
[
db
executeUpdate
:
sqlStr
,
chatlistModel
.
msg_
from
,
chatlistModel
.
msg_
to
,
chatlistModel
.
tid
,
chatlistModel
.
session_id
,
chatlistModel
.
msg_id
,[
NSNumber
numberWithInteger
:
chatlistModel
.
msg_type
],
lastmessage
,
chatlistModel
.
send_time
,[
NSNumber
numberWithInteger
:
chatlistModel
.
msg_seq
]];
}
[
rs
close
];
...
...
@@ -414,7 +414,7 @@ static OffcnIMZYJFMDBHandler *FMDBHandler;
getFMDBInstance
();
}
NSString
*
sql
=
[
NSString
stringWithFormat
:
@"SELECT * FROM chatlist order by
msg_seq
asc"
];
NSString
*
sql
=
[
NSString
stringWithFormat
:
@"SELECT * FROM chatlist order by
lastSendtime
asc"
];
[
_database
inDatabase
:
^
(
ZYJZYJFMDatabase
*
db
)
{
ZYJZYJFMResultSet
*
rs
=
[
db
executeQuery
:
sql
];
NSMutableArray
*
tmpArray
=
[
NSMutableArray
array
];
...
...
OffcnIMSDKiOS/Tools-(工具)/NetworkManager/OffcnNetworkExecutor.m
View file @
e1fad979
//
//
...
...
@@ -172,17 +172,17 @@
// {
// "last_msg" = {
// "msg_content" = {
// msg =
"\U6211\U662f\U4e00\U53ea\U5c0f\U9752\U9f99"
;
// msg =
1233
;
// };
// "msg_from" = ce0819db8391f1e7258a71cc9e2c3235;
// "msg_to" = ceb7383519c5b6a1c8579553f01ad9c4;
// "msg_type" = 1;
// "send_time" = "2020-0
8-18 17:48:09
";
// "send_time" = "2020-0
9-09 13:30:41
";
// };
// "session_id" = "a05517f0-ddec-11ea-88a4-4a5555fb6ab4";
// to = jfdfjei0343;
// "session_id" = 37f7344c5b7f94592882951e280d61676386ff86;
// to = ceb7383519c5b6a1c8579553f01ad9c4;
// type = 1;
// "unread_number" = 11;
// },
// }
// );
//}
//获取用户最近会话记录
...
...
@@ -199,8 +199,8 @@
OffcnIMMsgModel
*
MsgModel
=
[[
OffcnIMMsgModel
alloc
]
init
];
OffcnIMBodyModel
*
BodyModel
=
[[
OffcnIMBodyModel
alloc
]
init
];
BodyModel
.
msg_from
=
accid
;
BodyModel
.
msg_to
=
SessionModel
.
to
;
BodyModel
.
msg_from
=
SessionModel
.
last_msg
.
msg_from
;
BodyModel
.
msg_to
=
SessionModel
.
last_msg
.
msg_
to
;
BodyModel
.
session_id
=
SessionModel
.
session_id
;
BodyModel
.
msg_type
=
SessionModel
.
last_msg
.
msg_type
;
BodyModel
.
send_time
=
SessionModel
.
last_msg
.
send_time
;
...
...
@@ -208,10 +208,10 @@
BodyModel
.
msg_id
=
@""
;
BodyModel
.
msg_seq
=
0
;
BodyModel
.
isSentSuccess
=
1
;
if
([
BodyModel
.
msg_to
isEqualToString
:[
OffcnIMSocketManager
defaultService
].
msg_fromId
])
{
BodyModel
.
bymyself
=
0
;
}
else
{
if
([
BodyModel
.
msg_from
isEqualToString
:[
OffcnIMSocketManager
defaultService
].
msg_fromId
])
{
BodyModel
.
bymyself
=
1
;
}
else
{
BodyModel
.
bymyself
=
0
;
}
BodyModel
.
isRead
=
1
;
if
(
BodyModel
.
msg_type
==
1
)
{
...
...
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