react-native-navigation的迁移库

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #import "RNN.h"
  2. #import "RNNEventEmitter.h"
  3. #import "RCTBridge.h"
  4. @interface RNN()
  5. @end
  6. @implementation RNN
  7. {
  8. RCTBridge* bridge;
  9. }
  10. +(instancetype)instance
  11. {
  12. static RNN *sharedInstance = nil;
  13. static dispatch_once_t onceToken = 0;
  14. dispatch_once(&onceToken,^{
  15. if (sharedInstance == nil)
  16. {
  17. sharedInstance = [[RNN alloc] init];
  18. }
  19. });
  20. return sharedInstance;
  21. }
  22. -(void)bootstrap:(NSURL *)jsCodeLocation launchOptions:(NSDictionary *)launchOptions
  23. {
  24. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onJavaScriptLoaded) name:RCTJavaScriptDidLoadNotification object:nil];
  25. #pragma GCC diagnostic push
  26. #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
  27. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onJavaScriptDevReload) name:RCTReloadNotification object:nil];
  28. #pragma GCC diagnostic pop
  29. // this will load the JS bundle
  30. bridge = [[RCTBridge alloc] initWithBundleURL:jsCodeLocation moduleProvider:nil launchOptions:launchOptions];
  31. }
  32. -(void)onJavaScriptLoaded
  33. {
  34. [RNNEventEmitter sendOnAppLaunched];
  35. }
  36. -(void)onJavaScriptDevReload
  37. {
  38. UIApplication.sharedApplication.delegate.window.rootViewController = nil;
  39. }
  40. -(RCTBridge *)bridge
  41. {
  42. return bridge;
  43. }
  44. @end