react-native-navigation的迁移库

ReactNativeNavigation.m 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. # pragma mark - instance
  17. + (instancetype) sharedInstance {
  18. static ReactNativeNavigation *instance = nil;
  19. static dispatch_once_t onceToken = 0;
  20. dispatch_once(&onceToken,^{
  21. if (instance == nil) {
  22. instance = [[ReactNativeNavigation alloc] init];
  23. }
  24. });
  25. return instance;
  26. }
  27. -(void)bootstrap:(NSURL *)jsCodeLocation launchOptions:(NSDictionary *)launchOptions {
  28. self.bridgeManager = [[RNNBridgeManager alloc] initWithJsCodeLocation:jsCodeLocation launchOptions:launchOptions];
  29. [RNNSplashScreen show];
  30. }
  31. @end