iosreact-nativemoengage

MoEngage - React Native UIViewController that is already being presented


After following the instruction on the website, I got this error when I try to build on iOS:

Thread 1: "Application tried to present modally a view controller <UIViewController: 0x7f90684afee0> that is already being presented by <UIViewController: 0x7f906847c320>."

https://i.sstatic.net/7tUUE.png

phone error

Info.plist

<key>MoEngage</key>
<dict>
    <key>MoEngage_APP_ID</key>
    <string>...</string>
</dict>
...

AppDelegate.m

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
...
  // Set Data Center
  [MoEngage setDataCenter:DATA_CENTER_01]; //DATA_CENTER_01, DATA_CENTER_02, OR DATA_CENTER_03
  
  [[MOReactInitializer sharedInstance] intializeSDKWithLaunchOptions:launchOptions];
  
  return YES;
}

Solution

  • I got the issue fixed, for me it's because two lines in the file AppDelegate is putting in wrong position. Make sure these:

      [MoEngage setDataCenter:DATA_CENTER_01]; //DATA_CENTER_01, DATA_CENTER_02, OR DATA_CENTER_03
      
      [[MOReactInitializer sharedInstance] intializeSDKWithLaunchOptions:launchOptions];
    

    are in right position of the (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions function, in my case is to put them right before:

    RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
    RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge
                                                       moduleName:@"finan"
                                                initialProperties:nil];
    
    rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];