prebid / prebid-mobile-ios

Prebid Mobile SDK for iOS applications
Apache License 2.0
46 stars 86 forks source link

Add UserAgentDefaults for Managing User Agent String Persistence #992

Open weibel opened 1 month ago

weibel commented 1 month ago

Motivation

The creation of a WKWebView and subsequent execution of javascript to get a proper user agent string on app startup counts negatively against the app startup time. Depending on iOS version and device it can be in the hundreds of milliseconds. Since the user agent string only changes on iOS updates it's a good candidate for persistence between app starts

Summary

This pull request introduces the UserAgentDefaults class to manage the persistence of user agent strings within the application. The UserAgentService has been updated to utilize this new class, ensuring that user agents are efficiently stored and retrieved from UserDefaults.

Key Changes

UserAgentDefaults Class

UserAgentService Updates

weibel commented 1 month ago

@YuriyVelichkoPI In this comment, I mentioned persisting the user agent string keyed by the OS version. This PR is my take on an implementation. It will save the time of initializing a WKWebView and running the JavaScript on most app starts.