Commit e1fad979 by zhangyunjie

推送

parent 426bf7b2
......@@ -923,9 +923,9 @@
children = (
A9D1B33324FD1308000F4662 /* ZYJQiniuManager */,
A9661FE824EA80A50024EB54 /* OffcnZYJFMDBHandler */,
A9661F8724EA7AD10024EB54 /* DSToast */,
A9661FF624EA80A50024EB54 /* ZYJLibs */,
A9661F8224EA7AD10024EB54 /* LoadingView */,
A9661F8724EA7AD10024EB54 /* DSToast */,
A9661F8A24EA7AD10024EB54 /* NetworkManager */,
A9661F8F24EA7AD10024EB54 /* Category */,
A9661FC324EA7AD10024EB54 /* GeneralTool */,
......
......@@ -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.",
......
//
//
......@@ -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];
......
//
//
......@@ -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
//
//
......@@ -79,3 +79,10 @@
}
@end
@implementation OffcnIMPushModel
@end
@implementation OffcnIMPushApsModel
@end
//
//
......@@ -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;
//消息内容
......
//
//
......@@ -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];
......
//
//
......@@ -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-08-18 17:48:09";
// "send_time" = "2020-09-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) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment