MessageListViewController.m 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. //
  2. // MessageListViewController.m
  3. // 千模
  4. //
  5. // Created by MUMEI on 2018/6/28.
  6. // Copyright © 2018年 MUMEI. All rights reserved.
  7. //
  8. #import "MessageListViewController.h"
  9. #import "MessageViewController.h"
  10. #import "NTESVideoChatViewController.h"
  11. @interface MessageListViewController ()<NIMNetCallManagerDelegate>
  12. @end
  13. @implementation MessageListViewController
  14. - (void)viewDidLoad {
  15. [super viewDidLoad];
  16. self.navigationItem.title = @"会话";
  17. // [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(tcpConnectStateChange) name:@"reloadUnRead" object:nil];
  18. NIMUser *user = [[NIMSDK sharedSDK].userManager userInfo:[Helper sharedAccount].accid];
  19. NSLog(@"user = %@",user);
  20. // [[NIMKit sharedKit] setProvider:[NTESDataProvider new]];
  21. //
  22. //// [[NIMKit sharedKit] setProvider:[NTESDataProvider new]];
  23. //
  24. // NIMSession *session = [NIMSession session:@"hoong" type:NIMSessionTypeP2P];
  25. // NIMTipObject *object = [[NIMTipObject alloc] init];
  26. //
  27. // NIMMessage *message = [[NIMMessage alloc] init];
  28. // message.messageObject = object;
  29. // message.text = @"可以开始对话了";
  30. // NIMKitInfoFetchOption *option = [[NIMKitInfoFetchOption alloc] init];
  31. // option.session = session;
  32. // NIMKitInfo *info = [[NIMKit sharedKit] infoByUser:@"hoong" option:option];
  33. // // 错误反馈对象
  34. // NSError *error = nil;
  35. // // 发送消息
  36. // [[NIMSDK sharedSDK].chatManager sendMessage:message toSession:session error:&error];
  37. [[NIMAVChatSDK sharedSDK].netCallManager addDelegate:self];
  38. // [[NIMSDK sharedSDK].userManager updateMyUserInfo:@{@(NIMUserInfoUpdateTagAvatar) : [NSString stringWithFormat:@"%@%@",imageURl,user.userInfo.avatarUrl]} completion:nil];
  39. // Do any additional setup after loading the view.
  40. }
  41. - (void)viewWillAppear:(BOOL)animated{
  42. [self changeLoginState:@"1"];
  43. NSInteger count = [[[NIMSDK sharedSDK] conversationManager] allUnreadCount];
  44. self.navigationController.tabBarItem.badgeValue = count ? [NSString stringWithFormat:@"%ld",count] : nil;
  45. }
  46. - (void)tcpConnectStateChange{
  47. NSInteger count = [[[NIMSDK sharedSDK] conversationManager] allUnreadCount];
  48. self.navigationController.tabBarItem.badgeValue = count ? [NSString stringWithFormat:@"%ld",count] : nil;
  49. }
  50. - (void)onLogin:(NIMLoginStep)step{
  51. if (step == NIMLoginStepSyncOK) {
  52. [self.tableView reloadData];
  53. }
  54. }
  55. - (void)changeLoginState:(NSString *)state{
  56. NSString *str = [NSString stringWithFormat:@"%@modelInfo?action=doPutOnline&modelpk=%@&online=%@",imageURl,[ModelUser user].modelpk,state];
  57. [[AHHttpManager sharedManager]POST:str parameters:nil success:^(id responseObject) {
  58. NSLog(@"%@",responseObject);
  59. if ([[responseObject objectForKey:@"msg"]isEqualToString:@"success"]) {
  60. }else{
  61. }
  62. } failure:^(NSError *error) {
  63. NSLog(@"error = %@",error);
  64. }];
  65. }
  66. - (void)didReceiveMemoryWarning {
  67. [super didReceiveMemoryWarning];
  68. // Dispose of any resources that can be recreated.
  69. }
  70. - (void)onSelectedRecent:(NIMRecentSession *)recentSession atIndexPath:(NSIndexPath *)indexPath{
  71. MessageViewController *vc = [[MessageViewController alloc] initWithSession:recentSession.session];
  72. // vc.hidesBottomBarWhenPushed = YES;
  73. [self.navigationController pushViewController:vc animated:YES];
  74. }
  75. //- (void)onReceive:(UInt64)callID from:(NSString *)caller type:(NIMNetCallMediaType)type message:(NSString *)extendMessage{
  76. //
  77. // // NTESMainTabController *tabVC = [NTESMainTabController instance];
  78. // // [tabVC.view endEditing:YES];
  79. // // UINavigationController *nav = tabVC.selectedViewController;
  80. // //
  81. // // if ([self shouldResponseBusy]){
  82. // // [[NIMAVChatSDK sharedSDK].netCallManager control:callID type:NIMNetCallControlTypeBusyLine];
  83. // // }
  84. // // else {
  85. // //
  86. // // if ([self shouldFireNotification:caller]) {
  87. // // NSString *text = [self textByCaller:caller
  88. // // type:type];
  89. // // [_notifier start:text];
  90. // // }
  91. // UIViewController *vc;
  92. // switch (type) {
  93. // case NIMNetCallTypeVideo:{
  94. // vc = [[NTESVideoChatViewController alloc] initWithCaller:caller callId:callID];
  95. // NSLog(@"11111");
  96. //// [self response:NO];
  97. // }
  98. // break;
  99. // case NIMNetCallTypeAudio:{
  100. // // vc = [[NTESAudioChatViewController alloc] initWithCaller:caller callId:callID];
  101. // }
  102. // break;
  103. // default:
  104. // break;
  105. // }
  106. // if (!vc) {
  107. // return;
  108. // }
  109. //
  110. // // 由于音视频聊天里头有音频和视频聊天界面的切换,直接用present的话页面过渡会不太自然,这里还是用push,然后做出present的效果
  111. // // CATransition *transition = [CATransition animation];
  112. // // transition.duration = 0.25;
  113. // // transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionDefault];
  114. // // transition.type = kCATransitionPush;
  115. // // transition.subtype = kCATransitionFromTop;
  116. // // [nav.view.layer addAnimation:transition forKey:nil];
  117. // // nav.navigationBarHidden = YES;
  118. // // if (nav.presentedViewController) {
  119. // // // fix bug MMC-1431
  120. // // [nav.presentedViewController dismissViewControllerAnimated:NO completion:nil];
  121. // // }
  122. // // [nav pushViewController:vc animated:NO];
  123. // // }
  124. //// [self presentViewController:vc
  125. //// animated:YES
  126. //// completion:nil];
  127. // vc.hidesBottomBarWhenPushed = YES;
  128. // [self.navigationController pushViewController:vc animated:NO];
  129. //}
  130. /*
  131. #pragma mark - Navigation
  132. // In a storyboard-based application, you will often want to do a little preparation before navigation
  133. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  134. // Get the new view controller using [segue destinationViewController].
  135. // Pass the selected object to the new view controller.
  136. }
  137. */
  138. @end