iOS 环信透传cmd消息多次重复接收,解决办法

由于项目需求,需要在项目中接到消息的时候做不同界面的不同的操作,哪儿需要哪儿就要添加代理;引起代理事件重复执行;所以要在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];

 

}

 

posted @ 2017-07-12 15:22  徐家汇  阅读(1266)  评论(0编辑  收藏  举报