xref: /expo/ios/Exponent/Kernel/Core/EXKernel.h (revision b0932293)
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 
11 NS_ASSUME_NONNULL_BEGIN
12 
13 FOUNDATION_EXPORT NSString *kEXKernelErrorDomain;
14 typedef NS_ENUM(NSInteger, EXKernelErrorCode) {
15   EXKernelErrorCodeModuleDeallocated,
16 };
17 
18 // this key is set to YES when crashlytics sends a crash report.
19 FOUNDATION_EXPORT NSString * const kEXKernelClearJSCacheUserDefaultsKey;
20 
21 @interface EXKernel : NSObject <EXViewControllerDelegate>
22 
23 @property (nonatomic, strong, readonly) EXKernelAppRegistry *appRegistry;
24 @property (nonatomic, strong, readonly) EXKernelServiceRegistry *serviceRegistry;
25 @property (nonatomic, readonly) EXKernelAppRecord *visibleApp;
26 @property (nonatomic, assign) id<EXAppBrowserController> browserController;
27 
28 + (instancetype)sharedInstance;
29 
30 - (EXKernelAppRecord *)createNewAppWithUrl:(NSURL *)url initialProps:(nullable NSDictionary *)initialProps;
31 - (void)switchTasks;
32 - (void)reloadAppWithExperienceId:(NSString *)experienceId; // called by Util.reload
33 
34 /**
35  *  Send a notification to a given experience id.
36  */
37 - (void)sendNotification: (NSDictionary *)notifBody
38       toExperienceWithId: (NSString *)experienceId
39           fromBackground: (BOOL)isFromBackground
40                 isRemote: (BOOL)isRemote;
41 
42 /**
43  *  Find and return the (potentially versioned) native module instance belonging to the
44  *  specified app manager. Module name is the exported name such as @"AppState".
45  */
46 - (id)nativeModuleForAppManager:(EXReactAppManager *)appManager named:(NSString *)moduleName;
47 
48 /**
49  *  Send the given url to this app (via the RN Linking module) and foreground it.
50  */
51 - (void)sendUrl:(NSString *)url toAppRecord:(EXKernelAppRecord *)app;
52 
53 /**
54  *  An id that uniquely identifies this installation of Exponent.
55  */
56 + (NSString *)deviceInstallUUID;
57 
58 - (void)logAnalyticsEvent:(NSString *)eventId forAppRecord:(EXKernelAppRecord *)appRecord;
59 
60 @end
61 
62 NS_ASSUME_NONNULL_END
63