Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Warning: Attempt to present <UINavigationController> on <RNNSideMenuController> which is already presenting <RCTModalHostViewController>

I am using in-app-payments-react-native-plugin plugin to integrate Square payment method in react native. In iOS, it's creating an issue if opening a card entry model on Add new card react native popup. I am having a popup to add new credit card details, and getting this warning from the package when calling card entry model inside a popup. It's working on android and also with iOS if not calling from popup screen.

Warning inside Xcode::

Warning: Attempt to present <UINavigationController: 0x7fba6b163400>  on <RNNSideMenuController: 0x7fba6b15fa00> which is already presenting <RCTModalHostViewController: 0x7fba6d798340>

I am using Xcode version "11.0" and react native "0.61.4".

This objective-c code of package generating this warning::

UIViewController *rootViewController = UIApplication.sharedApplication.keyWindow.rootViewController;

if ([rootViewController isKindOfClass:[UINavigationController class]]) {
    [((UINavigationController *)rootViewController) pushViewController:cardEntryForm animated:YES];
} else {
    UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:cardEntryForm];
    [rootViewController presentViewController:navigationController animated:YES completion:nil];
}

Here the if a part is working but if statement generating this warning. I am new to objective c. Please suggest what is a problem occurred here.

like image 361
Archana Sharma Avatar asked Oct 25 '25 06:10

Archana Sharma


1 Answers

Two modals cannot be open at the same time. On iOS, even opening modals consecutively may trigger this. For my case, I closed the first modal, and set a timeout of 500ms before opening the second one. It solved my problem.

like image 156
Js Yau Avatar answered Oct 26 '25 23:10

Js Yau