-
Notifications
You must be signed in to change notification settings - Fork 50
Description
PyPI Username
jr9bjcqsjf
Reason for request
Maybe it was a reasonable solution at the time, but as I've just learned from Charles, there's an alternative.
What I can use instead is the application name for user agent property on WKWebView configuration.
So let's change this to use that instead.
First thing I'm going to do is remove this custom user agent code and go up here where I'm creating my web view.
So what I'm going to do here is first create a WKWebView configuration and then set the application name for user agent to what I want, Version/1.
0 ShinyBrowser/1.
0.
And finally, I'm going to create my web view using this configuration.
So that was a very small tweak.
I'm going to recompile my app and see what I get this time.
All right, so as you can see, we're now getting the full version of Google Docs, and I can finally collaborate with my friends.
That was pretty easy.
But now let's take it one step further.
One of the features that my users have been requesting for a while is the ability to switch between the desktop and mobile versions of a web page.
With the new API in iOS 18, it's now fairly easy to implement, so let me show you how.
First of all, notice I have this button in the top right-hand corner that contains some extra options like Add To Favorites and Share.
What I'm going to do is I'm going to add a third option here to allow the user to change content modes.
So that's going to either say Request Mobile Website or Request Desktop Website.
Okay.
So let's jump into Xcode and implement that.
I'm going to go down here, add this helper function that presents a list of UIAlertActions.
So far, as you can see, I've have Add to Favorites and Share.
What I want to do is add a third action here.
But before I do that, I'm going to make a new helper function.
It's going to help me create the UIAlertAction.
And of course, I'm just going to use it up here.
Okay.
So that should get my action.
And now I want to draw your attention over to this currentContentMode instance variable.
So what am I doing here? Well, I'm checking if the current content mode is equal to desktop.
And if it's equal to desktop, I want the string to say "request mobile website" and vice versa.
Okay, so that should make sense, but the question is "How do we keep track of currentContentMode?" How we know what it is? Well, I'm going to scroll down here where I've implemented my WKNavigation delegate, namely the didCommit navigation method, and what I'm going to do here is use a new API in iOS 18.
So in iOS 18, the WKNavigation has a new property called effectiveContentMode.
This is only ever going to be mobile or desktop and is perfect for my use case.
What I can do is set currentContent
Recovery Codes
- I never generated or have lost access to the recovery codes for my account
Code of Conduct
- I agree to follow the PSF Code of Conduct
Acknowledgement
- I understand that it may take a significant amount of time to process my account recovery request.