xref: /expo/ios/Exponent/Kernel/Core/EXKernel.h (revision 7629aae1)
1 // This class contains any singleton kernel logic that needs to live in obj-c.
2 // Copyright 2015-present 650 Industries. All rights reserved.
3 
4 #import <UIKit/UIKit.h>
5 
6 #import "EXKernelAppRegistry.h"
7 #import "EXKernelServiceRegistry.h"
8 #import "EXKernelUtil.h"
9 
10 @class EXViewController;
11 
12 NS_ASSUME_NONNULL_BEGIN
13 
14 FOUNDATION_EXPORT NSNotificationName kEXKernelJSIsLoadedNotification;
15 FOUNDATION_EXPORT NSNotificationName kEXKernelAppDidDisplay;
16 FOUNDATION_EXPORT NSString *kEXKernelErrorDomain;
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
22 
23 @property (nonatomic, strong, readonly) EXKernelAppRegistry *appRegistry;
24 @property (nonatomic, strong, readonly) EXKernelServiceRegistry *serviceRegistry;
25 
26 + (instancetype)sharedInstance;
27 
28 /**
29  *  Dispatch a JS event to the kernel bridge, with optional completion handlers.
30  */
31 - (void)dispatchKernelJSEvent: (NSString *)eventName
32                    body: (NSDictionary *)eventBody
33               onSuccess: (void (^_Nullable)(NSDictionary * _Nullable ))success
34               onFailure: (void (^_Nullable)(NSString * _Nullable ))failure;
35 
36 /**
37  *  Send a notification to a given experience id.
38  */
39 - (void)sendNotification: (NSDictionary *)notifBody
40       toExperienceWithId: (NSString *)experienceId
41           fromBackground: (BOOL)isFromBackground
42                 isRemote: (BOOL)isRemote;
43 
44 - (void)registerRootExponentViewController: (EXViewController *)exponentViewController;
45 - (EXViewController *)rootViewController;
46 
47 /**
48  *  Find and return the (potentially versioned) native module instance belonging to the
49  *  specified app manager. Module name is the exported name such as @"AppState".
50  */
51 - (id)nativeModuleForAppManager:(EXReactAppManager *)appManager named:(NSString *)moduleName;
52 
53 /**
54  *  Send the given url to this app manager (via the Linking module) and foreground it.
55  */
56 - (void)openUrl:(NSString *)url onAppManager:(EXReactAppManager *)appManager;
57 
58 /**
59  *  Update state after a JS task switch.
60  */
61 - (void)handleJSTaskDidForegroundWithType:(NSInteger)type params:(NSDictionary *)params;
62 
63 /**
64  *  An id that uniquely identifies this installation of Exponent.
65  */
66 + (NSString *)deviceInstallUUID;
67 
68 @end
69 
70 NS_ASSUME_NONNULL_END
71