react-native-navigation的迁移库

ReactNativeNavigation.m 1.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #import "ReactNativeNavigation.h"
  2. #import <React/RCTUIManager.h>
  3. #import "RNNBridgeManager.h"
  4. #import "RNNSplashScreen.h"
  5. @interface ReactNativeNavigation()
  6. @property (nonatomic, strong) RNNBridgeManager *bridgeManager;
  7. @end
  8. @implementation ReactNativeNavigation
  9. # pragma mark - public API
  10. +(void)bootstrap:(NSURL *)jsCodeLocation launchOptions:(NSDictionary *)launchOptions {
  11. [[ReactNativeNavigation sharedInstance] bootstrap:jsCodeLocation launchOptions:launchOptions];
  12. }
  13. + (void)registerExternalComponent:(NSString *)name callback:(RNNExternalViewCreator)callback {
  14. [[ReactNativeNavigation sharedInstance].bridgeManager registerExternalComponent:name callback:callback];
  15. }
  16. + (RCTBridge *)getBridge {
  17. return [[ReactNativeNavigation sharedInstance].bridgeManager bridge];
  18. }
  19. # pragma mark - instance
  20. + (instancetype) sharedInstance {
  21. static ReactNativeNavigation *instance = nil;
  22. static dispatch_once_t onceToken = 0;
  23. dispatch_once(&onceToken,^{
  24. if (instance == nil) {
  25. instance = [[ReactNativeNavigation alloc] init];
  26. }
  27. });
  28. return instance;
  29. }
  30. -(void)bootstrap:(NSURL *)jsCodeLocation launchOptions:(NSDictionary *)launchOptions {
  31. self.bridgeManager = [[RNNBridgeManager alloc] initWithJsCodeLocation:jsCodeLocation launchOptions:launchOptions];
  32. [RNNSplashScreen show];
  33. }
  34. @end