【问题标题】:MoEngage - React Native UIViewController that is already being presentedMoEngage - React Native UIViewController 已经呈现
【发布时间】:2021-12-29 22:27:37
【问题描述】:

按照网站上的说明,我尝试在 iOS 上构建时遇到此错误:

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

https://i.stack.imgur.com/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;
}

【问题讨论】:

    标签: ios react-native moengage


    【解决方案1】:

    MoEngageSDK 仅在 RichLanding 的情况下呈现 ViewController。上面提到的错误指向了

    react-native-splash-screen

    插件,因为您在 AppDelegate 中调用 [RNSplashScreen show];。所以问题似乎来自react-native-splash-screen插件。

    另外,对于另一个错误。你需要确定

    [[MOReactInitializer sharedInstance] intializeSDKWithLaunchOptions:launchOptions]
    

    正在正确初始化。

    另外,您可以与 moengage 的支持团队联系以解决此问题 https://help.moengage.com/

    【讨论】:

      【解决方案2】:

      我已经解决了这个问题,对我来说这是因为文件AppDelegate 中的两行放在了错误的位置。确保这些:

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

      (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions函数的正确位置,在我的情况下是把它们放在前面:

      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];
      

      【讨论】:

        猜你喜欢
        • 2016-10-20
        • 1970-01-01
        • 1970-01-01
        • 2017-05-24
        • 1970-01-01
        • 2016-08-02
        • 1970-01-01
        • 2015-04-21
        • 1970-01-01
        相关资源
        最近更新 更多