1#import <MBProgressHUD/MBProgressHUD.h> 2 3#import "EXManagedAppSplashScreenViewController.h" 4#import "EXSplashScreenHUDButton.h" 5 6@interface EXManagedAppSplashScreenViewController() 7 8@property (nonatomic, weak) NSTimer *warningTimer; 9@property (nonatomic, weak) MBProgressHUD *warningHud; 10 11@end 12 13@implementation EXManagedAppSplashScreenViewController 14 15- (instancetype)initWithRootView:(UIView *)rootView splashScreenView:(UIView *)splashScreenView 16{ 17 if (self = [super initWithRootView:rootView splashScreenView:splashScreenView]) { 18 self.splashScreenView.userInteractionEnabled = YES; 19 } 20 21 return self; 22} 23 24- (void)showWithCallback:(void (^)(void))successCallback failureCallback:(void (^)(NSString * _Nonnull))failureCallback 25{ 26 [super showWithCallback:^{ 27 if (successCallback) { 28 successCallback(); 29 } 30 } failureCallback:failureCallback]; 31} 32 33- (void)hideWithCallback:(void (^)(BOOL))successCallback failureCallback:(void (^)(NSString * _Nonnull))failureCallback 34{ 35 [super hideWithCallback:^(BOOL isSuccess){ 36 if (self.warningTimer) { 37 [self.warningTimer invalidate]; 38 } 39 40 if (successCallback) { 41 successCallback(YES); 42 } 43 } failureCallback:failureCallback]; 44} 45 46 47-(void)startSplashScreenVisibleTimer 48{ 49 self.warningTimer = [NSTimer scheduledTimerWithTimeInterval:20.0 50 target:self 51 selector:@selector(showSplashScreenVisibleWarning) 52 userInfo:nil 53 repeats:NO]; 54} 55 56- (void)showSplashScreenVisibleWarning 57{ 58#if DEBUG 59 _warningHud = [MBProgressHUD showHUDAddedTo: self.splashScreenView animated:YES]; 60 _warningHud.mode = MBProgressHUDModeCustomView; 61 62 EXSplashScreenHUDButton *button = [EXSplashScreenHUDButton buttonWithType: UIButtonTypeSystem]; 63 [button addTarget:self action:@selector(navigateToFYI) forControlEvents:UIControlEventTouchUpInside]; 64 65 _warningHud.customView = button; 66 _warningHud.offset = CGPointMake(0.f, MBProgressMaxOffset); 67 68 [_warningHud hideAnimated:YES afterDelay:8.f]; 69#endif 70} 71 72- (void)navigateToFYI 73{ 74 NSURL *fyiURL = [[NSURL alloc] initWithString:@"https://expo.fyi/splash-screen-hanging"]; 75 [[UIApplication sharedApplication] openURL:fyiURL]; 76 [_warningHud hideAnimated: YES]; 77} 78 79@end 80