10fbf6a33SBen Roth// Copyright 2015-present 650 Industries. All rights reserved. 20fbf6a33SBen Roth 30fbf6a33SBen Roth#import "EXAnalytics.h" 40fbf6a33SBen Roth#import "EXAppState.h" 5e791dcdeSBen Roth#import "EXBuildConstants.h" 60fbf6a33SBen Roth#import "EXFrame.h" 70fbf6a33SBen Roth#import "EXKernel.h" 889c6c39cSEric Samelson#import "EXKernelAppRecord.h" 90fbf6a33SBen Roth#import "EXKernelModule.h" 10b05926a2SBen Roth#import "EXKernelLinkingManager.h" 110fbf6a33SBen Roth#import "EXLinkingManager.h" 120fbf6a33SBen Roth#import "EXVersions.h" 130fbf6a33SBen Roth#import "EXViewController.h" 140fbf6a33SBen Roth 150fbf6a33SBen Roth#import <React/RCTBridge+Private.h> 160fbf6a33SBen Roth#import <React/RCTEventDispatcher.h> 170fbf6a33SBen Roth#import <React/RCTModuleData.h> 180fbf6a33SBen Roth#import <React/RCTUtils.h> 190fbf6a33SBen Roth 200fbf6a33SBen RothNS_ASSUME_NONNULL_BEGIN 210fbf6a33SBen Roth 220fbf6a33SBen RothNSString *kEXKernelErrorDomain = @"EXKernelErrorDomain"; 230fbf6a33SBen RothNSNotificationName kEXKernelJSIsLoadedNotification = @"EXKernelJSIsLoadedNotification"; 2443381aa0SAlicja WarchałNSNotificationName kEXKernelAppDidDisplay = @"EXKernelAppDidDisplay"; 250fbf6a33SBen RothNSString *kEXKernelShouldForegroundTaskEvent = @"foregroundTask"; 260fbf6a33SBen RothNSString * const kEXDeviceInstallUUIDKey = @"EXDeviceInstallUUIDKey"; 270fbf6a33SBen RothNSString * const kEXKernelClearJSCacheUserDefaultsKey = @"EXKernelClearJSCacheUserDefaultsKey"; 280fbf6a33SBen RothNSString * const EXKernelDisableNuxDefaultsKey = @"EXKernelDisableNuxDefaultsKey"; 290fbf6a33SBen Roth 3089c6c39cSEric Samelson@interface EXKernel () <EXKernelAppRegistryDelegate> 310fbf6a33SBen Roth 320fbf6a33SBen Roth@end 330fbf6a33SBen Roth 340fbf6a33SBen Roth@implementation EXKernel 350fbf6a33SBen Roth 360fbf6a33SBen Roth+ (instancetype)sharedInstance 370fbf6a33SBen Roth{ 380fbf6a33SBen Roth static EXKernel *theKernel; 390fbf6a33SBen Roth static dispatch_once_t once; 400fbf6a33SBen Roth dispatch_once(&once, ^{ 410fbf6a33SBen Roth if (!theKernel) { 420fbf6a33SBen Roth theKernel = [[EXKernel alloc] init]; 430fbf6a33SBen Roth } 440fbf6a33SBen Roth }); 450fbf6a33SBen Roth return theKernel; 460fbf6a33SBen Roth} 470fbf6a33SBen Roth 480fbf6a33SBen Roth- (instancetype)init 490fbf6a33SBen Roth{ 500fbf6a33SBen Roth if (self = [super init]) { 5189c6c39cSEric Samelson // init app registry: keep track of RN bridges we are running 5289c6c39cSEric Samelson _appRegistry = [[EXKernelAppRegistry alloc] init]; 5389c6c39cSEric Samelson _appRegistry.delegate = self; 549f8d9b9dSBen Roth 559f8d9b9dSBen Roth // init service registry: classes which manage shared resources among all bridges 56d7f51e5eSBen Roth _serviceRegistry = [[EXKernelServiceRegistry alloc] init]; 579f8d9b9dSBen Roth 580fbf6a33SBen Roth [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_onKernelJSLoaded) name:kEXKernelJSIsLoadedNotification object:nil]; 590fbf6a33SBen Roth for (NSString *name in @[UIApplicationDidBecomeActiveNotification, 600fbf6a33SBen Roth UIApplicationDidEnterBackgroundNotification, 610fbf6a33SBen Roth UIApplicationDidFinishLaunchingNotification, 620fbf6a33SBen Roth UIApplicationWillResignActiveNotification, 630fbf6a33SBen Roth UIApplicationWillEnterForegroundNotification]) { 640fbf6a33SBen Roth 650fbf6a33SBen Roth [[NSNotificationCenter defaultCenter] addObserver:self 660fbf6a33SBen Roth selector:@selector(_handleAppStateDidChange:) 670fbf6a33SBen Roth name:name 680fbf6a33SBen Roth object:nil]; 690fbf6a33SBen Roth } 702c229102SBen Roth NSLog(@"Expo iOS Runtime Version %@", [EXBuildConstants sharedInstance].expoRuntimeVersion); 710fbf6a33SBen Roth } 720fbf6a33SBen Roth return self; 730fbf6a33SBen Roth} 740fbf6a33SBen Roth 750fbf6a33SBen Roth- (void)dealloc 760fbf6a33SBen Roth{ 770fbf6a33SBen Roth [[NSNotificationCenter defaultCenter] removeObserver:self]; 780fbf6a33SBen Roth} 790fbf6a33SBen Roth 800fbf6a33SBen Roth- (void)_onKernelJSLoaded 810fbf6a33SBen Roth{ 820fbf6a33SBen Roth // used by appetize: optionally disable nux 83*7f6367d0SBen Roth // TODO: ben: audit 840fbf6a33SBen Roth BOOL disableNuxDefaultsValue = [[NSUserDefaults standardUserDefaults] boolForKey:EXKernelDisableNuxDefaultsKey]; 850fbf6a33SBen Roth if (disableNuxDefaultsValue) { 860fbf6a33SBen Roth [self dispatchKernelJSEvent:@"resetNuxState" body:@{ @"isNuxCompleted": @YES } onSuccess:nil onFailure:nil]; 870fbf6a33SBen Roth [[NSUserDefaults standardUserDefaults] removeObjectForKey:EXKernelDisableNuxDefaultsKey]; 880fbf6a33SBen Roth } 890fbf6a33SBen Roth} 900fbf6a33SBen Roth 915daa5350SBen Roth#pragma mark - Misc 925daa5350SBen Roth 9389c6c39cSEric Samelson- (void)openUrl:(NSString *)urlString onAppManager:(EXReactAppManager *)appManager 945daa5350SBen Roth{ 955daa5350SBen Roth // fire a Linking url event on this (possibly versioned) bridge 965daa5350SBen Roth id linkingModule = [self nativeModuleForAppManager:appManager named:@"LinkingManager"]; 975daa5350SBen Roth if (!linkingModule) { 9889c6c39cSEric Samelson DDLogError(@"Could not find the Linking module to open URL (%@)", urlString); 995daa5350SBen Roth } else if ([linkingModule respondsToSelector:@selector(dispatchOpenUrlEvent:)]) { 10089c6c39cSEric Samelson [linkingModule dispatchOpenUrlEvent:[NSURL URLWithString:urlString]]; 1015daa5350SBen Roth } else { 10289c6c39cSEric Samelson DDLogError(@"Linking module doesn't support the API we use to open URL (%@)", urlString); 1035daa5350SBen Roth } 1045daa5350SBen Roth [self _moveAppManagerToForeground:appManager]; 1055daa5350SBen Roth} 1060fbf6a33SBen Roth 1070fbf6a33SBen Roth+ (NSString *)deviceInstallUUID 1080fbf6a33SBen Roth{ 1090fbf6a33SBen Roth NSString *uuid = [[NSUserDefaults standardUserDefaults] stringForKey:kEXDeviceInstallUUIDKey]; 1100fbf6a33SBen Roth if (!uuid) { 1110fbf6a33SBen Roth uuid = [[NSUUID UUID] UUIDString]; 1120fbf6a33SBen Roth [[NSUserDefaults standardUserDefaults] setObject:uuid forKey:kEXDeviceInstallUUIDKey]; 1130fbf6a33SBen Roth [[NSUserDefaults standardUserDefaults] synchronize]; 1140fbf6a33SBen Roth } 1150fbf6a33SBen Roth return uuid; 1160fbf6a33SBen Roth} 1170fbf6a33SBen Roth 1189f8d9b9dSBen Roth#pragma mark - bridge registry delegate 1199f8d9b9dSBen Roth 12089c6c39cSEric Samelson- (void)appRegistry:(EXKernelAppRegistry *)registry didRegisterAppRecord:(EXKernelAppRecord *)appRecord 1219f8d9b9dSBen Roth{ 1229f8d9b9dSBen Roth // forward to service registry 12389c6c39cSEric Samelson [_serviceRegistry appRegistry:registry didRegisterAppRecord:appRecord]; 1249f8d9b9dSBen Roth} 1259f8d9b9dSBen Roth 12689c6c39cSEric Samelson- (void)appRegistry:(EXKernelAppRegistry *)registry willUnregisterAppRecord:(EXKernelAppRecord *)appRecord 1279f8d9b9dSBen Roth{ 1289f8d9b9dSBen Roth // forward to service registry 12989c6c39cSEric Samelson [_serviceRegistry appRegistry:registry willUnregisterAppRecord:appRecord]; 1309f8d9b9dSBen Roth} 1319f8d9b9dSBen Roth 1328a7f6184SBen Roth#pragma mark - interfacing with app managers 1330fbf6a33SBen Roth 1340fbf6a33SBen Roth- (void)dispatchKernelJSEvent:(NSString *)eventName body:(NSDictionary *)eventBody onSuccess:(void (^_Nullable)(NSDictionary * _Nullable))success onFailure:(void (^_Nullable)(NSString * _Nullable))failure 1350fbf6a33SBen Roth{ 136*7f6367d0SBen Roth // TODO: ben: kill me 137*7f6367d0SBen Roth /* EXKernelModule *kernelModule = [self nativeModuleForAppManager:_appRegistry.kernelAppManager named:@"ExponentKernel"]; 1380fbf6a33SBen Roth if (kernelModule) { 1390fbf6a33SBen Roth [kernelModule dispatchJSEvent:eventName body:eventBody onSuccess:success onFailure:failure]; 140*7f6367d0SBen Roth } */ 1410fbf6a33SBen Roth} 1420fbf6a33SBen Roth 1430fbf6a33SBen Roth- (void)_dispatchJSEvent:(NSString *)eventName body:(NSDictionary *)eventBody onAppManager:(EXReactAppManager *)appManager 1440fbf6a33SBen Roth{ 1450fbf6a33SBen Roth [appManager.reactBridge enqueueJSCall:@"RCTDeviceEventEmitter.emit" 1460fbf6a33SBen Roth args:eventBody ? @[eventName, eventBody] : @[eventName]]; 1470fbf6a33SBen Roth} 1480fbf6a33SBen Roth 1495daa5350SBen Roth- (id)nativeModuleForAppManager:(EXReactAppManager *)appManager named:(NSString *)moduleName 1500fbf6a33SBen Roth{ 1510fbf6a33SBen Roth id destinationBridge = appManager.reactBridge; 1520fbf6a33SBen Roth 1530fbf6a33SBen Roth if ([destinationBridge respondsToSelector:@selector(batchedBridge)]) { 1540fbf6a33SBen Roth id batchedBridge = [destinationBridge batchedBridge]; 1550fbf6a33SBen Roth id moduleData = [batchedBridge moduleDataForName:moduleName]; 1560fbf6a33SBen Roth 1570fbf6a33SBen Roth // React Native before SDK 11 didn't strip the "RCT" prefix from module names 1580fbf6a33SBen Roth if (!moduleData && ![moduleName hasPrefix:@"RCT"]) { 1590fbf6a33SBen Roth moduleData = [batchedBridge moduleDataForName:[@"RCT" stringByAppendingString:moduleName]]; 1600fbf6a33SBen Roth } 1610fbf6a33SBen Roth 1620fbf6a33SBen Roth if (moduleData) { 1630fbf6a33SBen Roth return [moduleData instance]; 1640fbf6a33SBen Roth } 1650fbf6a33SBen Roth } else { 1660fbf6a33SBen Roth DDLogError(@"Bridge does not support the API we use to get its underlying batched bridge"); 1670fbf6a33SBen Roth } 1680fbf6a33SBen Roth return nil; 1690fbf6a33SBen Roth} 1700fbf6a33SBen Roth 1710fbf6a33SBen Roth/** 1720fbf6a33SBen Roth * If the bridge has a batchedBridge or parentBridge selector, posts the notification on that object as well. 1730fbf6a33SBen Roth */ 1740fbf6a33SBen Roth- (void)_postNotificationName: (NSNotificationName)name onAbstractBridge: (id)bridge 1750fbf6a33SBen Roth{ 1760fbf6a33SBen Roth [[NSNotificationCenter defaultCenter] postNotificationName:name object:bridge]; 1770fbf6a33SBen Roth if ([bridge respondsToSelector:@selector(batchedBridge)]) { 1780fbf6a33SBen Roth [[NSNotificationCenter defaultCenter] postNotificationName:name object:[bridge batchedBridge]]; 1790fbf6a33SBen Roth } else if ([bridge respondsToSelector:@selector(parentBridge)]) { 1800fbf6a33SBen Roth [[NSNotificationCenter defaultCenter] postNotificationName:name object:[bridge parentBridge]]; 1810fbf6a33SBen Roth } 1820fbf6a33SBen Roth} 1830fbf6a33SBen Roth 1848a7f6184SBen Roth- (void)sendNotification:(NSDictionary *)notifBody 1858a7f6184SBen Roth toExperienceWithId:(NSString *)destinationExperienceId 1868a7f6184SBen Roth fromBackground:(BOOL)isFromBackground 1878a7f6184SBen Roth isRemote:(BOOL)isRemote 188f148175aSBen Roth{ 189*7f6367d0SBen Roth EXReactAppManager *destinationAppManager = _appRegistry.homeAppRecord.appManager; // TODO: BEN 19089c6c39cSEric Samelson EXKernelAppRecord *recordWithExperienceId = [_appRegistry newestRecordWithExperienceId:destinationExperienceId]; 19189c6c39cSEric Samelson if (recordWithExperienceId && recordWithExperienceId.appManager) { 19289c6c39cSEric Samelson destinationAppManager = recordWithExperienceId.appManager; 193f148175aSBen Roth } 1948a7f6184SBen Roth // if the notification came from the background, in most but not all cases, this means the user acted on an iOS notification 1958a7f6184SBen Roth // and caused the app to launch. 1968a7f6184SBen Roth // From SO: 1978a7f6184SBen Roth // > Note that "App opened from Notification" will be a false positive if the notification is sent while the user is on a different 1988a7f6184SBen Roth // > screen (for example, if they pull down the status bar and then receive a notification from your app). 1998a7f6184SBen Roth NSDictionary *bodyWithOrigin = @{ 2008a7f6184SBen Roth @"origin": (isFromBackground) ? @"selected" : @"received", 2018a7f6184SBen Roth @"remote": @(isRemote), 2028a7f6184SBen Roth @"data": notifBody, 2038a7f6184SBen Roth }; 2048a7f6184SBen Roth if (destinationAppManager) { 205*7f6367d0SBen Roth if (destinationAppManager == _appRegistry.homeAppRecord.appManager) { // TODO: BEN 2068a7f6184SBen Roth // send both the body and the experience id, so we can open a new experience from the kernel 2078a7f6184SBen Roth [self _dispatchJSEvent:@"Exponent.notification" 2088a7f6184SBen Roth body:@{ 2098a7f6184SBen Roth @"body": bodyWithOrigin, 2108a7f6184SBen Roth @"experienceId": destinationExperienceId, 2110fbf6a33SBen Roth } 212*7f6367d0SBen Roth onAppManager:_appRegistry.homeAppRecord.appManager]; // TODO: BEN 2138a7f6184SBen Roth } else { 2148a7f6184SBen Roth // send the body to the already-open experience 2158a7f6184SBen Roth [self _dispatchJSEvent:@"Exponent.notification" body:bodyWithOrigin onAppManager:destinationAppManager]; 2168a7f6184SBen Roth [self _moveAppManagerToForeground:destinationAppManager]; 2170fbf6a33SBen Roth } 2180fbf6a33SBen Roth } 2190fbf6a33SBen Roth} 2200fbf6a33SBen Roth 2218a7f6184SBen Roth#pragma mark - App State 2228e3c2ccdSBen Roth 223*7f6367d0SBen Roth- (void)switchTasks 2240fbf6a33SBen Roth{ 225*7f6367d0SBen Roth if (!_browserController) { 226*7f6367d0SBen Roth return; 2276f62abf2SBen Roth } 2286f62abf2SBen Roth 229*7f6367d0SBen Roth if (_visibleApp != _appRegistry.homeAppRecord) { 230*7f6367d0SBen Roth [EXUtil performSynchronouslyOnMainThread:^{ 231*7f6367d0SBen Roth [_browserController toggleMenu]; 232*7f6367d0SBen Roth }]; 233b05926a2SBen Roth } else { 234*7f6367d0SBen Roth EXKernelAppRegistry *appRegistry = [EXKernel sharedInstance].appRegistry; 235*7f6367d0SBen Roth for (NSString *recordId in appRegistry.appEnumerator) { 236*7f6367d0SBen Roth EXKernelAppRecord *record = [appRegistry recordForId:recordId]; 237*7f6367d0SBen Roth // foreground the first thing we find 238*7f6367d0SBen Roth [self moveAppToVisible:record]; 239*7f6367d0SBen Roth } 240*7f6367d0SBen Roth } 241*7f6367d0SBen Roth} 242*7f6367d0SBen Roth 243*7f6367d0SBen Roth- (void)moveAppToVisible:(EXKernelAppRecord *)appRecord 244*7f6367d0SBen Roth{ 245*7f6367d0SBen Roth if (_browserController) { 246*7f6367d0SBen Roth [EXUtil performSynchronouslyOnMainThread:^{ 247*7f6367d0SBen Roth [_browserController moveAppToVisible:appRecord]; 248*7f6367d0SBen Roth }]; 249*7f6367d0SBen Roth } 250*7f6367d0SBen Roth} 251*7f6367d0SBen Roth 252*7f6367d0SBen Roth- (void)appDidBecomeVisible:(EXKernelAppRecord *)appRecord 253*7f6367d0SBen Roth{ 254*7f6367d0SBen Roth EXKernelAppRecord *appRecordPreviouslyVisible = _visibleApp; 255*7f6367d0SBen Roth if (appRecord != appRecordPreviouslyVisible) { 256*7f6367d0SBen Roth if (appRecordPreviouslyVisible) { 257*7f6367d0SBen Roth [self _postNotificationName:kEXKernelBridgeDidBackgroundNotification onAbstractBridge:appRecordPreviouslyVisible.appManager.reactBridge]; 258*7f6367d0SBen Roth id appStateModule = [self nativeModuleForAppManager:appRecordPreviouslyVisible.appManager named:@"AppState"]; 2590fbf6a33SBen Roth if ([appStateModule respondsToSelector:@selector(setState:)]) { 2600fbf6a33SBen Roth [appStateModule setState:@"background"]; 2610fbf6a33SBen Roth } 2620fbf6a33SBen Roth } 263*7f6367d0SBen Roth if (appRecord) { 264*7f6367d0SBen Roth [self _postNotificationName:kEXKernelBridgeDidForegroundNotification onAbstractBridge:appRecord.appManager.reactBridge]; 265*7f6367d0SBen Roth id appStateModule = [self nativeModuleForAppManager:appRecord.appManager named:@"AppState"]; 2660fbf6a33SBen Roth if ([appStateModule respondsToSelector:@selector(setState:)]) { 2670fbf6a33SBen Roth [appStateModule setState:@"active"]; 2680fbf6a33SBen Roth } 269*7f6367d0SBen Roth _visibleApp = appRecord; 270*7f6367d0SBen Roth [[EXAnalytics sharedInstance] logKernelAppVisibleEvent]; 2710fbf6a33SBen Roth } else { 272*7f6367d0SBen Roth _visibleApp = nil; 273*7f6367d0SBen Roth } 274*7f6367d0SBen Roth 275*7f6367d0SBen Roth if (_visibleApp && _visibleApp != _appRegistry.homeAppRecord) { 276*7f6367d0SBen Roth [self _unregisterUnusedAppRecords]; 277*7f6367d0SBen Roth } 278*7f6367d0SBen Roth } 279*7f6367d0SBen Roth} 280*7f6367d0SBen Roth 281*7f6367d0SBen Roth- (void)_unregisterUnusedAppRecords 282*7f6367d0SBen Roth{ 283*7f6367d0SBen Roth for (NSString *recordId in _appRegistry.appEnumerator) { 284*7f6367d0SBen Roth EXKernelAppRecord *record = [_appRegistry recordForId:recordId]; 285*7f6367d0SBen Roth if (record && record != _visibleApp) { 286*7f6367d0SBen Roth [_appRegistry unregisterAppWithRecordId:recordId]; 287*7f6367d0SBen Roth break; 2880fbf6a33SBen Roth } 2890fbf6a33SBen Roth } 290b05926a2SBen Roth} 2910fbf6a33SBen Roth 2920fbf6a33SBen Roth- (void)_handleAppStateDidChange:(NSNotification *)notification 2930fbf6a33SBen Roth{ 2940fbf6a33SBen Roth NSString *newState; 2950fbf6a33SBen Roth 2960fbf6a33SBen Roth if ([notification.name isEqualToString:UIApplicationWillResignActiveNotification]) { 2970fbf6a33SBen Roth newState = @"inactive"; 2980fbf6a33SBen Roth } else if ([notification.name isEqualToString:UIApplicationWillEnterForegroundNotification]) { 2990fbf6a33SBen Roth newState = @"background"; 3000fbf6a33SBen Roth } else { 3010fbf6a33SBen Roth switch (RCTSharedApplication().applicationState) { 3020fbf6a33SBen Roth case UIApplicationStateActive: 3030fbf6a33SBen Roth newState = @"active"; 3040fbf6a33SBen Roth break; 3050fbf6a33SBen Roth case UIApplicationStateBackground: { 3060fbf6a33SBen Roth newState = @"background"; 3070fbf6a33SBen Roth break; 3080fbf6a33SBen Roth } 3090fbf6a33SBen Roth default: { 3100fbf6a33SBen Roth newState = @"unknown"; 3110fbf6a33SBen Roth break; 3120fbf6a33SBen Roth } 3130fbf6a33SBen Roth } 3140fbf6a33SBen Roth } 3150fbf6a33SBen Roth 316*7f6367d0SBen Roth if (_visibleApp) { 317*7f6367d0SBen Roth EXReactAppManager *appManager = _visibleApp.appManager; 3185daa5350SBen Roth id appStateModule = [self nativeModuleForAppManager:appManager named:@"AppState"]; 3190fbf6a33SBen Roth NSString *lastKnownState; 3200fbf6a33SBen Roth if ([appStateModule respondsToSelector:@selector(lastKnownState)]) { 3210fbf6a33SBen Roth lastKnownState = [appStateModule lastKnownState]; 3220fbf6a33SBen Roth } 3230fbf6a33SBen Roth if ([appStateModule respondsToSelector:@selector(setState:)]) { 3240fbf6a33SBen Roth [appStateModule setState:newState]; 3250fbf6a33SBen Roth } 3260fbf6a33SBen Roth if (!lastKnownState || ![newState isEqualToString:lastKnownState]) { 3270fbf6a33SBen Roth if ([newState isEqualToString:@"active"]) { 328*7f6367d0SBen Roth [self _postNotificationName:kEXKernelBridgeDidForegroundNotification onAbstractBridge:appManager.reactBridge]; 3290fbf6a33SBen Roth } else if ([newState isEqualToString:@"background"]) { 330*7f6367d0SBen Roth [self _postNotificationName:kEXKernelBridgeDidBackgroundNotification onAbstractBridge:appManager.reactBridge]; 3310fbf6a33SBen Roth } 3320fbf6a33SBen Roth } 3330fbf6a33SBen Roth } 3340fbf6a33SBen Roth} 3350fbf6a33SBen Roth 336*7f6367d0SBen Roth// TODO: BEN 3378a7f6184SBen Roth- (void)_moveAppManagerToForeground: (EXReactAppManager *)appManager 3388a7f6184SBen Roth{ 339*7f6367d0SBen Roth /* if (appManager != _appRegistry.kernelAppManager) { 3408a7f6184SBen Roth EXFrameReactAppManager *frameAppManager = (EXFrameReactAppManager *)appManager; 3418a7f6184SBen Roth // kernel JS needs to bring the relevant frame/bridge to visibility. 3428a7f6184SBen Roth NSURL *frameUrlToForeground = frameAppManager.frame.initialUri; 3438a7f6184SBen Roth [self dispatchKernelJSEvent:kEXKernelShouldForegroundTaskEvent body:@{ @"taskUrl":frameUrlToForeground.absoluteString } onSuccess:nil onFailure:nil]; 344*7f6367d0SBen Roth } */ 3458a7f6184SBen Roth} 3468a7f6184SBen Roth 3470fbf6a33SBen Roth@end 3480fbf6a33SBen Roth 3490fbf6a33SBen RothNS_ASSUME_NONNULL_END 350