react-native-navigation的迁移库

RNNBridgeModule.m 748B

12345678910111213141516171819202122232425262728293031
  1. #import "RNNBridgeModule.h"
  2. #import "RNN.h"
  3. #import "RNNControllerFactory.h"
  4. @implementation RNNBridgeModule
  5. RCT_EXPORT_MODULE();
  6. - (dispatch_queue_t)methodQueue
  7. {
  8. return dispatch_get_main_queue();
  9. }
  10. RCT_EXPORT_METHOD(setRoot:(NSDictionary*)layout)
  11. {
  12. [self assertReady];
  13. UIApplication.sharedApplication.delegate.window.rootViewController = [[RNNControllerFactory new] createRootViewController:layout];
  14. [UIApplication.sharedApplication.delegate.window makeKeyAndVisible];
  15. }
  16. -(void)assertReady
  17. {
  18. if (!RNN.instance.isReadyToReceiveCommands) {
  19. @throw [NSException exceptionWithName:@"BridgeNotLoadedError" reason:@"Bridge not yet loaded! Send commands after Navigation.events().onAppLaunched() has been called." userInfo:nil];
  20. }
  21. }
  22. @end