@@ -113,27 +113,19 @@ - (void)presentSafariVCWithBranchKey:(NSString *)branchKey {
113113 return ;
114114 }
115115
116- UIViewController * safController = [[SFSafariViewControllerClass alloc ] initWithURL: strongMatchUrl];
117- self.secondWindow = [[UIWindow alloc ] initWithFrame: [[[[UIApplication sharedApplication ] windows ] firstObject ] bounds ]];
118- UIViewController *windowRootController = [[UIViewController alloc ] init ];
119- self.secondWindow .rootViewController = windowRootController;
120- self.secondWindow .windowLevel = UIWindowLevelNormal - 1 ;
121- [self .secondWindow setHidden: NO ];
122- [self .secondWindow setAlpha: 0 ];
123-
124116 // Must be on next run loop to avoid a warning
125117 dispatch_async (dispatch_get_main_queue (), ^{
126- // Add the safari view controller using view controller containment
127- [windowRootController addChildViewController: safController];
128- [windowRootController.view addSubview: safController.view];
129- [safController didMoveToParentViewController: windowRootController];
118+ UIViewController * safController = [[SFSafariViewControllerClass alloc ] initWithURL: strongMatchUrl];
119+ self.secondWindow = [[UIWindow alloc ] initWithFrame: [[UIScreen mainScreen ] bounds ]];
120+ self.secondWindow .rootViewController = safController;
121+ self.secondWindow .windowLevel = UIWindowLevelNormal - 100 ;
122+ [self .secondWindow setHidden: NO ];
123+ UIWindow *keyWindow = [[UIApplication sharedApplication ] keyWindow ];
124+ [self .secondWindow makeKeyWindow ];
130125
131- // Give a little bit of time for safari to load the request.
132- dispatch_after (dispatch_time (DISPATCH_TIME_NOW, (int64_t )(10 * NSEC_PER_SEC)), dispatch_get_main_queue (), ^{
133- // Remove the safari view controller from view controller containment
134- [safController willMoveToParentViewController: nil ];
135- [safController.view removeFromSuperview ];
136- [safController removeFromParentViewController ];
126+ // Give enough time for Safari to load the request (optimized for 3G)
127+ dispatch_after (dispatch_time (DISPATCH_TIME_NOW, (int64_t )(2 * NSEC_PER_SEC)), dispatch_get_main_queue (), ^{
128+ [keyWindow makeKeyWindow ];
137129
138130 // Remove the window and release it's strong reference. This is important to ensure that
139131 // applications using view controller based status bar appearance are restored.
0 commit comments