1 // Copyright 2015-present 650 Industries. All rights reserved. 2 3 #import <UIKit/UIKit.h> 4 5 #import "EXAppBrowserController.h" 6 #import "EXKernelAppRegistry.h" 7 #import "EXKernelServiceRegistry.h" 8 #import "EXKernelUtil.h" 9 #import "EXViewController.h" 10 #import "EXPendingNotification.h" 11 12 NS_ASSUME_NONNULL_BEGIN 13 14 FOUNDATION_EXPORT NSString *kEXKernelErrorDomain; 15 16 typedef NS_ENUM(NSInteger, EXKernelErrorCode) { 17 EXKernelErrorCodeModuleDeallocated, 18 }; 19 20 @interface EXKernel : NSObject <EXViewControllerDelegate> 21 22 @property (nonatomic, strong, readonly) EXKernelAppRegistry *appRegistry; 23 @property (nonatomic, strong, readonly) EXKernelServiceRegistry *serviceRegistry; 24 @property (nonatomic, readonly) EXKernelAppRecord *visibleApp; 25 @property (nonatomic, assign) id<EXAppBrowserController> browserController; 26 27 + (instancetype)sharedInstance; 28 29 - (EXKernelAppRecord *)createNewAppWithUrl:(NSURL *)url initialProps:(nullable NSDictionary *)initialProps; 30 - (void)switchTasks; 31 - (void)reloadAppWithScopeKey:(NSString *)scopeKey; // called by Updates.reload 32 - (void)reloadAppFromCacheWithScopeKey:(NSString *)scopeKey; // called by Updates.reloadFromCache 33 - (void)reloadVisibleApp; // called in development whenever the app is reloaded 34 35 /** 36 * Send a given notification. 37 * Returns whether the notification has been successfully sent to a running experience. 38 */ 39 - (BOOL)sendNotification:(EXPendingNotification *)notification; 40 41 /** 42 * Initial props to pass to an app based on LaunchOptions from UIApplicationDelegate. 43 */ 44 - (nullable NSDictionary *)initialAppPropsFromLaunchOptions:(NSDictionary *)launchOptions; 45 46 /** 47 * Find and return the (potentially versioned) native module instance belonging to the 48 * specified app manager. Module name is the exported name such as @"AppState". 49 */ 50 - (id)nativeModuleForAppManager:(EXReactAppManager *)appManager named:(NSString *)moduleName; 51 52 /** 53 * Send the given url to this app (via the RN Linking module) and foreground it. 54 */ 55 - (void)sendUrl:(NSString *)url toAppRecord:(EXKernelAppRecord *)app; 56 57 - (void)logAnalyticsEvent:(NSString *)eventId forAppRecord:(EXKernelAppRecord *)appRecord; 58 59 @end 60 61 NS_ASSUME_NONNULL_END 62