Commit 377bbaf4 by zhangyunjie

1.0.0.1

parent d98e6b3d
......@@ -20,11 +20,11 @@
6003F5BA195388D20070C39A /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 6003F5B8195388D20070C39A /* InfoPlist.strings */; };
6003F5BC195388D20070C39A /* Tests.m in Sources */ = {isa = PBXBuildFile; fileRef = 6003F5BB195388D20070C39A /* Tests.m */; };
71719F9F1E33DC2100824A3D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 71719F9D1E33DC2100824A3D /* LaunchScreen.storyboard */; };
A995671F25107F72006D0714 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = A995671725107F71006D0714 /* AppDelegate.m */; };
A995672025107F72006D0714 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = A995671925107F71006D0714 /* ViewController.m */; };
A995672125107F72006D0714 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = A995671A25107F71006D0714 /* Main.storyboard */; };
A995672225107F72006D0714 /* OffcnIMSqliteTestVC.m in Sources */ = {isa = PBXBuildFile; fileRef = A995671C25107F72006D0714 /* OffcnIMSqliteTestVC.m */; };
A995672325107F72006D0714 /* OffcnZYJTestDataStorageView.m in Sources */ = {isa = PBXBuildFile; fileRef = A995671E25107F72006D0714 /* OffcnZYJTestDataStorageView.m */; };
A974845F2514CCD5005BEE32 /* OffcnIMSqliteTestVC.m in Sources */ = {isa = PBXBuildFile; fileRef = A97484592514CCD3005BEE32 /* OffcnIMSqliteTestVC.m */; };
A97484602514CCD5005BEE32 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = A974845C2514CCD4005BEE32 /* ViewController.m */; };
A97484612514CCD5005BEE32 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = A974845D2514CCD5005BEE32 /* AppDelegate.m */; };
A97484622514CCD5005BEE32 /* OffcnZYJ1TestDataStorageView.m in Sources */ = {isa = PBXBuildFile; fileRef = A974845E2514CCD5005BEE32 /* OffcnZYJ1TestDataStorageView.m */; };
A97484642514CCEC005BEE32 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = A97484632514CCEC005BEE32 /* Main.storyboard */; };
E7FA485477A3068BDB59B57D /* Pods_OffcnIMSDKiOS_Tests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 681564F81C0DE2354005C818 /* Pods_OffcnIMSDKiOS_Tests.framework */; };
/* End PBXBuildFile section */
......@@ -61,15 +61,15 @@
71719F9E1E33DC2100824A3D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
7C892FB0D02A2840B4B96BCF /* Pods_OffcnIMSDKiOS_Example.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_OffcnIMSDKiOS_Example.framework; sourceTree = BUILT_PRODUCTS_DIR; };
8BBE7340DBBB571709419405 /* Pods-OffcnIMSDKiOS_Example.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-OffcnIMSDKiOS_Example.debug.xcconfig"; path = "Target Support Files/Pods-OffcnIMSDKiOS_Example/Pods-OffcnIMSDKiOS_Example.debug.xcconfig"; sourceTree = "<group>"; };
A995671625107F71006D0714 /* OffcnIMSqliteTestVC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OffcnIMSqliteTestVC.h; sourceTree = "<group>"; };
A995671725107F71006D0714 /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
A995671825107F71006D0714 /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
A995671925107F71006D0714 /* ViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = "<group>"; };
A995671A25107F71006D0714 /* Main.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = Main.storyboard; sourceTree = "<group>"; };
A995671B25107F72006D0714 /* ViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = "<group>"; };
A995671C25107F72006D0714 /* OffcnIMSqliteTestVC.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OffcnIMSqliteTestVC.m; sourceTree = "<group>"; };
A995671D25107F72006D0714 /* OffcnZYJTestDataStorageView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OffcnZYJTestDataStorageView.h; sourceTree = "<group>"; };
A995671E25107F72006D0714 /* OffcnZYJTestDataStorageView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OffcnZYJTestDataStorageView.m; sourceTree = "<group>"; };
A97484572514CCD2005BEE32 /* OffcnZYJ1TestDataStorageView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OffcnZYJ1TestDataStorageView.h; sourceTree = "<group>"; };
A97484582514CCD2005BEE32 /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
A97484592514CCD3005BEE32 /* OffcnIMSqliteTestVC.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OffcnIMSqliteTestVC.m; sourceTree = "<group>"; };
A974845A2514CCD3005BEE32 /* ViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = "<group>"; };
A974845B2514CCD4005BEE32 /* OffcnIMSqliteTestVC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OffcnIMSqliteTestVC.h; sourceTree = "<group>"; };
A974845C2514CCD4005BEE32 /* ViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = "<group>"; };
A974845D2514CCD5005BEE32 /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
A974845E2514CCD5005BEE32 /* OffcnZYJ1TestDataStorageView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OffcnZYJ1TestDataStorageView.m; sourceTree = "<group>"; };
A97484632514CCEC005BEE32 /* Main.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = Main.storyboard; sourceTree = "<group>"; };
A99567242510825E006D0714 /* OffcnIMSDKiOS_Example.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = OffcnIMSDKiOS_Example.entitlements; sourceTree = "<group>"; };
D3198CF0B25C3B22C9B5421A /* LICENSE */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = LICENSE; path = ../LICENSE; sourceTree = "<group>"; };
E37AF8A01CD45C868BC87F73 /* OffcnIMSDKiOS.podspec */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = OffcnIMSDKiOS.podspec; path = ../OffcnIMSDKiOS.podspec; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.ruby; };
......@@ -140,15 +140,15 @@
6003F593195388D20070C39A /* Example for OffcnIMSDKiOS */ = {
isa = PBXGroup;
children = (
A995671825107F71006D0714 /* AppDelegate.h */,
A995671725107F71006D0714 /* AppDelegate.m */,
A995671A25107F71006D0714 /* Main.storyboard */,
A995671625107F71006D0714 /* OffcnIMSqliteTestVC.h */,
A995671C25107F72006D0714 /* OffcnIMSqliteTestVC.m */,
A995671D25107F72006D0714 /* OffcnZYJTestDataStorageView.h */,
A995671E25107F72006D0714 /* OffcnZYJTestDataStorageView.m */,
A995671B25107F72006D0714 /* ViewController.h */,
A995671925107F71006D0714 /* ViewController.m */,
A97484582514CCD2005BEE32 /* AppDelegate.h */,
A974845D2514CCD5005BEE32 /* AppDelegate.m */,
A974845B2514CCD4005BEE32 /* OffcnIMSqliteTestVC.h */,
A97484592514CCD3005BEE32 /* OffcnIMSqliteTestVC.m */,
A97484572514CCD2005BEE32 /* OffcnZYJ1TestDataStorageView.h */,
A974845E2514CCD5005BEE32 /* OffcnZYJ1TestDataStorageView.m */,
A974845A2514CCD3005BEE32 /* ViewController.h */,
A974845C2514CCD4005BEE32 /* ViewController.m */,
A97484632514CCEC005BEE32 /* Main.storyboard */,
71719F9D1E33DC2100824A3D /* LaunchScreen.storyboard */,
6003F5A8195388D20070C39A /* Images.xcassets */,
6003F594195388D20070C39A /* Supporting Files */,
......@@ -296,7 +296,7 @@
71719F9F1E33DC2100824A3D /* LaunchScreen.storyboard in Resources */,
6003F5A9195388D20070C39A /* Images.xcassets in Resources */,
6003F598195388D20070C39A /* InfoPlist.strings in Resources */,
A995672125107F72006D0714 /* Main.storyboard in Resources */,
A97484642514CCEC005BEE32 /* Main.storyboard in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -362,10 +362,12 @@
);
inputPaths = (
"${PODS_ROOT}/Target Support Files/Pods-OffcnIMSDKiOS_Example/Pods-OffcnIMSDKiOS_Example-frameworks.sh",
"${BUILT_PRODUCTS_DIR}/LMJDropdownMenu/LMJDropdownMenu.framework",
"${PODS_ROOT}/../../OffcnIMSDKiOS/Frameworks/oimcore.framework",
);
name = "[CP] Embed Pods Frameworks";
outputPaths = (
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/LMJDropdownMenu.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/oimcore.framework",
);
runOnlyForDeploymentPostprocessing = 0;
......@@ -380,11 +382,11 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
A995672025107F72006D0714 /* ViewController.m in Sources */,
A995672325107F72006D0714 /* OffcnZYJTestDataStorageView.m in Sources */,
A995672225107F72006D0714 /* OffcnIMSqliteTestVC.m in Sources */,
A995671F25107F72006D0714 /* AppDelegate.m in Sources */,
A97484612514CCD5005BEE32 /* AppDelegate.m in Sources */,
A97484602514CCD5005BEE32 /* ViewController.m in Sources */,
6003F59A195388D20070C39A /* main.m in Sources */,
A97484622514CCD5005BEE32 /* OffcnZYJ1TestDataStorageView.m in Sources */,
A974845F2514CCD5005BEE32 /* OffcnIMSqliteTestVC.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......
......@@ -8,9 +8,12 @@
#import <UIKit/UIKit.h>
typedef void(^deviceTokenCallback)(void);
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@property (nonatomic, copy) deviceTokenCallback deviceTokenCallback;
@end
......@@ -11,7 +11,7 @@
#import "OffcnIMSDKiOS.h"
#import "OffcnIMSocketManager.h"
#import "OffcnIMZYJFMDBHandler.h"
#import "OffcnIMZYJ1FMDBHandler.h"
#import "OffcnIMPushManager.h"
@interface AppDelegate ()
......@@ -39,10 +39,11 @@
//启动SDK
[[OffcnIMSDKiOS defaultService] setupWithIsTest:YES];
//注册推送
//注册系统推送
[OffcnIMPushManager registerOffcnUserNotificationSettingsWithApplication:application options:launchOptions];
//获取用户相关数据库,该方法在登陆或者第一次启动已登陆下执行
[[OffcnIMZYJFMDBHandler sharedInstance] getUserDB];
[[OffcnIMZYJ1FMDBHandler sharedInstance] getUserDB];
return YES;
......@@ -58,7 +59,7 @@
- (void)applicationWillEnterForeground:(UIApplication *)application {
// Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
}
- (void)applicationWillTerminate:(UIApplication *)application {
......@@ -68,16 +69,12 @@
- (void)applicationDidBecomeActive:(UIApplication *)application {
//进入前台,清除推送角标
[UIApplication sharedApplication].applicationIconBadgeNumber = 1;
[UIApplication sharedApplication].applicationIconBadgeNumber = 0;
[application cancelAllLocalNotifications];
// [JPUSHService setBadge:0];
}
- (void)application:(UIApplication *)application handleEventsForBackgroundURLSession:(NSString *)identifier completionHandler:(void (^)(void))completionHandler{
}
//远程推送注册成功
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken{
// 25bb75ac 3ffcebd7 90d9f517 1ebca904 154a367a 87781e5d b9ea288e 37fdf487
......@@ -88,6 +85,10 @@
NSString *str = [OffcnIMPushManager hexStringForData:deviceToken];
[OffcnIMSDKiOS defaultService].deviceToken = str;
NSLog(@"token--- %@",str);
if (self.deviceTokenCallback) {
self.deviceTokenCallback();
}
}
//注册失败
......@@ -99,7 +100,26 @@
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
NSLog(@"接收到远程推送通知Background ---- %@", userInfo);
[OffcnIMPushManager didReceiveRemoteNotification:userInfo];
// [OffcnIMPushManager didReceiveRemoteNotification:userInfo Finished:^(OffcnIMPushModel * _Nonnull IMPushModel) {
//
// NSString *sender = [NSString stringWithFormat:@"发送人ID:%@",IMPushModel.message.body.msg_from];
// NSString *rever = [NSString stringWithFormat:@"接收人ID:%@",IMPushModel.message.body.msg_to];
// NSString *time = [NSString stringWithFormat:@"时间:%@",IMPushModel.message.body.send_time];
// NSString *msg = @"";
// if (IMPushModel.message.body.msg_type == 1) {
// //文本消息
// msg = [msg stringByAppendingString:IMPushModel.message.body.msg.msg?IMPushModel.message.body.msg.msg:@"nil"];
// }else{
// //非文本消息
// msg = [msg stringByAppendingString:IMPushModel.message.body.msg.url?IMPushModel.message.body.msg.url:@"nil"];
// }
//
// NSString *allmsg = [NSString stringWithFormat:@"%@,%@,%@,消息:%@,拓展内容:%@",sender,rever,time,msg,IMPushModel.message.body.ext];
// dispatch_async(dispatch_get_main_queue(), ^{
// UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"远程推送通知" message:allmsg delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
// [alert show];
// });
// }];
// if ([UIApplication sharedApplication].applicationState != UIApplicationStateActive) {
//
......@@ -111,15 +131,49 @@
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo{
NSLog(@"接收到远程推送通知 ---- %@", userInfo);
[OffcnIMPushManager didReceiveRemoteNotification:userInfo];
//将推送消息以alert形式呈现
// NSString *message = [[userInfo objectForKey:@"aps"]objectForKey:@"alert"];
// UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示" message:message delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
// [alert show];
// [OffcnIMPushManager didReceiveRemoteNotification:userInfo Finished:^(OffcnIMPushModel * _Nonnull IMPushModel) {
//
// NSString *sender = [NSString stringWithFormat:@"发送人ID:%@",IMPushModel.message.body.msg_from];
// NSString *rever = [NSString stringWithFormat:@"接收人ID:%@",IMPushModel.message.body.msg_to];
// NSString *time = [NSString stringWithFormat:@"时间:%@",IMPushModel.message.body.send_time];
// NSString *msg = @"";
// if (IMPushModel.message.body.msg_type == 1) {
// //文本消息
// msg = [msg stringByAppendingString:IMPushModel.message.body.msg.msg?IMPushModel.message.body.msg.msg:@"nil"];
// }else{
// //非文本消息
// msg = [msg stringByAppendingString:IMPushModel.message.body.msg.url?IMPushModel.message.body.msg.url:@"nil"];
// }
//
// NSString *allmsg = [NSString stringWithFormat:@"%@,%@,%@,消息:%@,拓展内容:%@",sender,rever,time,msg,IMPushModel.message.body.ext];
// dispatch_async(dispatch_get_main_queue(), ^{
// UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"远程推送通知" message:allmsg delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
// [alert show];
// });
// }];
}
- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification{
NSLog(@"接收到本地推送通知 ---- %@", notification.userInfo);
// [OffcnIMPushManager didReceiveLocalNotification:notification.userInfo Finished:^(OffcnIMModel * _Nonnull IMLocalPushModel) {
//
// NSString *sender = [NSString stringWithFormat:@"发送人ID:%@",IMLocalPushModel.body.msg_from];
// NSString *rever = [NSString stringWithFormat:@"接收人ID:%@",IMLocalPushModel.body.msg_to];
// NSString *time = [NSString stringWithFormat:@"时间:%@",IMLocalPushModel.body.send_time];
// NSString *msg = @"";
// if (IMLocalPushModel.body.msg_type == 1) {
// //文本消息
// msg = [msg stringByAppendingString:IMLocalPushModel.body.msg.msg?IMLocalPushModel.body.msg.msg:@"nil"];
// }else{
// //非文本消息
// msg = [msg stringByAppendingString:IMLocalPushModel.body.msg.url?IMLocalPushModel.body.msg.url:@"nil"];
// }
//
// NSString *allmsg = [NSString stringWithFormat:@"%@,%@,%@,消息:%@,拓展内容:%@",sender,rever,time,msg,IMLocalPushModel.body.ext];
// dispatch_async(dispatch_get_main_queue(), ^{
// UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"本地推送通知" message:allmsg delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
// [alert show];
// });
// }];
}
- (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings{
......
......@@ -20,9 +20,10 @@
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="HDM-va-7kG">
<rect key="frame" x="0.0" y="0.0" width="375" height="50"/>
<rect key="frame" x="0.0" y="0.0" width="100" height="50"/>
<color key="backgroundColor" red="1" green="0.21225945169999999" blue="0.26982277180000003" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="width" constant="100" id="ggp-5t-EmR"/>
<constraint firstAttribute="height" constant="50" id="hEt-Jn-qfb"/>
</constraints>
<state key="normal" title="点我退出键盘"/>
......@@ -31,11 +32,8 @@
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="so4-rI-aRi">
<rect key="frame" x="0.0" y="55" width="375" height="30"/>
<rect key="frame" x="100" y="0.0" width="275" height="50"/>
<color key="backgroundColor" red="0.63529411759999999" green="0.51764705879999995" blue="0.36862745099999999" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="height" constant="30" id="FlU-ab-1sz"/>
</constraints>
<color key="tintColor" red="0.63529411759999999" green="0.51764705879999995" blue="0.36862745099999999" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<state key="normal" title="当前为正式环境,点击切换为测试环境">
<color key="titleColor" red="1" green="0.1764705882" blue="0.33333333329999998" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
......@@ -91,7 +89,7 @@
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Vmx-zP-DRW">
<rect key="frame" x="82" y="207" width="92" height="30"/>
<color key="backgroundColor" white="0.66666666669999997" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<state key="normal" title="发送本地通知"/>
<state key="normal" title="进入当前会话"/>
<connections>
<action selector="sendLocalNotiAction:" destination="BYZ-38-t0r" eventType="touchUpInside" id="jbM-Ii-Hmr"/>
</connections>
......@@ -105,9 +103,9 @@
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="FOH-XA-D8x">
<rect key="frame" x="179" y="207" width="107" height="30"/>
<rect key="frame" x="179" y="207" width="92" height="30"/>
<color key="backgroundColor" white="0.66666666669999997" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<state key="normal" title="发送socket消息"/>
<state key="normal" title="退出当前会话"/>
<connections>
<action selector="sendMegAction:" destination="BYZ-38-t0r" eventType="touchUpInside" id="6ex-WY-diR"/>
</connections>
......@@ -127,7 +125,7 @@
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="m3k-LM-GSV">
<rect key="frame" x="15" y="452" width="62" height="30"/>
<color key="backgroundColor" white="0.66666666669999997" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<state key="normal" title="注册用户"/>
<state key="normal" title="注册推送"/>
<connections>
<action selector="registeredUser:" destination="BYZ-38-t0r" eventType="touchUpInside" id="6BH-gR-fcD"/>
</connections>
......@@ -135,7 +133,7 @@
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="uRU-q5-QzB">
<rect key="frame" x="82" y="452" width="62" height="30"/>
<color key="backgroundColor" white="0.66666666669999997" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<state key="normal" title="注销用户"/>
<state key="normal" title="注销推送"/>
<connections>
<action selector="UnRegisteredUser:" destination="BYZ-38-t0r" eventType="touchUpInside" id="lsz-2T-JSe"/>
</connections>
......@@ -199,7 +197,7 @@
<color key="backgroundColor" white="0.66666666669999997" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<state key="normal" title="数据库"/>
<connections>
<segue destination="2by-9C-78c" kind="push" id="fvn-k7-WRW"/>
<action selector="lookDatabase:" destination="BYZ-38-t0r" eventType="touchUpInside" id="NzO-RH-OFo"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="hBY-Ug-jR2">
......@@ -211,6 +209,24 @@
<action selector="pressureTest:" destination="BYZ-38-t0r" eventType="touchUpInside" id="elf-4J-COs"/>
</connections>
</button>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="发送人" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="2dO-Tn-LD7">
<rect key="frame" x="15" y="55" width="100" height="30"/>
<color key="backgroundColor" white="0.66666666669999997" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="height" constant="30" id="OzX-mU-bih"/>
<constraint firstAttribute="width" constant="100" id="Yz6-yT-W63"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="15"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="接受人" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="irT-Ka-3TX">
<rect key="frame" x="125" y="55" width="112" height="30"/>
<color key="backgroundColor" white="0.66666666669999997" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<fontDescription key="fontDescription" type="system" pointSize="15"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
......@@ -218,29 +234,34 @@
<constraint firstItem="7fD-Hf-Afy" firstAttribute="top" secondItem="F7y-mH-mpC" secondAttribute="bottom" constant="5" id="3iZ-Fk-2i8"/>
<constraint firstItem="W7X-2X-xsv" firstAttribute="leading" secondItem="8bC-Xf-vdC" secondAttribute="leading" constant="15" id="4mN-Ol-K6z"/>
<constraint firstItem="F7y-mH-mpC" firstAttribute="leading" secondItem="TnX-iH-azN" secondAttribute="leading" constant="1" id="6b7-ni-Ag1"/>
<constraint firstItem="2dO-Tn-LD7" firstAttribute="leading" secondItem="8bC-Xf-vdC" secondAttribute="leading" constant="15" id="6eY-Q2-wof"/>
<constraint firstItem="bxC-wQ-owS" firstAttribute="top" secondItem="Cy1-S1-DPz" secondAttribute="top" id="6i3-87-Iqw"/>
<constraint firstItem="2dO-Tn-LD7" firstAttribute="top" secondItem="HDM-va-7kG" secondAttribute="bottom" constant="5" id="7eE-LI-n4L"/>
<constraint firstItem="wpP-7X-EhS" firstAttribute="leading" secondItem="W7X-2X-xsv" secondAttribute="leading" id="7qR-05-4WU"/>
<constraint firstAttribute="trailing" secondItem="so4-rI-aRi" secondAttribute="trailing" id="83W-xz-1xP"/>
<constraint firstAttribute="trailing" secondItem="hBY-Ug-jR2" secondAttribute="trailing" constant="15" id="8L6-lm-ovv"/>
<constraint firstItem="wpP-7X-EhS" firstAttribute="top" secondItem="8TM-yv-Un7" secondAttribute="bottom" constant="5" id="8Ny-K1-4n7"/>
<constraint firstItem="Cy1-S1-DPz" firstAttribute="height" secondItem="dRe-f0-gnl" secondAttribute="height" id="8qa-si-8ig"/>
<constraint firstItem="m3k-LM-GSV" firstAttribute="leading" secondItem="dRe-f0-gnl" secondAttribute="leading" id="97H-yt-Mwa"/>
<constraint firstItem="dRe-f0-gnl" firstAttribute="leading" secondItem="8bC-Xf-vdC" secondAttribute="leading" constant="15" id="A4C-6b-WCr"/>
<constraint firstItem="so4-rI-aRi" firstAttribute="leading" secondItem="8bC-Xf-vdC" secondAttribute="leading" id="Acv-YJ-6xY"/>
<constraint firstItem="hBY-Ug-jR2" firstAttribute="top" secondItem="0ox-b2-eLv" secondAttribute="bottom" constant="10" id="Ahq-wn-M6U"/>
<constraint firstItem="dRe-f0-gnl" firstAttribute="top" secondItem="wpP-7X-EhS" secondAttribute="bottom" constant="5" id="AvN-lQ-0c4"/>
<constraint firstItem="so4-rI-aRi" firstAttribute="leading" secondItem="HDM-va-7kG" secondAttribute="trailing" id="DBt-un-mxD"/>
<constraint firstItem="wpP-7X-EhS" firstAttribute="height" secondItem="W7X-2X-xsv" secondAttribute="height" id="DSG-sD-qXE"/>
<constraint firstItem="irT-Ka-3TX" firstAttribute="top" secondItem="2dO-Tn-LD7" secondAttribute="top" id="FLv-ff-VCA"/>
<constraint firstItem="8TM-yv-Un7" firstAttribute="height" secondItem="W7X-2X-xsv" secondAttribute="height" id="FsK-4W-A58"/>
<constraint firstItem="so4-rI-aRi" firstAttribute="height" secondItem="HDM-va-7kG" secondAttribute="height" multiplier="0.6" constant="20" id="FzM-6k-5Gt"/>
<constraint firstItem="bxC-wQ-owS" firstAttribute="height" secondItem="Cy1-S1-DPz" secondAttribute="height" id="HRS-aT-dpu"/>
<constraint firstItem="F7y-mH-mpC" firstAttribute="height" secondItem="TnX-iH-azN" secondAttribute="height" id="HV9-jc-VLg"/>
<constraint firstItem="F7y-mH-mpC" firstAttribute="top" secondItem="9JE-Lz-Dma" secondAttribute="bottom" constant="5" id="HdJ-KZ-Mo0"/>
<constraint firstItem="irT-Ka-3TX" firstAttribute="width" secondItem="2dO-Tn-LD7" secondAttribute="width" multiplier="1.07" constant="5" id="Hig-Ke-H37"/>
<constraint firstItem="FOH-XA-D8x" firstAttribute="leading" secondItem="Vmx-zP-DRW" secondAttribute="trailing" constant="5" id="IwN-ov-FmL"/>
<constraint firstItem="so4-rI-aRi" firstAttribute="top" secondItem="HDM-va-7kG" secondAttribute="bottom" constant="5" id="JGR-v7-Dr6"/>
<constraint firstItem="01u-sn-4fM" firstAttribute="leading" secondItem="bxC-wQ-owS" secondAttribute="trailing" constant="5" id="Klm-Tu-0BT"/>
<constraint firstItem="HDM-va-7kG" firstAttribute="leading" secondItem="8bC-Xf-vdC" secondAttribute="leading" id="LVQ-dP-gyt"/>
<constraint firstItem="m3k-LM-GSV" firstAttribute="top" secondItem="7fD-Hf-Afy" secondAttribute="bottom" constant="5" id="Lxq-EJ-ByY"/>
<constraint firstItem="2eb-Vp-qLt" firstAttribute="height" secondItem="dRe-f0-gnl" secondAttribute="height" id="M7d-CM-zWv"/>
<constraint firstItem="uRU-q5-QzB" firstAttribute="top" secondItem="m3k-LM-GSV" secondAttribute="top" id="MSV-Gc-Og9"/>
<constraint firstAttribute="trailing" secondItem="so4-rI-aRi" secondAttribute="trailing" id="MTw-tc-ZdJ"/>
<constraint firstItem="W7X-2X-xsv" firstAttribute="top" secondItem="2dO-Tn-LD7" secondAttribute="bottom" constant="5" id="NXp-gD-4dc"/>
<constraint firstItem="01u-sn-4fM" firstAttribute="top" secondItem="Cy1-S1-DPz" secondAttribute="top" id="Nb3-Oc-foo"/>
<constraint firstItem="2eb-Vp-qLt" firstAttribute="top" secondItem="dRe-f0-gnl" secondAttribute="bottom" constant="5" id="QLW-Tp-TY4"/>
<constraint firstItem="bxC-wQ-owS" firstAttribute="leading" secondItem="Cy1-S1-DPz" secondAttribute="trailing" constant="5" id="Rdx-7e-eh7"/>
......@@ -249,20 +270,21 @@
<constraint firstItem="8PJ-g2-nFJ" firstAttribute="top" secondItem="Cy1-S1-DPz" secondAttribute="bottom" constant="5" id="Tjy-h1-vZN"/>
<constraint firstItem="9C8-lY-VAg" firstAttribute="bottom" secondItem="TnX-iH-azN" secondAttribute="bottom" id="UMk-Jo-juB"/>
<constraint firstItem="TnX-iH-azN" firstAttribute="leading" secondItem="8bC-Xf-vdC" secondAttribute="leading" constant="15" id="UOK-BA-rIV"/>
<constraint firstItem="irT-Ka-3TX" firstAttribute="leading" secondItem="2dO-Tn-LD7" secondAttribute="trailing" constant="10" id="W1D-fa-dg9"/>
<constraint firstItem="0ox-b2-eLv" firstAttribute="top" secondItem="9JE-Lz-Dma" secondAttribute="top" id="Wtn-mc-a6W"/>
<constraint firstItem="9C8-lY-VAg" firstAttribute="leading" secondItem="TnX-iH-azN" secondAttribute="trailing" constant="5" id="XgB-GO-lOM"/>
<constraint firstItem="Cy1-S1-DPz" firstAttribute="leading" secondItem="dRe-f0-gnl" secondAttribute="leading" id="Y9c-yU-8ZX"/>
<constraint firstAttribute="trailing" secondItem="HDM-va-7kG" secondAttribute="trailing" id="YX6-FQ-G4J"/>
<constraint firstItem="8TM-yv-Un7" firstAttribute="trailing" secondItem="W7X-2X-xsv" secondAttribute="trailing" id="ZsE-8c-rUX"/>
<constraint firstItem="FOH-XA-D8x" firstAttribute="top" secondItem="dRe-f0-gnl" secondAttribute="top" id="dJi-hK-bk0"/>
<constraint firstItem="W7X-2X-xsv" firstAttribute="top" secondItem="so4-rI-aRi" secondAttribute="bottom" constant="5" id="dox-is-kXR"/>
<constraint firstItem="2eb-Vp-qLt" firstAttribute="leading" secondItem="dRe-f0-gnl" secondAttribute="leading" constant="1" id="e0h-4k-Ucp"/>
<constraint firstItem="8TM-yv-Un7" firstAttribute="leading" secondItem="W7X-2X-xsv" secondAttribute="leading" id="eFf-tb-Hek"/>
<constraint firstAttribute="trailing" secondItem="0ox-b2-eLv" secondAttribute="trailing" constant="15" id="eZI-Mq-JLV"/>
<constraint firstItem="9JE-Lz-Dma" firstAttribute="height" secondItem="TnX-iH-azN" secondAttribute="height" id="fRe-gX-tKo"/>
<constraint firstItem="1dp-RW-FhV" firstAttribute="leading" secondItem="TnX-iH-azN" secondAttribute="leading" constant="1" id="gpR-z2-ljd"/>
<constraint firstItem="uRU-q5-QzB" firstAttribute="leading" secondItem="m3k-LM-GSV" secondAttribute="trailing" constant="5" id="hRq-kb-fCs"/>
<constraint firstItem="so4-rI-aRi" firstAttribute="top" secondItem="HDM-va-7kG" secondAttribute="top" id="iv1-xe-BDD"/>
<constraint firstItem="7fD-Hf-Afy" firstAttribute="height" secondItem="TnX-iH-azN" secondAttribute="height" id="j3W-5R-k7D"/>
<constraint firstItem="irT-Ka-3TX" firstAttribute="height" secondItem="2dO-Tn-LD7" secondAttribute="height" multiplier="0.6" constant="12" id="j9c-Dh-Gyd"/>
<constraint firstItem="9C8-lY-VAg" firstAttribute="height" secondItem="TnX-iH-azN" secondAttribute="height" multiplier="1.13333" id="k7J-W8-ljE"/>
<constraint firstItem="9JE-Lz-Dma" firstAttribute="leading" secondItem="TnX-iH-azN" secondAttribute="leading" constant="1" id="kqV-nZ-dh4"/>
<constraint firstItem="HDM-va-7kG" firstAttribute="top" secondItem="a21-3W-10n" secondAttribute="bottom" id="lS8-hA-rmu"/>
......@@ -288,8 +310,10 @@
<outlet property="changeEnvironmentBtn" destination="so4-rI-aRi" id="ong-vG-zJ6"/>
<outlet property="megTextField" destination="9C8-lY-VAg" id="NdF-KZ-ejC"/>
<outlet property="recvIDTextField" destination="wpP-7X-EhS" id="qJr-jJ-e4u"/>
<outlet property="revLab" destination="irT-Ka-3TX" id="mZ8-7X-8zX"/>
<outlet property="sendIDTextField" destination="W7X-2X-xsv" id="e1Q-4T-l0b"/>
<outlet property="sendTokenTextField" destination="8TM-yv-Un7" id="HYr-kt-sOj"/>
<outlet property="senderLab" destination="2dO-Tn-LD7" id="fP4-m5-Rcn"/>
<outlet property="showImage" destination="01u-sn-4fM" id="Tl0-7d-FXH"/>
</connections>
</viewController>
......@@ -300,13 +324,13 @@
<!--OffcnIM Sqlite TestVC-->
<scene sceneID="hcv-uv-YGK">
<objects>
<viewController id="2by-9C-78c" customClass="OffcnIMSqliteTestVC" sceneMemberID="viewController">
<viewController storyboardIdentifier="OffcnIMSqliteTestVC" id="2by-9C-78c" customClass="OffcnIMSqliteTestVC" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="gRc-11-2rD"/>
<viewControllerLayoutGuide type="bottom" id="5Te-7X-gHr"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="Lef-sG-R6x">
<rect key="frame" x="0.0" y="0.0" width="375" height="647"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="hI0-jm-bPD">
......
......@@ -12,7 +12,8 @@ NS_ASSUME_NONNULL_BEGIN
@interface OffcnIMSqliteTestVC : UIViewController
@property (strong, nonatomic) NSString *fromId;
@property (strong, nonatomic) NSString *toId;
@end
NS_ASSUME_NONNULL_END
......@@ -7,15 +7,13 @@
//
#import "OffcnIMSqliteTestVC.h"
#import "OffcnIMZYJFMDBHandler.h"
#import "OffcnIMZYJ1FMDBHandler.h"
#import "OffcnIMModel.h"
#import "OffcnZYJTestDataStorageView.h"
#import "OffcnZYJ1TestDataStorageView.h"
@interface OffcnIMSqliteTestVC ()
@property (strong, nonatomic) NSString *fromId;
@property (strong, nonatomic) NSString *toId;
@property (assign, nonatomic) UIClearStyle clearStyle;
@end
......@@ -25,15 +23,14 @@
[super viewDidLoad];
self.title = @"数据库";
self.fromId = @"ce0819db8391f1e7258a71cc9e2c3235";
self.toId = @"ceb7383519c5b6a1c8579553f01ad9c4";
self.clearStyle = UIClearStylePart;
self.clearStyle = UIClearStyleAll;
}
//删除记录
- (IBAction)deleteRecord:(UIButton *)sender {
[[OffcnIMZYJFMDBHandler sharedInstance] deleteUserChatDataWithFromUser:self.fromId toUser:self.toId clearStyle:self.clearStyle callBack:^(BOOL isSuccess) {
[[OffcnIMZYJ1FMDBHandler sharedInstance] deleteUserChatDataWithFromUser:self.fromId toUser:self.toId clearStyle:self.clearStyle callBack:^(BOOL isSuccess) {
}];
}
......@@ -41,24 +38,24 @@
//删除表格
- (IBAction)deleteTable:(UIButton *)sender {
[[OffcnIMZYJFMDBHandler sharedInstance] deleteDataTable];
[[OffcnIMZYJ1FMDBHandler sharedInstance] deleteDataTable];
}
//查询聊天列表
- (IBAction)queryChatList:(UIButton *)sender {
[[OffcnIMZYJFMDBHandler sharedInstance] getChatListArrayCallback:^(NSArray<OffcnIMBodyModel *> *messagesArray) {
[[OffcnIMZYJ1FMDBHandler sharedInstance] getChatListArrayCallback:^(NSArray<OffcnIMBodyModel *> *messagesArray) {
NSString *msg = @"";
for (int i=0; i<messagesArray.count; i++) {
OffcnIMBodyModel *model = messagesArray[i];
msg = [msg stringByAppendingString:[NSString stringWithFormat:@"msg_type:%ld,lastSendtime:%@,lastmessage:%@",(long)model.msg_type,model.lastSendtime,model.lastmessage]];
msg = [msg stringByAppendingString:[NSString stringWithFormat:@"发送人ID:%@,接收人ID:%@,消息类型:%ld,时间:%@,内容:%@,未读数:%ld,拓展内容:%@",model.msg_from,model.msg_to,(long)model.msg_type,model.lastSendtime,model.lastmessage,(long)model.unread_number,model.ext]];
msg = [msg stringByAppendingString:@"\r\n"];
msg = [msg stringByAppendingString:@"\r\n"];
}
OffcnZYJTestDataStorageView *storageView = [[OffcnZYJTestDataStorageView alloc] initWithFrame:CGRectMake(0, 20, self.view.bounds.size.width, self.view.bounds.size.height-20)];
OffcnZYJ1TestDataStorageView *storageView = [[OffcnZYJ1TestDataStorageView alloc] initWithFrame:CGRectMake(0, 20, self.view.bounds.size.width, self.view.bounds.size.height-20)];
storageView.msg = msg;
[storageView showView];
}];
......@@ -67,11 +64,15 @@
//查询聊天记录
- (IBAction)queryChat:(UIButton *)sender {
[[OffcnIMZYJFMDBHandler sharedInstance] getChatRecordArrayWithFromUser:self.fromId toUser:self.toId limit:@"20" startIndex:@"0" callback:^(NSArray<OffcnIMBodyModel *> *messagesArray) {
[[OffcnIMZYJ1FMDBHandler sharedInstance] getChatRecordArrayWithFromUser:self.fromId toUser:self.toId limit:@"20" startIndex:@"0" callback:^(NSArray<OffcnIMBodyModel *> *messagesArray) {
NSString *msg = @"";
NSString *content = @"";
for (int i=0; i<messagesArray.count; i++) {
OffcnIMBodyModel *model = messagesArray[i];
NSString *sender = [NSString stringWithFormat:@"发送人ID:%@",model.msg_from];
NSString *rever = [NSString stringWithFormat:@"接收人ID:%@",model.msg_to];
NSString *time = [NSString stringWithFormat:@"时间:%@",model.send_time];
NSString *msg = @"";
if (model.msg_type == 1) {
//文本消息
msg = [msg stringByAppendingString:model.msg.msg?model.msg.msg:@"nil"];
......@@ -80,12 +81,16 @@
msg = [msg stringByAppendingString:model.msg.url?model.msg.url:@"nil"];
}
msg = [msg stringByAppendingString:@"\r\n"];
msg = [msg stringByAppendingString:@"\r\n"];
NSString *allmsg = [NSString stringWithFormat:@"%@,%@,%@,消息:%@,拓展内容:%@",sender,rever,time,msg,model.ext];
content = [content stringByAppendingString:allmsg];
content = [content stringByAppendingString:@"\r\n"];
content = [content stringByAppendingString:@"\r\n"];
}
OffcnZYJTestDataStorageView *storageView = [[OffcnZYJTestDataStorageView alloc] initWithFrame:CGRectMake(0, 20, self.view.bounds.size.width, self.view.bounds.size.height-20)];
storageView.msg = msg;
OffcnZYJ1TestDataStorageView *storageView = [[OffcnZYJ1TestDataStorageView alloc] initWithFrame:CGRectMake(0, 20, self.view.bounds.size.width, self.view.bounds.size.height-20)];
storageView.msg = content;
[storageView showView];
}];
}
......@@ -94,24 +99,20 @@
- (IBAction)setUnreadNum:(UIButton *)sender {
__block OffcnIMBodyModel *IMBodyModel = nil;
[[OffcnIMZYJFMDBHandler sharedInstance] getChatListOneMessageWithFromUser:self.fromId toUser:self.toId callback:^(OffcnIMBodyModel *model) {
[[OffcnIMZYJ1FMDBHandler sharedInstance] getChatListOneMessageWithFromUser:self.fromId toUser:self.toId callback:^(OffcnIMBodyModel *model) {
IMBodyModel = model;
}];
if (IMBodyModel) {
//存在,更新未读数
OffcnIMBodyModel *BodyModel = [[OffcnIMBodyModel alloc] init];
BodyModel.msg_from = self.fromId;
BodyModel.msg_to = self.toId;
BodyModel.unread_number = IMBodyModel.unread_number+1;
OffcnIMBodyModel *BodyModel = [[OffcnIMBodyModel alloc] init];
BodyModel.msg_from = self.fromId;
BodyModel.msg_to = self.toId;
BodyModel.unread_number = IMBodyModel.unread_number+1;
[[OffcnIMZYJ1FMDBHandler sharedInstance] updateChatListUnread_number:BodyModel callBack:^(OffcnIMBodyModel *model) {
[[OffcnIMZYJFMDBHandler sharedInstance] updateChatListUnread_number:BodyModel callBack:^(BOOL isSuccess) {
}];
}else{
//不存在,先更新聊天列表再更新未读数
}
NSLog(@"测试未读数%ld",(long)model.unread_number);
}];
}
@end
//
// OffcnZYJTestDataStorageView.h
// OffcnZYJ1TestDataStorageView.h
// OffcnLiveSDK
//
// Created by zyj on 2020/3/28.
// Created by ZYJ1 on 2020/3/28.
// Copyright © 2020 中公教育. All rights reserved.
//
......@@ -10,7 +10,7 @@
NS_ASSUME_NONNULL_BEGIN
@interface OffcnZYJTestDataStorageView : UIView
@interface OffcnZYJ1TestDataStorageView : UIView
@property (nonatomic, strong) NSString *msg;
......
//
// OffcnZYJTestDataStorageView.m
// OffcnZYJ1TestDataStorageView.m
// OffcnLiveSDK
//
// Created by zyj on 2020/3/28.
// Created by ZYJ1 on 2020/3/28.
// Copyright © 2020 中公教育. All rights reserved.
//
#import "OffcnZYJTestDataStorageView.h"
#import "OffcnZYJ1TestDataStorageView.h"
@interface OffcnZYJTestDataStorageView ()
@interface OffcnZYJ1TestDataStorageView ()
@property (nonatomic, strong) UIButton *pasteBtn;
@property (nonatomic, strong) UIButton *cancellBtn;
@property (nonatomic, strong) UITextView *textView;
@end
@implementation OffcnZYJTestDataStorageView
@implementation OffcnZYJ1TestDataStorageView
-(UIButton *)pasteBtn{
if (!_pasteBtn) {
......@@ -55,7 +55,7 @@
if (!_textView){
_textView = [[UITextView alloc] initWithFrame:CGRectZero];
_textView.font = [UIFont systemFontOfSize:13];
_textView.textColor = [UIColor greenColor];
_textView.textColor = [UIColor blackColor];
_textView.textAlignment = NSTextAlignmentLeft;
_textView.linkTextAttributes = @{NSForegroundColorAttributeName:[UIColor blueColor]};
......
......@@ -9,6 +9,8 @@
#import <UIKit/UIKit.h>
#define kOffcnIMSDKiOS_changeEnvironment @"kOffcnIMSDKiOS_changeEnvironment"
#define kOffcnIMSDKiOS_fromid @"kOffcnIMSDKiOS_fromid"
#define kOffcnIMSDKiOS_token @"kOffcnIMSDKiOS_token"
@interface ViewController : UIViewController
......
......@@ -10,17 +10,29 @@
#import "OffcnIMSDKiOS.h"
#import "OffcnIMSocketManager.h"
#import "OffcnIMPushManager.h"
#import "AppDelegate.h"
#import "OffcnZYJTestDataStorageView.h"
@interface ViewController ()<UINavigationControllerDelegate, UIImagePickerControllerDelegate>
#import "OffcnZYJ1TestDataStorageView.h"
#import "LMJDropdownMenu.h"
#import "OffcnIMSqliteTestVC.h"
@interface ViewController ()<UINavigationControllerDelegate, UIImagePickerControllerDelegate,LMJDropdownMenuDelegate,LMJDropdownMenuDataSource>
{
NSArray * _menu1OptionTitles;
NSArray * _menu1TokenOptionTitles;
NSArray * _menu2OptionTitles;
NSArray * _nameOptionTitles;
LMJDropdownMenu * menu1;
LMJDropdownMenu * menu2;
}
@property (weak, nonatomic) IBOutlet UIButton *changeEnvironmentBtn;
@property (weak, nonatomic) IBOutlet UITextField *megTextField;
@property (weak, nonatomic) IBOutlet UITextField *sendIDTextField;
@property (weak, nonatomic) IBOutlet UITextField *sendTokenTextField;
@property (weak, nonatomic) IBOutlet UITextField *recvIDTextField;
@property (weak, nonatomic) IBOutlet UILabel *senderLab;
@property (weak, nonatomic) IBOutlet UILabel *revLab;
@property (strong, nonatomic) NSString *fromId;
@property (strong, nonatomic) NSString *toId;
......@@ -29,6 +41,8 @@
@property (weak, nonatomic) IBOutlet UIImageView *showImage;
@property (nonatomic, strong) NSTimer *timer;//压测
@property (nonatomic, assign)NSInteger msg_seq;//消息时序
@end
@implementation ViewController
......@@ -40,9 +54,16 @@
self.changeEnvironmentBtn.selected = [OffcnIMSDKiOS defaultService].isTest;
self.sendIDTextField.text = @"ce0819db8391f1e7258a71cc9e2c3235";
self.sendTokenTextField.text = @"fadbce3f4929b6bdee0617fee34e32ae";
self.recvIDTextField.text = @"ceb7383519c5b6a1c8579553f01ad9c4";
self.sendIDTextField.text = @"704a3ebbfeb9a754ea6fd1106e4862d8";
self.sendTokenTextField.text = @"ThXLFM/oGZPTks22QjPNnSvkJxD3aqwtLkmbsTlhm4t5p5G+RXCyx8SwRXv6GO1RVM3WGJzCxmef1N3WZ9euRt5tvKs1XLLYIDGe4PIEBqPrvxEReyZv0jSd+XWxE0EF";
self.senderLab.text = @"发送人:李梦";
self.recvIDTextField.text = @"2a956beb4a21a4b98c42384f3534ee08";
self.revLab.text = @"接收人:李永裕";
self.sendIDTextField.hidden = YES;
self.sendTokenTextField.hidden = YES;
self.recvIDTextField.hidden = YES;
self.fromId = self.sendIDTextField.text;
self.toId = self.recvIDTextField.text;
......@@ -52,12 +73,82 @@
}
[self.timer setFireDate:[NSDate distantFuture]];
[self addMenu];
NSNotificationCenter *defaultCenter = [NSNotificationCenter defaultCenter];
[defaultCenter addObserver:self
selector:@selector(appWillTerminate)
name:UIApplicationWillTerminateNotification
object:nil];
}
-(void)addMenu{
_menu1OptionTitles = @[@"发送人704a3ebbfeb9a754ea6fd1106e4862d8",@"发送人2a956beb4a21a4b98c42384f3534ee08",@"发送人3f09513d254682a25ba0413097099a92",@"发送人1f890295d95b2dea102483373e6a7e3a",@"发送人20a35e2e10996d0e15489297b319fd51"];
_menu1TokenOptionTitles = @[@"ThXLFM/oGZPTks22QjPNnSvkJxD3aqwtLkmbsTlhm4t5p5G+RXCyx8SwRXv6GO1RVM3WGJzCxmef1N3WZ9euRt5tvKs1XLLYIDGe4PIEBqPrvxEReyZv0jSd+XWxE0EF",@"3csdJWLhE6K9FrQK8Gy7wzroe/icewdVchEm1NrRn148R6m6AwGrBc2FT8dgqybCvc5oVN//Qks=@ip6c.cn.rongnav.com;ip6c.cn.rongcfg.com",@"TlXegSSUiiU6GN6ZhUwGt2LwpiKByYg1GRe0X/Havz1IrPNTu/ait4PWl1zOxiBTG8ju8QEOGl0VnSlJXWAEubMWiD8zcXNM6dN4XRDjafwvs+RgyZXb7z0O4oHauZzyRK/U8pOAkX0=",@"+SSkwImtTQbKvMZu3Je2t1hKcd6MtgL4/0zwzBsh3kNjvs87f03ch82FT8dgqybCHDhIkChdv84=@ip6c.cn.rongnav.com;ip6c.cn.rongcfg.com",@"/L3TZiY2oEoBvEZtn+sHWmLwpiKByYg1GRe0X/Havz1IrPNTu/ait0hda/h0OnT7mlkYUdtmheRmQnKb3HDdzPD8twTxIYaaQWdGktQhAkve0ak/MKLE++3OwGhBJl/nRK/U8pOAkX0="];
_nameOptionTitles = @[@"李梦",@"李永裕",@"杨瑞娟",@"任志玲",@"殷倩"];
_menu2OptionTitles = @[@"接收人704a3ebbfeb9a754ea6fd1106e4862d8",@"接收人2a956beb4a21a4b98c42384f3534ee08",@"接收人3f09513d254682a25ba0413097099a92",@"接收人1f890295d95b2dea102483373e6a7e3a",@"接收人20a35e2e10996d0e15489297b319fd51"];
// ----------------------- menu1 ---------------------------
menu1 = [[LMJDropdownMenu alloc] init];
menu1.frame = self.sendIDTextField.frame;
menu1.dataSource = self;
menu1.delegate = self;
menu1.layer.borderColor = [UIColor whiteColor].CGColor;
menu1.layer.borderWidth = 1;
menu1.layer.cornerRadius = 3;
menu1.title = @"发送人704a3ebbfeb9a754ea6fd1106e4862d8";
menu1.titleBgColor = [UIColor colorWithRed:64/255.f green:151/255.f blue:255/255.f alpha:1];
menu1.titleFont = [UIFont boldSystemFontOfSize:12];
menu1.titleColor = [UIColor whiteColor];
menu1.titleAlignment = NSTextAlignmentLeft;
menu1.titleEdgeInsets = UIEdgeInsetsMake(0, 15, 0, 0);
menu1.optionBgColor = [UIColor colorWithRed:64/255.f green:151/255.f blue:255/255.f alpha:0.5];
menu1.optionFont = [UIFont systemFontOfSize:12];
menu1.optionTextColor = [UIColor blackColor];
menu1.optionTextAlignment = NSTextAlignmentLeft;
menu1.optionNumberOfLines = 0;
menu1.optionLineColor = [UIColor whiteColor];
menu1.optionIconSize = CGSizeMake(15, 15);
[self.view addSubview:menu1];
// ----------------------- menu2 ---------------------------
menu2 = [[LMJDropdownMenu alloc] init];
menu2.frame = self.sendTokenTextField.frame;
menu2.dataSource = self;
menu2.delegate = self;
menu2.layer.borderColor = [UIColor whiteColor].CGColor;
menu2.layer.borderWidth = 1;
menu2.layer.cornerRadius = 3;
menu2.title = @"接收人2a956beb4a21a4b98c42384f3534ee08";
menu2.titleBgColor = menu1.titleBgColor;
menu2.titleFont = [UIFont boldSystemFontOfSize:12];
menu2.titleColor = [UIColor whiteColor];
menu2.titleAlignment = NSTextAlignmentLeft;
menu2.titleEdgeInsets = UIEdgeInsetsMake(0, 15, 0, 0);
// menu2.rotateIcon = [UIImage imageNamed:@"arrowIcon3"];
// menu2.rotateIconSize = CGSizeMake(15, 15);
menu2.optionBgColor = menu1.optionBgColor;
menu2.optionFont = [UIFont systemFontOfSize:12];
menu2.optionTextColor = [UIColor blackColor];
menu2.optionTextAlignment = NSTextAlignmentLeft;
menu2.optionNumberOfLines = 0;
menu2.optionLineColor = [UIColor whiteColor];
menu2.optionIconSize = CGSizeMake(15, 15);
[self.view addSubview:menu2];
}
//压力测试
-(void)loop{
NSString *randomStr = [NSString stringWithFormat:@"zyj%d",arc4random_uniform(1000000)];
[[OffcnIMSDKiOS defaultService] sendMsgWithMsg_fromID:self.fromId msg_toID:self.toId msg_type:OffcnSDKMsgTypeText text:randomStr filePath:nil Finished:^(BOOL success, OffcnIMSendMsgModel *sendMsgModel, NSString *errorMessage) {
NSString *randomStr = [NSString stringWithFormat:@"ZYJ1%d",arc4random_uniform(1000000)];
[[OffcnIMSDKiOS defaultService] sendMsgWithMsg_fromID:self.fromId msg_toID:self.toId msg_type:OffcnSDKMsgTypeText text:randomStr filePath:nil ext:@"123" Finished:^(BOOL success, OffcnIMBodyModel *sendMsgModel, NSString *errorMessage) {
if (success) {
NSLog(@"发送消息成功,消息:%@",randomStr);
......@@ -91,6 +182,8 @@
__weak typeof(self) weakSelf = self;
[OffcnIMSocketManager defaultService].connectReceiveMessage = ^(OffcnIMModel *IMModel) {
NSLog(@"收到消息---%@,时间:%@",IMModel.body.msg.msg,IMModel.body.send_time);
self.msg_seq = IMModel.body.msg_seq;
NSString *msg = @"";
if (IMModel.body.msg_type == 1) {
msg = [msg stringByAppendingString:IMModel.body.msg.msg?IMModel.body.msg.msg:@"nil"];
......@@ -98,25 +191,38 @@
msg = [msg stringByAppendingString:IMModel.body.msg.url?IMModel.body.msg.url:@"nil"];
}
//进入后台正常连接socket,使用此方法本地推送接受到的消息
[[OffcnIMSocketManager defaultService] manualSendLocalNotificationWithModel:IMModel];
// [weakSelf tipMessageWithTitle:@"收到消息" message:msg];
msg = [NSString stringWithFormat:@"%@,未读数%ld,拓展内容:%@",msg,(long)IMModel.body.unread_number,IMModel.body.ext];
if ([IMModel.body.msg_from isEqualToString:[OffcnIMSocketManager defaultService].msg_fromId]) {
[weakSelf tipMessageWithTitle:@"通道发送消息" message:msg];
}else{
[weakSelf tipMessageWithTitle:@"收到消息" message:msg];
}
};
//收到连接状态回调
[OffcnIMSocketManager defaultService].connectStatus = ^(OffcnIMConnectStatus status, NSString * _Nonnull errorMessage) {
NSLog(@"收到连接状态---%@,code:%lu,%@",errorMessage,(unsigned long)status,[weakSelf getNowSSSTimeTimestamp]);
if (status == OffcnIMConnectStatusDisConnectOK) {
errorMessage = @"断开连接成功";
}else if (status == OffcnIMConnectStatusSuccess){
errorMessage = @"连接成功";
errorMessage = @"主动断开连接成功";
}else if (status == OffcnIMConnectStatusFail){
errorMessage = @"连接失败,请重新连接";
// errorMessage = @"连接失败,请重新连接";
dispatch_async(dispatch_get_main_queue(), ^{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"连接失败,请重新连接" message:errorMessage delegate:weakSelf cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
[alert show];
});
}else if (status == OffcnIMConnectStatusBreak){
errorMessage = @"连接断开,请重新连接";
// errorMessage = @"连接断开,请重新连接";
dispatch_async(dispatch_get_main_queue(), ^{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"连接失败,请重新连接" message:errorMessage delegate:weakSelf cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
[alert show];
});
}else if (status == OffcnIMConnectStatusKickout){
errorMessage = @"被挤掉";
}else if (status == OffcnIMConnectStatusReconnect_success || status == OffcnIMConnectStatusSuccess){
//标记消息已读接口传最后一条消息时序,再获取未读消息接口,这样保持断开重连后消息的连续性
errorMessage = @"连接成功";
}
[weakSelf tipMessageWithTitle:@"收到连接状态" message:errorMessage];
};
}
......@@ -139,15 +245,21 @@
//断开连接
[[OffcnIMSocketManager defaultService] disConnectIMServer];
}
//退出当前会话
- (IBAction)sendMegAction:(UIButton *)sender {
//暂无
[self tipMessageWithTitle:@"暂无此功能" message:@""];
[[OffcnIMSocketManager defaultService] joinSessionWithSession_fromId:@"" session_toId:@"" callBack:^(NSInteger unread_number, NSString * _Nonnull fromUser, NSString * _Nonnull toUser) {
}];
}
//发送本地通知
//进入当前会话
- (IBAction)sendLocalNotiAction:(UIButton *)sender {
//暂无
[self tipMessageWithTitle:@"暂无此功能" message:@""];
__weak typeof(self) weakSelf = self;
[[OffcnIMSocketManager defaultService] joinSessionWithSession_fromId:self.fromId session_toId:self.toId callBack:^(NSInteger unread_number, NSString * _Nonnull fromUser, NSString * _Nonnull toUser) {
[weakSelf tipMessageWithTitle:@"进入当前会话" message:@"未读数清0"];
}];
}
- (IBAction)sendMeg:(UIButton *)sender {
......@@ -157,10 +269,19 @@
return;
}
__weak typeof(self) weakSelf = self;
[[OffcnIMSDKiOS defaultService] sendMsgWithMsg_fromID:self.fromId msg_toID:self.toId msg_type:OffcnSDKMsgTypeText text:self.megTextField.text filePath:nil Finished:^(BOOL success, OffcnIMSendMsgModel *sendMsgModel, NSString *errorMessage) {
[[OffcnIMSDKiOS defaultService] sendMsgWithMsg_fromID:self.fromId msg_toID:self.toId msg_type:OffcnSDKMsgTypeText text:self.megTextField.text filePath:nil ext:@"123" Finished:^(BOOL success, OffcnIMBodyModel *sendMsgModel, NSString *errorMessage) {
if (success) {
[weakSelf tipMessageWithTitle:@"发送消息成功" message:@""];
NSString *msg = @"";
if (sendMsgModel.msg_type == 1) {
msg = [msg stringByAppendingString:sendMsgModel.msg.msg?sendMsgModel.msg.msg:@"nil"];
}else{
msg = [msg stringByAppendingString:sendMsgModel.msg.url?sendMsgModel.msg.url:@"nil"];
}
NSString *allmsg = [NSString stringWithFormat:@"%@,拓展内容:%@",msg,sendMsgModel.ext];
[weakSelf tipMessageWithTitle:@"接口发送消息" message:allmsg];
// [weakSelf tipMessageWithTitle:@"发送消息成功" message:@""];
}else{
[weakSelf tipMessageWithTitle:@"发送消息失败" message:errorMessage];
}
......@@ -175,9 +296,14 @@
[[OffcnIMSDKiOS defaultService] getSessionUnreadMsgWithFromID:self.fromId toID:self.toId Finished:^(BOOL success, OffcnIMUnreadMsgModel *unreadMsgModel, NSString *errorMessage) {
if (success) {
NSString *msg = @"";
NSString *content = @"";
for (int i=0; i<unreadMsgModel.msg_list.count; i++) {
OffcnIMBodyModel *model = unreadMsgModel.msg_list[i];
NSString *sender = [NSString stringWithFormat:@"发送人ID:%@",model.msg_from];
NSString *rever = [NSString stringWithFormat:@"接收人ID:%@",model.msg_to];
NSString *time = [NSString stringWithFormat:@"时间:%@",model.send_time];
NSString *msg = @"";
if (model.msg_type == 1) {
//文本消息
msg = [msg stringByAppendingString:model.msg.msg?model.msg.msg:@"nil"];
......@@ -186,12 +312,15 @@
msg = [msg stringByAppendingString:model.msg.url?model.msg.url:@"nil"];
}
msg = [msg stringByAppendingString:@"\r\n"];
msg = [msg stringByAppendingString:@"\r\n"];
NSString *allmsg = [NSString stringWithFormat:@"%@,%@,%@,消息:%@,拓展内容:%@",sender,rever,time,msg,model.ext];
content = [content stringByAppendingString:allmsg];
content = [content stringByAppendingString:@"\r\n"];
content = [content stringByAppendingString:@"\r\n"];
}
OffcnZYJTestDataStorageView *storageView = [[OffcnZYJTestDataStorageView alloc] initWithFrame:CGRectMake(0, 20, self.view.bounds.size.width, self.view.bounds.size.height-20)];
storageView.msg = msg;
OffcnZYJ1TestDataStorageView *storageView = [[OffcnZYJ1TestDataStorageView alloc] initWithFrame:CGRectMake(0, 20, self.view.bounds.size.width, self.view.bounds.size.height-20)];
storageView.msg = content;
[storageView showView];
}else{
[weakSelf tipMessageWithTitle:@"获取会话未读消息列表失败" message:errorMessage];
......@@ -201,7 +330,7 @@
- (IBAction)readedAction:(UIButton *)sender {
//用户信息标记已读
__weak typeof(self) weakSelf = self;
[[OffcnIMSDKiOS defaultService] markMsgReadWithMsg_fromID:self.fromId msg_toID:self.toId msg_seq:1599222612718 Finished:^(BOOL success, id response, NSString *errorMessage) {
[[OffcnIMSDKiOS defaultService] markMsgReadWithMsg_fromID:self.fromId msg_toID:self.toId msg_seq:self.msg_seq Finished:^(BOOL success, id response, NSString *errorMessage) {
if (success) {
[weakSelf tipMessageWithTitle:@"标记已读成功" message:@""];
}else{
......@@ -215,24 +344,31 @@
[[OffcnIMSDKiOS defaultService] getRecentSessionsWithAccid:self.fromId Finished:^(BOOL success, OffcnIMRecentMsgModel *recentMsgModel, NSString *errorMessage) {
if (success) {
NSString *msg = @"";
NSString *content = @"";
for (int i=0; i<recentMsgModel.sessions.count; i++) {
OffcnIMSessionModel *model = recentMsgModel.sessions[i];
NSString *sender = [NSString stringWithFormat:@"发送人ID:%@",model.last_msg.msg_from];
NSString *rever = [NSString stringWithFormat:@"接收人ID:%@",model.last_msg.msg_to];
NSString *time = [NSString stringWithFormat:@"时间:%@",model.last_msg.send_time];
NSString *msg = @"";
if (model.last_msg.msg_type == 1) {
//文本消息
msg = [msg stringByAppendingString:model.last_msg.msg_content.msg?model.last_msg.msg_content.msg:@"nil"];
msg = [msg stringByAppendingString:model.last_msg.msg.msg?model.last_msg.msg.msg:@"nil"];
}else{
//非文本消息
msg = [msg stringByAppendingString:model.last_msg.msg_content.url?model.last_msg.msg_content.url:@"nil"];
msg = [msg stringByAppendingString:model.last_msg.msg.url?model.last_msg.msg.url:@"nil"];
}
msg = [msg stringByAppendingString:@"\r\n"];
msg = [msg stringByAppendingString:@"\r\n"];
NSString *allmsg = [NSString stringWithFormat:@"%@,%@,%@,消息:%@,未读数:%ld,拓展内容:%@",sender,rever,time,msg,(long)model.unread_number,model.last_msg.ext];
content = [content stringByAppendingString:allmsg];
content = [content stringByAppendingString:@"\r\n"];
content = [content stringByAppendingString:@"\r\n"];
}
OffcnZYJTestDataStorageView *storageView = [[OffcnZYJTestDataStorageView alloc] initWithFrame:CGRectMake(0, 20, self.view.bounds.size.width, self.view.bounds.size.height-20)];
storageView.msg = msg;
OffcnZYJ1TestDataStorageView *storageView = [[OffcnZYJ1TestDataStorageView alloc] initWithFrame:CGRectMake(0, 20, self.view.bounds.size.width, self.view.bounds.size.height-20)];
storageView.msg = content;
[storageView showView];
}else{
[weakSelf tipMessageWithTitle:@"获取用户最近会话记录失败" message:errorMessage];
......@@ -245,9 +381,14 @@
[[OffcnIMSDKiOS defaultService] getSessionHistoryMsgWithFromID:self.fromId toID:self.toId msg_seq:@"" Finished:^(BOOL success, OffcnIMHistoryMsgModel *historyMsgModel, NSString *errorMessage) {
if (success) {
NSString *msg = @"";
NSString *content = @"";
for (int i=0; i<historyMsgModel.msg_list.count; i++) {
OffcnIMBodyModel *model = historyMsgModel.msg_list[i];
NSString *sender = [NSString stringWithFormat:@"发送人ID:%@",model.msg_from];
NSString *rever = [NSString stringWithFormat:@"接收人ID:%@",model.msg_to];
NSString *time = [NSString stringWithFormat:@"时间:%@",model.send_time];
NSString *msg = @"";
if (model.msg_type == 1) {
//文本消息
msg = [msg stringByAppendingString:model.msg.msg?model.msg.msg:@"nil"];
......@@ -256,12 +397,15 @@
msg = [msg stringByAppendingString:model.msg.url?model.msg.url:@"nil"];
}
msg = [msg stringByAppendingString:@"\r\n"];
msg = [msg stringByAppendingString:@"\r\n"];
NSString *allmsg = [NSString stringWithFormat:@"%@,%@,%@,消息:%@,拓展内容:%@",sender,rever,time,msg,model.ext];
content = [content stringByAppendingString:allmsg];
content = [content stringByAppendingString:@"\r\n"];
content = [content stringByAppendingString:@"\r\n"];
}
OffcnZYJTestDataStorageView *storageView = [[OffcnZYJTestDataStorageView alloc] initWithFrame:CGRectMake(0, 20, self.view.bounds.size.width, self.view.bounds.size.height-20)];
storageView.msg = msg;
OffcnZYJ1TestDataStorageView *storageView = [[OffcnZYJ1TestDataStorageView alloc] initWithFrame:CGRectMake(0, 20, self.view.bounds.size.width, self.view.bounds.size.height-20)];
storageView.msg = content;
[storageView showView];
}else{
[weakSelf tipMessageWithTitle:@"获取会话历史消息列表失败" message:errorMessage];
......@@ -269,28 +413,68 @@
}];
}
- (IBAction)registeredUser:(UIButton *)sender {
//注册用户设备
[OffcnIMPushManager registerOffcnUserNotificationSettingsWithApplication:[UIApplication sharedApplication] options:[NSDictionary dictionary]];
__weak typeof(self) weakSelf = self;
[[OffcnIMSDKiOS defaultService] registerDevicesWithAccid:self.fromId device_token:[OffcnIMSDKiOS defaultService].deviceToken Finished:^(BOOL success, id response, NSString *errorMessage) {
if (success) {
[weakSelf tipMessageWithTitle:@"注册用户设备成功" message:@""];
AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
appDelegate.deviceTokenCallback = ^{
NSString *oldFromId = [[NSUserDefaults standardUserDefaults] valueForKey:kOffcnIMSDKiOS_fromid];
NSString *oldToken = [[NSUserDefaults standardUserDefaults] valueForKey:kOffcnIMSDKiOS_token];
if (oldFromId) {
[[OffcnIMSDKiOS defaultService] unregisterDevicesWithAccid:oldFromId device_token:oldToken Finished:^(BOOL success, id response, NSString *errorMessage) {
if (success) {
[weakSelf tipMessageWithTitle:@"注销推送成功" message:@""];
//注册推送
[[OffcnIMSDKiOS defaultService] registerDevicesWithAccid:self.fromId device_token:[OffcnIMSDKiOS defaultService].deviceToken Finished:^(BOOL success, id response, NSString *errorMessage) {
if (success) {
[[NSUserDefaults standardUserDefaults] setValue:self.fromId forKey:kOffcnIMSDKiOS_fromid];
[[NSUserDefaults standardUserDefaults] setValue:[OffcnIMSDKiOS defaultService].deviceToken forKey:kOffcnIMSDKiOS_token];
[[NSUserDefaults standardUserDefaults] synchronize];
[weakSelf tipMessageWithTitle:@"注册推送成功" message:@""];
}else{
[weakSelf tipMessageWithTitle:@"注册推送失败" message:errorMessage];
}
}];
}else{
[weakSelf tipMessageWithTitle:@"注销推送失败" message:errorMessage];
}
}];
}else{
[weakSelf tipMessageWithTitle:@"注册用户设备失败" message:errorMessage];
//注册推送
[[OffcnIMSDKiOS defaultService] registerDevicesWithAccid:self.fromId device_token:[OffcnIMSDKiOS defaultService].deviceToken Finished:^(BOOL success, id response, NSString *errorMessage) {
if (success) {
[[NSUserDefaults standardUserDefaults] setValue:self.fromId forKey:kOffcnIMSDKiOS_fromid];
[[NSUserDefaults standardUserDefaults] setValue:[OffcnIMSDKiOS defaultService].deviceToken forKey:kOffcnIMSDKiOS_token];
[[NSUserDefaults standardUserDefaults] synchronize];
[weakSelf tipMessageWithTitle:@"注册推送成功" message:@""];
}else{
[weakSelf tipMessageWithTitle:@"注册推送失败" message:errorMessage];
}
}];
}
}];
};
}
- (IBAction)UnRegisteredUser:(UIButton *)sender {
//注销用户设备
//注销推送
[OffcnIMPushManager unregisterForOffcnUserRemoteNotifications];
__weak typeof(self) weakSelf = self;
[[OffcnIMSDKiOS defaultService] unregisterDevicesWithAccid:self.fromId device_token:[OffcnIMSDKiOS defaultService].deviceToken Finished:^(BOOL success, id response, NSString *errorMessage) {
NSString *oldFromId = [[NSUserDefaults standardUserDefaults] valueForKey:kOffcnIMSDKiOS_fromid];
NSString *oldToken = [[NSUserDefaults standardUserDefaults] valueForKey:kOffcnIMSDKiOS_token];
[[OffcnIMSDKiOS defaultService] unregisterDevicesWithAccid:oldFromId device_token:oldToken Finished:^(BOOL success, id response, NSString *errorMessage) {
if (success) {
[weakSelf tipMessageWithTitle:@"注销用户设备成功" message:@""];
[weakSelf tipMessageWithTitle:@"注销推送成功" message:@""];
}else{
[weakSelf tipMessageWithTitle:@"注销用户设备失败" message:errorMessage];
[weakSelf tipMessageWithTitle:@"注销推送失败" message:errorMessage];
}
}];
}
-(void)appWillTerminate{
// [self UnRegisteredUser:nil];
}
- (IBAction)getImage:(UIButton *)sender {
//获取相册图片
[self gotoImageLibrary];
......@@ -300,7 +484,7 @@
//上传
__weak typeof(self) weakSelf = self;
NSString *filePath = [self getImagePath:self.pickImage];
[[OffcnIMSDKiOS defaultService] sendMsgWithMsg_fromID:self.fromId msg_toID:self.toId msg_type:OffcnSDKMsgTypePicture text:nil filePath:filePath Finished:^(BOOL success, OffcnIMSendMsgModel *sendMsgModel, NSString *errorMessage) {
[[OffcnIMSDKiOS defaultService] sendMsgWithMsg_fromID:self.fromId msg_toID:self.toId msg_type:OffcnSDKMsgTypePicture text:nil filePath:filePath ext:@"123" Finished:^(BOOL success, OffcnIMBodyModel *sendMsgModel, NSString *errorMessage) {
if (success) {
[weakSelf tipMessageWithTitle:@"上传成功" message:@""];
......@@ -314,9 +498,9 @@
}
- (IBAction)uploadFile:(UIButton *)sender {
NSString *path = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES).firstObject;
NSString *filePath = [path stringByAppendingPathComponent:@"ZYJFMDBIMChat.db"];
NSString *filePath = [path stringByAppendingPathComponent:@"ZYJ1FMDBIMChat.db"];
__weak typeof(self) weakSelf = self;
[[OffcnIMSDKiOS defaultService] sendMsgWithMsg_fromID:self.fromId msg_toID:self.toId msg_type:OffcnSDKMsgTypeFile text:nil filePath:filePath Finished:^(BOOL success, OffcnIMSendMsgModel *sendMsgModel, NSString *errorMessage) {
[[OffcnIMSDKiOS defaultService] sendMsgWithMsg_fromID:self.fromId msg_toID:self.toId msg_type:OffcnSDKMsgTypeFile text:nil filePath:filePath ext:@"123" Finished:^(BOOL success, OffcnIMBodyModel *sendMsgModel, NSString *errorMessage) {
if (success) {
[weakSelf tipMessageWithTitle:@"上传成功" message:@""];
......@@ -338,6 +522,13 @@
}
}
//查看数据库
- (IBAction)lookDatabase:(UIButton *)sender {
OffcnIMSqliteTestVC *SqliteTestVC = [[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"OffcnIMSqliteTestVC"];
SqliteTestVC.fromId = self.fromId;
SqliteTestVC.toId = self.toId;
[self.navigationController pushViewController:SqliteTestVC animated:YES];
}
#pragma mark UIImagePickerControllerDelegate
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary<UIImagePickerControllerInfoKey, id> *)info {
......@@ -391,10 +582,14 @@
}
-(void)tipMessageWithTitle:(NSString *)title message:(NSString *)message{
__weak typeof(self) weakSelf = self;
dispatch_async(dispatch_get_main_queue(), ^{
[weakSelf.view endEditing:YES];
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:title message:message delegate:weakSelf cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
NSString *msg = [NSString stringWithFormat:@"%@:%@",title,message];
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:title message:msg delegate:weakSelf cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
[alert show];
});
}
......@@ -416,4 +611,71 @@
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#pragma mark - LMJDropdownMenu DataSource
- (NSUInteger)numberOfOptionsInDropdownMenu:(LMJDropdownMenu *)menu{
if (menu == menu1) {
return _menu1OptionTitles.count;
} else if (menu == menu2) {
return _menu2OptionTitles.count;
} else {
return 0;
}
}
- (CGFloat)dropdownMenu:(LMJDropdownMenu *)menu heightForOptionAtIndex:(NSUInteger)index{
if (menu == menu1) {
return 40;
} else if (menu == menu2) {
return 40;
} else {
return 0;
}
}
- (NSString *)dropdownMenu:(LMJDropdownMenu *)menu titleForOptionAtIndex:(NSUInteger)index{
if (menu == menu1) {
return _menu1OptionTitles[index];
} else if (menu == menu2) {
return _menu2OptionTitles[index];
} else {
return @"";
}
}
#pragma mark - LMJDropdownMenu Delegate
- (void)dropdownMenu:(LMJDropdownMenu *)menu didSelectOptionAtIndex:(NSUInteger)index optionTitle:(NSString *)title{
if (menu == menu1) {
self.sendIDTextField.text = _menu1OptionTitles[index];
self.sendTokenTextField.text = _menu1TokenOptionTitles[index];
self.senderLab.text = [NSString stringWithFormat:@"发送人:%@",_nameOptionTitles[index]];
// NSLog(@"你选择了(you selected):menu1,index: %ld - title: %@", index, title);
} else if (menu == menu2) {
self.recvIDTextField.text = _menu2OptionTitles[index];
self.revLab.text = [NSString stringWithFormat:@"接收人:%@",_nameOptionTitles[index]];
// NSLog(@"你选择了(you selected):menu2,index: %ld - title: %@", index, title);
}
self.fromId = [self.sendIDTextField.text stringByReplacingOccurrencesOfString:@"发送人" withString:@""];
self.toId = [self.recvIDTextField.text stringByReplacingOccurrencesOfString:@"接收人" withString:@""];
menu2.hidden = NO;
}
- (void)dropdownMenuWillShow:(LMJDropdownMenu *)menu{
if (menu == menu1) {
menu2.hidden = YES;
} else if (menu == menu2) {
}
}
- (void)dropdownMenuDidHidden:(LMJDropdownMenu *)menu{
if (menu == menu1) {
menu2.hidden = NO;
} else if (menu == menu2) {
}
}
- (void)dealloc {
NSNotificationCenter *defaultCenter = [NSNotificationCenter defaultCenter];
[defaultCenter removeObserver:self name:UIApplicationWillTerminateNotification object:nil];
}
@end
......@@ -5,6 +5,9 @@ platform :ios, '8.0'
target 'OffcnIMSDKiOS_Example' do
pod 'OffcnIMSDKiOS', :path => '../'
pod 'LMJDropdownMenu'
target 'OffcnIMSDKiOS_Tests' do
inherit! :search_paths
......
......@@ -8,7 +8,7 @@
Pod::Spec.new do |s|
s.name = 'OffcnIMSDKiOS'
s.version = '1.0.0.0'
s.version = '1.0.0.1'
s.summary = 'OffcnIMSDKiOS.'
s.description = <<-DESC
......
......@@ -30,6 +30,7 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic,copy)NSString *msg_to;//接受消息的用户id
@property (nonatomic,assign)NSInteger msg_type;//消息类型
@property (nonatomic,strong)OffcnIMMsgModel *msg;//消息内容
@property (nonatomic,copy)NSString *ext;//开发者扩展字段
//以下数据库使用
@property (nonatomic,assign)NSInteger isSentSuccess;//是否发送成功
......@@ -39,6 +40,7 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic,copy)NSString *lastSendtime;//最后一条消息时间
@property (nonatomic,copy)NSString *tid;//本地的消息Id
@property (nonatomic,assign)NSInteger unread_number;//未读数
@property (nonatomic,assign)BOOL isJoinSession;//进入会话未读数为0
@end
@interface OffcnIMMsgModel : NSObject
......@@ -93,7 +95,8 @@ NS_ASSUME_NONNULL_BEGIN
@interface OffcnIMLast_msgModel : NSObject
@property (nonatomic,strong)OffcnIMMsgModel *msg_content;//消息内容
@property (nonatomic,copy)NSString *ext;//开发者扩展字段
@property (nonatomic,strong)OffcnIMMsgModel *msg;//消息内容
@property (nonatomic,assign)NSInteger msg_type;//消息类型
@property (nonatomic,copy)NSString *send_time;//时间
@property (nonatomic,copy)NSString *session_id; //会话ID
......
......@@ -7,20 +7,26 @@
//
#import <UIKit/UIKit.h>
#import "OffcnIMModel.h"
NS_ASSUME_NONNULL_BEGIN
@interface OffcnIMPushManager : NSObject
//注册通知
//注册系统推送
+(void)registerOffcnUserNotificationSettingsWithApplication:(UIApplication *)application options:(NSDictionary *)launchOptions;
//注销系统推送
+(void)unregisterForOffcnUserRemoteNotifications;
//解析deviceToken
+(NSString *)hexStringForData:(NSData *)data;
//收到通知
+(void)didReceiveRemoteNotification:(NSDictionary *)userInfo;
//收到远端推送
+(void)didReceiveRemoteNotification:(NSDictionary *)userInfo Finished:(void(^)(OffcnIMPushModel *IMPushModel))finished;
//收到本地推送
+(void)didReceiveLocalNotification:(NSDictionary *)userInfo Finished:(void(^)(OffcnIMModel *IMLocalPushModel))finished;
@end
NS_ASSUME_NONNULL_END
......
......@@ -9,7 +9,7 @@
#import <UIKit/UIKit.h>
#import "OffcnIMModel.h"
static const NSString *OffcnIMSDKiOSVersion = @"1.0.0.0";
static const NSString *OffcnIMSDKiOSVersion = @"1.0.0.1";
typedef NS_ENUM(NSUInteger, OffcnSDKReachabilityStatus) {
OffcnSDKReachabilityStatusNotReachable = 0,
......@@ -64,8 +64,9 @@ typedef void(^OffcnSDKReachabilityStatusCallBack)(OffcnSDKReachabilityStatus sta
/// @param msg_type 发送消息类型
/// @param text 文本
/// @param filePath 图片/音频(语音消息格式,只能是aac格式)/视频/文件,沙盒路径
/// @param ext 开发者扩展字段
/// @param finished 结果回调
-(void)sendMsgWithMsg_fromID:(NSString *)msg_fromID msg_toID:(NSString *)msg_toID msg_type:(OffcnSDKMsgType)msg_type text:(NSString *)text filePath:(NSString *)filePath Finished:(void(^)(BOOL success,OffcnIMSendMsgModel *sendMsgModel,NSString *errorMessage))finished ProgressPercent:(void(^)(NSString *key, float percent))progressPercent;
-(void)sendMsgWithMsg_fromID:(NSString *)msg_fromID msg_toID:(NSString *)msg_toID msg_type:(OffcnSDKMsgType)msg_type text:(NSString *)text filePath:(NSString *)filePath ext:(NSString *)ext Finished:(void(^)(BOOL success,OffcnIMBodyModel *sendMsgModel,NSString *errorMessage))finished ProgressPercent:(void(^)(NSString *key, float percent))progressPercent;
/// 用户信息标记已读
/// @param msg_fromID 发送人ID
......@@ -92,13 +93,13 @@ typedef void(^OffcnSDKReachabilityStatusCallBack)(OffcnSDKReachabilityStatus sta
/// @param finished 结果回调
-(void)getSessionHistoryMsgWithFromID:(NSString *)fromID toID:(NSString *)toID msg_seq:(NSString *)msg_seq Finished:(void(^)(BOOL success,OffcnIMHistoryMsgModel *historyMsgModel,NSString *errorMessage))finished;
/// 注册用户设备
/// 接口注册推送
/// @param accid 用户ID
/// @param device_token 设备Token
/// @param finished 结果回调
-(void)registerDevicesWithAccid:(NSString *)accid device_token:(NSString *)device_token Finished:(void(^)(BOOL success,id response,NSString *errorMessage))finished;
/// 注销用户设备
/// 接口注销推送
/// @param accid 用户ID
/// @param device_token 设备Token
/// @param finished 结果回调
......
......@@ -16,10 +16,15 @@ typedef NS_ENUM(NSUInteger, OffcnIMConnectStatus) {
OffcnIMConnectStatusFail = 1, //连接失败
OffcnIMConnectStatusBreak = 2, //连接断开
OffcnIMConnectStatusDisConnectOK = 3, //手动断开成功
OffcnIMConnectStatusReconnect_start = 4, //开始重连
OffcnIMConnectStatusReconnect_success = 5, //重连成功
OffcnIMConnectStatusReconnect_fail = 6, //重连失败
OffcnIMConnectStatusOverLimit = 3001, //连接数量超过限制
OffcnIMConnectStatusUserNoExist = 5002, //用户不存在
OffcnIMConnectStatusTokenInvalid = 5003, //token已失效
OffcnIMConnectStatusKickout = 8003, //账号被踢
OffcnIMConnectStatusKickout = 8002, //账号被踢
};
//收到消息回调
......@@ -33,6 +38,7 @@ typedef void(^OffcnIMReceiveConnectStatus)(OffcnIMConnectStatus status,NSString
@property (nonatomic, copy) NSString *msg_fromId;//发送消息的用户id
@property (nonatomic, copy) NSString *token;//发送消息的用户token
@property (nonatomic, assign) BOOL isManualDisconnect;//是手动断开的连接
@property (nonatomic, assign) OffcnIMConnectStatus IMConnectStatus;//连接状态
......@@ -43,9 +49,16 @@ typedef void(^OffcnIMReceiveConnectStatus)(OffcnIMConnectStatus status,NSString
//连接状态回调
@property (nonatomic, copy) OffcnIMReceiveConnectStatus connectStatus;
@property (nonatomic, strong) NSMutableArray *msgArr;//防止重复msg_id缓存池
//单例
+(OffcnIMSocketManager *)defaultService;
/// 进入一个会话需要传入当前会话的参数
/// @param session_fromId 当前会话发送消息的用户id
/// @param session_toId 当前会话接收消息的用户id
-(void)joinSessionWithSession_fromId:(NSString *)session_fromId session_toId:(NSString *)session_toId callBack:(void(^)(NSInteger unread_number,NSString *fromUser,NSString *toUser))numberBack;
/// 建立连接
/// @param account_id 用户ID
/// @param token 用户token
......
//
// OffcnIMZYJFMDBHandler.h
// OffcnIMZYJ1FMDBHandler.h
// OffcnIMSDKiOS
//
// Created by vockey on 2019/4/9.
......@@ -20,10 +20,10 @@ typedef void (^getFMDBOneMessageBlock)(OffcnIMBodyModel *model);
typedef void (^callBackIsSuccess)(BOOL isSuccess);
@interface OffcnIMZYJFMDBHandler : NSObject
@interface OffcnIMZYJ1FMDBHandler : NSObject
//单例
+ (OffcnIMZYJFMDBHandler *)sharedInstance;
+ (OffcnIMZYJ1FMDBHandler *)sharedInstance;
//获取用户相关数据库,该方法在登陆或者第一次启动已登陆下执行
- (void)getUserDB;
......@@ -45,8 +45,10 @@ typedef void (^callBackIsSuccess)(BOOL isSuccess);
//更新和某个用户所有聊天为已读状态
- (void)updateChatInfoIsRead:(OffcnIMBodyModel *)model callBack:(callBackIsSuccess)isSuccess;
//更新和某个用户的聊天未读数
- (void)updateChatListUnread_number:(OffcnIMBodyModel *)model callBack:(callBackIsSuccess)isSuccess;
//更新和某个用户的聊天和未读数
- (void)updateChatListUnread_number:(OffcnIMBodyModel *)model callBack:(getFMDBOneMessageBlock)messagesBack;
//更新和某个用户的未读数
- (void)updateChatListOnlyUnread_number:(NSInteger)unread_number fromUser:(NSString *)fromUser toUser:(NSString *)toUser callBack:(void(^)(NSInteger unread_number,NSString *fromUser,NSString *toUser))numberBack;
/// 删除个人聊天记录
/// @param fromUser 发送人ID
......@@ -74,6 +76,10 @@ typedef void (^callBackIsSuccess)(BOOL isSuccess);
//查询聊天列表其中一个会话信息
- (void)getChatListOneMessageWithFromUser:(NSString *)fromUser toUser:(NSString *)toUser callback:(getFMDBOneMessageBlock)messagesBack;
//查询某条消息是否存在
- (void)queryAMessageExistsWithMegid:(NSString *)megid callback:(getFMDBHistoryMessagesBlock)messagesBack;
//消息内容
- (NSString *)lastMessage:(OffcnIMBodyModel *)messageModel;
......
......@@ -31,8 +31,8 @@ namespace im
{
typedef enum
{
kMsg_Type_Normal, //正常的聊天消息
kMsg_Type_Recv_Confirm, //收到服务端发来的消息确认消息
kMsg_Type_Normal, //normal message type
kMsg_Type_Recv_Confirm, //client recv message confirm type
}OImMsgType;
typedef enum
......@@ -41,6 +41,10 @@ namespace im
Z_CONN_IM_SRV_FAILED,
Z_CONN_IM_SRV_BROKEN,
Z_DISCONN_IM_SRV_OK,
Z_CONN_IM_SRV_RECONNECT_START, //start reconnect
Z_CONN_IM_SRV_RECONNECT_SUCCESS, //reconnect success
Z_CONN_IM_SRV_RECONNECT_FAILED,
}OImEventCode;
class OImCoreObserver
......
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