xref: /expo/ios/Exponent/Kernel/Core/EXKernel.h (revision 4a05dfd5)
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 // this key is set to YES when crashlytics sends a crash report.
21 FOUNDATION_EXPORT NSString * const kEXKernelClearJSCacheUserDefaultsKey;
22 
23 @interface EXKernel : NSObject <EXViewControllerDelegate>
24 
25 @property (nonatomic, strong, readonly) EXKernelAppRegistry *appRegistry;
26 @property (nonatomic, strong, readonly) EXKernelServiceRegistry *serviceRegistry;
27 @property (nonatomic, readonly) EXKernelAppRecord *visibleApp;
28 @property (nonatomic, assign) id<EXAppBrowserController> browserController;
29 
30 + (instancetype)sharedInstance;
31 
32 - (EXKernelAppRecord *)createNewAppWithUrl:(NSURL *)url initialProps:(nullable NSDictionary *)initialProps;
33 - (void)switchTasks;
34 - (void)reloadAppWithExperienceId:(NSString *)experienceId; // called by Updates.reload
35 - (void)reloadAppFromCacheWithExperienceId:(NSString *)experienceId; // called by Updates.reloadFromCache
36 - (void)reloadVisibleApp; // called in development whenever the app is reloaded
37 
38 /**
39  *  Send a given notification.
40  *  Returns whether the notification has been successfully sent to a running experience.
41  */
42 - (BOOL)sendNotification:(EXPendingNotification *)notification;
43 
44 /**
45  *  Initial props to pass to an app based on LaunchOptions from UIApplicationDelegate.
46  */
47 - (nullable NSDictionary *)initialAppPropsFromLaunchOptions:(NSDictionary *)launchOptions;
48 
49 /**
50  *  Find and return the (potentially versioned) native module instance belonging to the
51  *  specified app manager. Module name is the exported name such as @"AppState".
52  */
53 - (id)nativeModuleForAppManager:(EXReactAppManager *)appManager named:(NSString *)moduleName;
54 
55 /**
56  *  Send the given url to this app (via the RN Linking module) and foreground it.
57  */
58 - (void)sendUrl:(NSString *)url toAppRecord:(EXKernelAppRecord *)app;
59 
60 /**
61  *  An id that uniquely identifies this installation of Exponent.
62  */
63 + (NSString *)deviceInstallUUID;
64 
65 - (void)logAnalyticsEvent:(NSString *)eventId forAppRecord:(EXKernelAppRecord *)appRecord;
66 
67 @end
68 
69 NS_ASSUME_NONNULL_END
70