Skip to content

Commit

Permalink
Merge pull request #718 from OneSignal/fix/second_webview_not_cleared
Browse files Browse the repository at this point in the history
Fixing webviews not being cleared properly
  • Loading branch information
emawby committed Aug 7, 2020
2 parents 2e4a36c + ccd0251 commit 380f40f
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions iOS_SDK/OneSignalSDK/Source/OneSignalWebView.m
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,9 @@ - (void)showInApp {
if (!navController) {
navController = [[UINavigationController alloc] initWithRootViewController:self];
navController.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
navController.presentationController.delegate = self;
}
navController.presentationController.delegate = self;

if (!viewControllerForPresentation) {
viewControllerForPresentation = [[UIViewController alloc] init];
[[viewControllerForPresentation view] setBackgroundColor:[UIColor clearColor]];
Expand All @@ -122,8 +123,9 @@ - (void)showInApp {

UIWindow* mainWindow = [[UIApplication sharedApplication] keyWindow];

if (!viewControllerForPresentation.view.superview)
if (!viewControllerForPresentation.view.superview) {
[mainWindow addSubview:[viewControllerForPresentation view]];
}

@try {
[viewControllerForPresentation presentViewController:navController animated:YES completion:nil];
Expand All @@ -133,11 +135,15 @@ - (void)showInApp {

- (void)clearWebView {
[_webView loadHTMLString:@"" baseURL:nil];
if (viewControllerForPresentation)
if (viewControllerForPresentation) {
[OneSignal onesignal_Log:ONE_S_LL_VERBOSE message:@"clearing web view"];
[viewControllerForPresentation.view removeFromSuperview];
}

}

- (void)presentationControllerDidDismiss:(UIPresentationController *)presentationController {
[OneSignal onesignal_Log:ONE_S_LL_VERBOSE message:@"presentation controller did dismiss webview"];
[self clearWebView];
}

Expand Down

0 comments on commit 380f40f

Please sign in to comment.