由于项目需求,需要在项目中接到消息的时候做不同界面的不同的操作,哪儿需要哪儿就要添加代理;引起代理事件重复执行;所以要在VC显示的时候添加代理,消失的时候删除代理

 

环信 透传 消息多次接收情况(由于代理多次添加,没有取消掉)

在VC将要显示和 消失中 挂代理,删除代理

-(void)viewWillAppear:(BOOL)animated{}

-(void)viewWillDisappear:(BOOL)animated{}

 

#pragma mark - registerNotifications

 

-(void)registerNotifications{

 

    [self unregisterNotifications];

 

    [[EMClient sharedClient].chatManager addDelegate:self delegateQueue:nil];

 

    [[EMClient sharedClient].groupManager addDelegate:self delegateQueue:nil];

 

}

-(void)unregisterNotifications{

 

    [[EMClient sharedClient].chatManager removeDelegate:self];

 

    [[EMClient sharedClient].groupManager removeDelegate:self];

 

}

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-04-17
  • 2022-01-07
  • 2022-12-23
  • 2021-06-14
  • 2022-12-23
猜你喜欢
  • 2021-05-09
  • 2022-12-23
  • 2021-09-09
  • 2021-08-29
  • 2021-10-13
  • 2021-04-23
  • 2022-12-23
相关资源
相似解决方案