react-native-navigation的迁移库

ReactNativeNavigation.m 1.2KB

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