Load iPhone version of page in WKWebView on iPad? - ios

I have a page in my app that displays a WKWebView. It looks great on iPhone, but doesn't look so good on iPad.
On iPad, the page is too big and gets cut off, so you have to scroll horizontally. That doesn't look good, and it doesn't work well since this is in a page view controller. I want everything to fit on the page. Is there a way to load the iPhone version of the page, even on iPad? Or is there another solution I can use?

To load iPhone version of site on iPad, you need to change user agent of your web view. First, you need to find appropriate user agent value. Go to www.whatismyuseragent.net from your iPhone. After that, change WKWebView user agent:
webView.customUserAgent = #"Mozilla/5.0 (iPhone; CPU iPhone OS 8_0_2 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Version/8.0 Mobile/12A366 Safari/600.1.4";
Of course, in real world you will only need to replace occurrences of "iPad" with "iPhone" in your user agent. Something like:
[webView evaluateJavaScript:#"navigator.userAgent" completionHandler:^(id __nullable userAgent, NSError * __nullable error) {
webView.customUserAgent = [userAgent stringByReplacingOccurrencesOfString:#"iPad" withString:#"iPhone"];
// Start actual site loading.
}
Obviously, you need to do that before loading actual web page.

Related

Is electron app needs chromium during development in ubuntu

i am new to electron js and i created a simple app that opens whatsapp web.
First it works perfectly but i dont have chromium at that time. Then i use electron forge so i created a new app with the same code and i have chromium this time.
But the output varies
link for the code is here => https://github.com/gowtham758550/WA-opener
Is chrome needed or chromium is ok for running a electron app
i am a beginner help me to solve this
You need to change the user-agent.
A user-agent is just a string that Whatsapp uses to detect what OS and browser you're coming from. Currently the user-agent looks like this:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) wa-opener/1.0.0 Chrome/89.0.4389.90 Electron/12.0.2 Safari/537.36
Notice how Electron adds wa-opener/1.0.0?
Taking wa-opener/1.0.0 out of the user-agent fixes it.
We can change the user-agent with this code:
var session = require('electron').session;
session.defaultSession.webRequest.onBeforeSendHeaders(function (detailsObj, callbackFunc) {
detailsObj.requestHeaders['User-Agent'] = detailsObj.requestHeaders['User-Agent'].replace(/wa-opener\/[.0-9]+ /, '');
callbackFunc({requestHeaders: detailsObj.requestHeaders});
});
That'll take wa-opener/1.0.0 out of the user-agent and voila!

Webpage load slow in iPhone safari on some devices

Here are 2 devices, tested to the same page
iPhone 1 safari load the web page, it blank for around 3~4 seconds
iPhone 2 we can see the page load as normal
Why would the same web page, same browser, behave differently in different devices?
What are the possible causes for this issue?
The internet speed for 2 iphones isp might be different. Go to fast.com to know your internet speed
Try clearing the cache of the device which is slow.The more cache makes the web page load longer.

iOS swift check if URL accessed via ipv6

Is there a way to check if a website is ipv6 compatible before loading it to a webview via url request?
I am asking this because I want to publish an app thats main layout loads a webview first and the url it loads isnt ipv6 compatible. Now its giving off a white screen due to which apple is rejecting my app from being published. Now that solution I want to apply is:
if(connection is ipv6) {
//do something to prevent loading the webview
} else {
//load the webview normally
}
but this is my first time using xCode and SWIFT, even MAC just installed it on vmware workstation.
edit : extra information, the application is just a single layout that has a webview to load a mobile friendly website nothing more than that:
webView.loadRequest(URLRequest(URL: URL(string: "link")!))
the review guy from apple:
From Apple
Performance - 2.1
We discovered one or more bugs in your app when reviewed on iPad
running iOS 10.2.1 on Wi-Fi connected to an IPv6 network.
Specifically, your app launches to empty white screen.
Please see attached screenshots for details.
and the screenshot is just a blank white image

Images showing up in wrong place (iOS - mobile ) - wordpress

I have a photography blog, very basic. I just write a blurb, upload the pictures.
Lately I've noticed that on my client iphone 6+ (US based), when visiting the site, some of the pictures from other posts are being placed in other posts that they weren't originally in. Logo and header images replaced with twitter, instagram and FB icon. It's happen with in US only (my client's iphone). When I look at it on the computer and other mobile devices, everything is right where it should be.
Even its working fine in my iphone 6 (in india).
Anybody else have this problem with mobile? (iphone iOS)
The website is http://www.cuadrilatero.mx/

Non-working cache.manifest on iPad and Safari Desktop

I'm trying to create an offline version of a test web app.
This far it had been working perfectly on Chrome and Firefox where I do most of my tests. Meaning I can go to the page, the console is all good, and then when I unplug my ethernet cable (I'm hardcore like that) I can see still all of my page content in browser and in chrome://appcache-internals
Problems arise when I try to test it on the iPad, I go to my webpage, but then when going into Airplane mode it refuses to access the page saying I need an internet connection. So I decided to test on Safari (mac) which is the closest I have, and I do see an error in the console on the cache.manifest mime-type : Application Cache manifest had an incorrect MIME type: text/plain.
Problem is, I do have a .htaccess and it does specify AddType text/cache-manifest appcache manifest, but no. Even when I use a web sniffer on my cache.manifest file it comes out as text/plain, which I think might be the reason it's not getting read on the iPad/Safari.
Anyone can help me on this thing ? I'm completely stuck right now.
add to your manifest file NETWORK and FALLBACK blocks so it will look like this:
CACHE MANIFEST
# Version 1.0
NETWORK:
*
CACHE:
index.html
FALLBACK:
Check if you have Private Browsing enabled in Safari on your iPad:
Settings -> Safari -> Private Browsing
If it is enabled, disable it. When Private Browsing is enabled all cookies and other caching is disabled.
I had a similar problem. My app worked fine with internet disconnected both on Safari and Firefox running on the iMac and even on the iPhone in airplane mode. But when I tried to load it on the iPad in Airplane mode it just wouldn't work. When I turned off Private Browsing it worked! Still got the notice about turning off Aerplane Mode though. But it was possible to browse the App.

Resources