         self?.revertToLastKnownGoodVersion()
       }
     }
+    
+    NotificationCenter.default.addObserver(self, selector: #selector(WebAppLocalServer.pageDidLoad), name: NSNotification.Name.CDVPageDidLoad, object: webView)
 
     NotificationCenter.default.addObserver(self, selector: #selector(WebAppLocalServer.applicationDidEnterBackground), name: NSNotification.Name.UIApplicationDidEnterBackground, object: nil)
-
-    NotificationCenter.default.addObserver(self, selector: #selector(WebAppLocalServer.pageDidLoad), name: NSNotification.Name.CDVPageDidLoad, object: webView)
+    
+    NotificationCenter.default.addObserver(self, selector: #selector(WebAppLocalServer.applicationWillEnterForeground), name: NSNotification.Name.UIApplicationWillEnterForeground, object: nil)
   }
 
   func initializeAssetBundles() {

    // Stop startup timer when going into the background, to avoid
    // blacklisting a version just because the web view has been suspended
    startupTimer?.stop()
  }

  // MARK: - Public plugin commands

      self.pendingAssetBundle = nil
    }

    // Don't start the startup timer if the app started up in the background
    if UIApplication.shared.applicationState == UIApplicationState.active {
      startupTimer?.start(withTimeInterval: startupTimeoutInterval)
    }
  }

  // MARK: - Notifications
