Search code examples
iosswiftuiwebview

How to measure the number of words the user has read in webview?


I am implementing gamification in my app. How can I measure the number of words a user has read in a webview in my app? I want to measure their progress in the webview. Have they gone through 50% of the content or 25%? I know I can inject javascript in the webview. How can I do this specific task?


Solution

  • WebView has a scrollView instance. You can read its contentOffset property to see how far have they scrolled.