@@ -156,7 +156,7 @@ - (void)startInviteUsers:(NSArray<NSString*>*)aUsers ext:(NSDictionary*)aExt co
156156 if (weakself.modal .currentCall && weakself.callVC ) {
157157 NSLog (@" inviteUsers in group" );
158158 for (NSString * uId in aUsers) {
159- if ([weakself.modal.currentCall.allUserAccounts.allKeys containsObject: uId])
159+ if ([weakself.modal.currentCall.allUserAccounts.allValues containsObject: uId])
160160 continue ;
161161 [weakself sendInviteMsgToCallee: uId type: weakself.modal.currentCall.callType callId: weakself.modal.currentCall.callId channelName: weakself.modal.currentCall.channelName ext: aExt completion: nil ];
162162 [weakself _startCallTimer: uId];
@@ -296,6 +296,28 @@ - (void)clearRes
296296 self.bNeedSwitchToVoice = NO ;
297297}
298298
299+ -(UIWindow*) getKeyWindow
300+ {
301+ if (@available (iOS 13.0 , *)) {
302+ for (UIWindowScene* scene in [UIApplication sharedApplication ].connectedScenes ) {
303+ if (scene.activationState == UISceneActivationStateForegroundActive) {
304+ if (@available (iOS 15.0 , *)) {
305+ return scene.keyWindow ;
306+ }else {
307+ for (UIWindow* window in scene.windows ) {
308+ if (window.isKeyWindow ) {
309+ return window;
310+ }
311+ }
312+ }
313+ }
314+ }
315+ }else {
316+ return [UIApplication sharedApplication ].keyWindow ;
317+ }
318+ return nil ;
319+ }
320+
299321- (void )refreshUIOutgoing
300322{
301323 if (self.modal .currentCall ) {
@@ -304,7 +326,10 @@ - (void)refreshUIOutgoing
304326 self.callVC = [[EaseCallSingleViewController alloc ] initWithisCaller: self .modal.currentCall.isCaller type: self .modal.currentCall.callType remoteName: self .modal.currentCall.remoteUserAccount];
305327 self.callVC .modalPresentationStyle = UIModalPresentationFullScreen;
306328 __weak typeof (self) weakself = self;
307- UIViewController* rootVC = [[UIApplication sharedApplication ].delegate window ].rootViewController ;
329+ UIWindow* keyWindow = [self getKeyWindow ];
330+ if (!keyWindow)
331+ return ;
332+ UIViewController* rootVC = keyWindow.rootViewController ;
308333 [rootVC presentViewController: self .callVC animated: NO completion: ^{
309334 if (weakself.modal .currentCall .callType == EaseCallType1v1Video)
310335 [weakself setupLocalVideo ];
@@ -319,7 +344,10 @@ - (void)refreshUIAnswering
319344 if (self.modal .currentCall .callType == EaseCallTypeMulti && self.modal .currentCall .isCaller ) {
320345 self.callVC = [[EaseCallMultiViewController alloc ] init ];
321346 self.callVC .modalPresentationStyle = UIModalPresentationFullScreen;
322- UIViewController* rootVC = [[UIApplication sharedApplication ].delegate window ].rootViewController ;
347+ UIWindow* keyWindow = [self getKeyWindow ];
348+ if (!keyWindow)
349+ return ;
350+ UIViewController* rootVC = keyWindow.rootViewController ;
323351 __weak typeof (self) weakself = self;
324352 [rootVC presentViewController: self .callVC animated: NO completion: ^{
325353 [weakself setupLocalVideo ];
@@ -342,7 +370,10 @@ - (void)refreshUIAlerting
342370 self.callVC = [[EaseCallMultiViewController alloc ] init ];
343371 [self getMultiVC ].inviterId = self.modal .currentCall .remoteUserAccount ;
344372 self.callVC .modalPresentationStyle = UIModalPresentationFullScreen;
345- UIViewController* rootVC = [[UIApplication sharedApplication ].delegate window ].rootViewController ;
373+ UIWindow* keyWindow = [self getKeyWindow ];
374+ if (!keyWindow)
375+ return ;
376+ UIViewController* rootVC = keyWindow.rootViewController ;
346377 if (rootVC.presentationController && rootVC.presentationController .presentedViewController )
347378 [rootVC.presentationController.presentedViewController dismissViewControllerAnimated: NO completion: nil ];
348379
@@ -1339,4 +1370,5 @@ - (void)sendVideoToVoiceMsg
13391370{
13401371 [self sendVideoToVoiceMsg: self .modal.currentCall.remoteUserAccount callId: self .modal.currentCall.callId];
13411372}
1373+
13421374@end
0 commit comments