Add UserAgentDefaults for Managing User Agent String Persistence
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
- Implements UserAgentPersistence protocol to handle user agent persistence.
- Uses UserDefaults for storing user agent strings, keyed by the current OS version.
- Includes a contents property to fetch the entire user agent dictionary from UserDefaults.
- Provides methods for setting, getting, and resetting the user agent.
UserAgentService Updates
- Utilizes UserAgentDefaults for managing user agent persistence.
@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.
@YuriyVelichkoPI
Looks good to me!
Hmm, I'm not sure why it's still not merged.
@mdanylov-sigma could you please rebase the branch and we can merge it once the conflicts are solved
Hey @weibel, could we ask you to rebase your branch on master to merge these changes ?
Hi @weibel, could you update the branch one more time, please? It has conflicts now.
Sorry for such a mess, I'll do my best to help finalizing these eforts.
@mdanylov-sigma, please take a look at why the tests failed. It doesn't look like a reason in the code of PR.
Hi. These days I work in a new role and will not have much opportunity to work further on this PR. I'll check back from time to time. Thanks!
The issue wasn't related to the codebase, sometimes GitHub Actions lags without any errors. Now all checks have been finished successfully, merging PR.
Thanks for your contribution!