From b469805b2d0c9b23ca020cf9356ff137205f856c Mon Sep 17 00:00:00 2001
From: 464027401@qq.com <464027401@qq.com>
Date: 星期一, 27 九月 2021 10:22:10 +0800
Subject: [PATCH] 修复来点页面重复呼叫时alert位置不对问题

---
 HDLLinPhoneSDK(OC)/HDLLinPhoneSDK/HDLLinPhoneSDK.m |   86 ++++++++++++++++++++++++++++++++++++-------
 1 files changed, 72 insertions(+), 14 deletions(-)

diff --git "a/HDLLinPhoneSDK\357\274\210OC\357\274\211/HDLLinPhoneSDK/HDLLinPhoneSDK.m" "b/HDLLinPhoneSDK\357\274\210OC\357\274\211/HDLLinPhoneSDK/HDLLinPhoneSDK.m"
index 4befa5a..75db80f 100644
--- "a/HDLLinPhoneSDK\357\274\210OC\357\274\211/HDLLinPhoneSDK/HDLLinPhoneSDK.m"
+++ "b/HDLLinPhoneSDK\357\274\210OC\357\274\211/HDLLinPhoneSDK/HDLLinPhoneSDK.m"
@@ -13,7 +13,7 @@
 #import "HDLLPOnMonitorViewController.h"
 
 @interface HDLLinPhoneSDK()
-
+@property (strong, nonatomic) HDLLinphoneIntercomVC* presentingIntercomVC;//褰撳墠灞曠ず鐨勬潵鐐规帶鍒跺櫒锛岀敤浜庡瓨鏀炬鍦ㄥ睍绀虹殑鏉ョ偣鎺у埗鍣紝閬垮厤閲嶅寮瑰嚭鐣岄潰
 @end
 
 @implementation HDLLinPhoneSDK
@@ -70,18 +70,19 @@
     if (state == LinphoneCallIncomingReceived) {
         [self.hdlLinphoneCallDelegate onIncomingCall:userName];
         if(self.IsAutoJumpCallView){
-//                    NSString *callId=[NSString stringWithFormat:@"%@",[notif.userInfo objectForKey:@"callID"]];
-//                    BOOL hasVideo=(BOOL)[notif.userInfo objectForKey:@"hasVideo"];
+
             
-                    HDLLinphoneIntercomVC *vc=[[HDLLinphoneIntercomVC alloc]init];
-//                    vc.CallId=callId;
-                    vc.hasVideo=YES;
-                    vc.hdlLinphoneCallDelegate=self.hdlLinphoneCallDelegate;
-                    vc.modalPresentationStyle = UIModalPresentationFullScreen;
-//                    self.IntercomVC=vc;
-                    [[HDLLinPhoneCommon topMostController] presentViewController:vc animated:YES completion:^{
+//                    HDLLinphoneIntercomVC *vc=[[HDLLinphoneIntercomVC alloc]init];
+////                    vc.CallId=callId;
+//                    vc.hasVideo=YES;
+//                    vc.hdlLinphoneCallDelegate=self.hdlLinphoneCallDelegate;
+//                    vc.modalPresentationStyle = UIModalPresentationFullScreen;
+////                    self.IntercomVC=vc;
+//                    [[HDLLinPhoneCommon topMostController] presentViewController:vc animated:YES completion:^{
+//
+//                    }];
             
-                    }];
+            [self gotoHDLLinphoneIntercomVC:nil];
         }
     }
 }
@@ -114,16 +115,73 @@
     
 //    NSString *callId=[NSString stringWithFormat:@"%@",[notif.userInfo objectForKey:@"callID"]];
 //    BOOL hasVideo=(BOOL)[notif.userInfo objectForKey:@"hasVideo"];
+//    NSLog(@"椤跺眰瑙嗗浘锛�%@",[HDLLinPhoneCommon topMostController]);
+   
+    if ([HDLLinPhoneCommon rootPresentVCContent:[HDLLinphoneIntercomVC class]]||[HDLLinPhoneCommon rootPresentVCContent:[HDLLPOnMonitorViewController class]]) {
+        if ([[HDLLinPhoneCommon topMostController] isKindOfClass:[UIAlertController class]]) {
+            NSLog(@"椤跺眰瑙嗗浘鏄棰戦�氳瘽椤�");
+            __weak typeof(self) weakSelf = self;
+            
+            [[HDLLinPhoneCommon topMostController] dismissViewControllerAnimated:NO completion:^{
+                UIViewController *topVC=[HDLLinPhoneCommon topMostController];
+                if ([topVC isKindOfClass:[HDLLPOnMonitorViewController class]]) {
+                    [topVC dismissViewControllerAnimated:NO completion:^{
+                        [weakSelf toLinphoneIntercomVC:titleName];
+                    }];
+                }else if ([topVC isKindOfClass:[HDLLinphoneIntercomVC class]]) {
+                    [topVC dismissViewControllerAnimated:NO completion:^{
+                        [weakSelf toLinphoneIntercomVC:titleName];
+                    }];
+                }
+            }];
+        }
+//        UIViewController *topVC=[HDLLinPhoneCommon topMostController];
+//        if ([topVC isKindOfClass:[HDLLinphoneIntercomVC class]]) {
+//            [topVC dismissViewControllerAnimated:NO completion:nil];
+//        }
+        return;
+    }
 
+    [self toLinphoneIntercomVC:titleName];
+    
+//    if (self.presentingIntercomVC) {
+//        __weak typeof(self) weakSelf = self;
+//        [self.presentingIntercomVC dismissViewControllerAnimated:NO completion:^{
+//            NSLog(@"椤甸潰閫�鍑轰簡");
+//            weakSelf.presentingIntercomVC=nil;
+//            [weakSelf toLinphoneIntercomVC:titleName];
+//        }];
+//
+//        return;
+//    }
+//    NSLog(@"鎵ц鍒版垜浜�");
+//    [self toLinphoneIntercomVC:titleName];
+//    HDLLinphoneIntercomVC *vc=[[HDLLinphoneIntercomVC alloc]init];
+////    vc.CallId=callId;
+//    vc.hasVideo=YES;
+//    vc.hdlLinphoneCallDelegate=self.hdlLinphoneCallDelegate;
+//    if (titleName) {
+//        vc.titleName=titleName;
+//    }
+//    vc.modalPresentationStyle = UIModalPresentationFullScreen;
+//    self.presentingIntercomVC=vc;
+//    [[HDLLinPhoneCommon topMostController] presentViewController:vc animated:YES completion:^{
+//
+//    }];
+}
+
+-(void)toLinphoneIntercomVC:(NSString*)titleName{
     HDLLinphoneIntercomVC *vc=[[HDLLinphoneIntercomVC alloc]init];
 //    vc.CallId=callId;
     vc.hasVideo=YES;
     vc.hdlLinphoneCallDelegate=self.hdlLinphoneCallDelegate;
-    vc.titleName=titleName;
+    if (titleName) {
+        vc.titleName=titleName;
+    }
     vc.modalPresentationStyle = UIModalPresentationFullScreen;
-//    self.IntercomVC=vc;
+//    self.presentingIntercomVC=vc;
     [[HDLLinPhoneCommon topMostController] presentViewController:vc animated:YES completion:^{
-        
+
     }];
 }
 

--
Gitblit v1.8.0