I've been experiencing weird behaviour on iOS9 when trying to load in-app HTML pages into our UIWebView - sometimes the pages load, sometimes just appearing as a blank screen.
The webViewDidFinishLoad function gets called in these instances as well (but no didFailLoadWithError). I can't seem to find any clues as to what would be making the page not visible some of the time. A lot of the other questions I found here suggest issues with the path, but I would think it'd be consistantly failing if that was the case.
The same code works fine on iOS 8.
add into info.plist file
NSAppTransportSecurity
NSAllowsArbitraryLoads
As #vmthiru said, you need to add that to the Info.plist file. Although the exact format would be:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key><true/>
</dict>
Meaning that if you do it via the XCode UI, you would need to add the NSAppTransportSecurity key (with Dictionary type), and inside of it, add a boolean with key NSAppTransportSecurity and set it to YES.
That said, you will probably notice that there are some viewport bugs in iOS 9 still, but that has nothing to do with this.
Hope it helps
Related
I have a WKWebView which will display users' webpages using links gathered online.
Sometimes these links are http: which are blocked by ATS.
I've tried simply changing the links to https:, which works sometimes.
However, very often I get an error "An SSL error has occurred and a secure connection to the server cannot be made".
Sometimes the page simply redirects to the http:, which gets blocked again.
Other times the https: page is simply "Not found".
Removing http: only results in "Unsupported URL" error.
Is there any way to get WKWebView to show these pages?
PLEASE DON"T suggest NSAllowsArbitraryLoads, or even per-domain exceptions (I do not know in advance what the domains will be).
The pages load perfectly on Safari, and even mobile safari, so it must be possible.
So, the short answer is NSAllowsArbitraryLoadsInWebContent, which will work great in iOS 10. However, if you try to run with that in your Info.plist on an iOS 9 device, it won't work.
If you want this to work on both iOS 9 and iOS 10, what Apple is recommending that you do is to put both NSAllowsArbitraryLoads AND NSAllowsArbitraryLoadsInWebContent in your Info.plist.
In iOS 9, since it doesn't recognize the NSAllowsArbitraryLoadsInWebContent entry, it will allow all http content in the app (including your WKWebview). This isn't ideal, but as long as you are ensuring your critical connections elsewhere are secure, having Apple enforce it really doesn't do much.
In iOS 10 (which most of your users should be running) iOS will ignore the NSAllowsArbitraryLoads if it also sees NSAllowsArbitraryLoadsInWebContent. This means the rest of your app network communications will need to follow ATS's security requirements, while the WKWebView and UIWebView does not. This isn't a great solution, but it is the one recommended by Apple engineers when you need to support both iOS 9 and 10.
Note that when Apple does start to require justifications for ATS exceptions, the NSAllowsArbitraryLoadsInWebContent entry is one of the ones that will trigger the need to justification. But, it is better than having NSAllowsArbitraryLoads by itself, and you can put that in your justification and it should be accepted by Apple.
As posted in this article, add a top level property NSAppTransportSecurity in info.plist, then if the iOS version is 10 and above, add a boolean entry for NSAllowsArbitraryLoadsInWebContent in this dictionary, otherwise NSAllowsArbitraryLoads, such that the plist entry looks like
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoadsInWebContent</key>
<true/>
</dict>
I have used Fullcalendar in one of my html page. It is working fine in chrome and mozilla. Also same is working fine in Android devices. But issue is with IOS device.
Calendar events itself are not being loaded. Didn't found any solution for this on net. Please provide any help on this.
Just a couple of attempts:
try to load another url and to see if the problem is in your html page or in your app
take a look at your plist, in particular at the NSAppTransportSecurity
In this second case, you can add this key:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
If the problem is the NSAppTransportSecurity, you'll have to set up it correctly with your domain.
Do you get this deprecation warning in browser console?
Deprecation warning: value provided is not in a recognized ISO format.
moment construction falls back to js Date(), which is not reliable
across all browsers and versions. Non ISO date formats are discouraged
and will be removed in an upcoming major release. Please refer to
http://momentjs.com/guides/#/warnings/js-date/ for more info.
If yes, check the date format for event start and end.
In my app it was RFC822 (nonISO), causing fallback to date format not working on iOS devices.
Changing date parsing to ISO8601 helped in my case.
So I'm trying to add a custom URL scheme to my app. Everything works. The confusing part is that when a user gets redirected it puts up a dialog box that says:
Open in "(null)"?
I can't figure out why it says null and not the name of the app. The only other spot I've been able to see this issue mentioned is here:
'Open this page in "null"' Modal appearing from FacebookSDK login after iOS9 and Swift 2 upgrade
but that talks about updating to the latest SDK. It does mention whitelisting the scheme which I tried doing using LSApplicationQueriesSchemes but that doesn't seem to fix it either.
So in my case it ended up being that the following had gotten added to my Info.plist:
<key>CFBundleDisplayName</key>
<string></string>
Either removing this key or giving it a non empty string value fixes the issue and causes it to give: Open in "name of app"?.
The value in that dialog is specified in Build Settings -> Packaging -> Product Name. By any chance, is that field somehow blank? Usually the build should fail if so, and presumably you'd have also noted something wrong on the homescreen, but who knows!
As a side note, URL schemes are not a fool-proof way to handle deep linking anymore, and are actually actively discouraged by Apple. At minimum, you also need to implement Universal Links, but even that is not a complete solution because of variations in how other apps (Facebook, etc) handle outbound links. You may want to consider a tool like Branch.io (full disclosure: I'm on the Branch team) to give a hand with all the logistics.
I found this about whitelisting urlschemes for iOS 9 (found answer here)
Any app built with SDK 9 needs to provide a LSApplicationQueriesSchemes entry in its plist file, declaring which schemes it attempts to query.
<key>LSApplicationQueriesSchemes</key>
<array>
<string>urlscheme</string>
<string>urlscheme2</string>
<string>urlscheme3</string>
<string>urlscheme4</string>
</array>
This worked for me in getting rid of that.
I need to be able to launch my iOS app from the Safari browser. So I went to my .plist file in xcode and added an item to my URL Schemes and entered in the string of myappname.
Now if I go to Safari, and type myappname:// in the URL address bar and submit it, it shows me a UIAlertView that says Open this page in "MyAppName"? with options for Cancel and Open.
If I tap Open it successfully opens my app, however I want to do this without the UIAlertView popping up with that message.
I have done some quick searching online and it looks like people keep having trouble with this whenever a new iOS update comes out and I can't seem to find a recent solution or answer.
I am on an iPhone 4s with iOS 7.1, and I'm using xcode 5.1 if that makes any difference.
Also, I have been using an app available in the App Store called "Frontback" that successfully does this same thing without the UIAlertView showing in Safari so this is definitely possible.
Thanks for the help.
I use this method in my app without getting a UIAlertView. It just goes straight to the app.
I had a similar issue when I first started implementing it. I suspect that it's not a problem with myappname://, but possibly a problem with how you added the URL Scheme.
Make sure to assign your custom value (myappname) to the URL Identifier object (com.mycompany.myappname). The URL identifier should be a String and the URL Schemes should be an array with your custom value being a String.
The XML version of your .plist should look like this:
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<string>com.mycompany.myappname</string>
<key>CFBundleURLSchemes</key>
<array>
<string>myappname</string>
</array>
</dict>
</array>
Here is how to avoid the "Open this page in YourAppName?" popup when using Universal links.
My observation is as follows:
When using html links that the user needs to click then the popup does not appear.
If you want to use window.location.href or window.location.replace to directly get back to the app without the user needing to click a link then it seems to depend on if is there is a delay before the redirect. If the page loads fast and you directly call window.location.replace then the popup will appear. However if you set a timeout to 400ms and then trigger window.location.replace then there will be no popup.
I found this when noticing that after a change and redeployment of the html page, the popup was not shown. This was the case for me because I use a cloudflare worker to host the html page and after an update the initial response time is about 400ms while it is just 15ms if requested again.
I'm developing an app using phonegap/cordova (1.7.0), I can't figure out how to make my application work with a less restrictive option than *. If I try setting www.mywebservicedomain.com or *.mywebservicedomain.com it can't retrieve data anymore. I see many questions about this and the general answer is to just set *. I'd like to understand how to be more restrictive, if it is possible.
Thank you in advance for your efforts.
That is indeed possible. But be aware that redirects on the servers may lead to connections to different domains which you also have to specifiy. Luckily those restricted accesses appear in the debug log in xcode. Run the project on the simulator or the device from within xcode and then you will see which requests to which servers got blocked.
In the cordova.plist it should look like this:
<key>ExternalHosts</key>
<array>
<string>*.googleapis.com</string>
<string>*.gstatic.com</string>
</array>
I use Google maps in my project which uses the described redirect. Thus I had to add the gstatic although my requests point to maps.googleapis.com originally (I use cordova 1.7).