Prevent Sleep in iOS WKWebView apps 🌝

Couple cooking with mobile app

This article will guide you on how to prevent your WebView app from sleeping.

The WebView is a part of the WKWebView and UIWebView classes in Swift, which presents web content within an iOS app. It’s designed to help developers integrate their apps with the latest technology. However, sometimes there are some limitations in the use of WebView. One limitation is that those apps can’t show notifications and other alerts on their screen, even if they are running in the background all the time, and the display does not stay awake while being on an important web app (e.g., a recipe app).

In this article, we’ll talk about how to make sure that your iOS Webview app doesn’t sleep by using a few simple tricks and tools such as keep display awake and keep device active:

  1. Download WebViewGold for iOS
  2. Go to Config.swift file
  3. Change preventsleep boolean variable to true.
  4. That’s it!