UIWebview Returning Blank Screen - ios

After learning the basic framework, what seems to be working for others is consistently returning a blank screen. Below is what I'm led to believe is overkill, but is still not working. I'm attempting to load an IP as the url (if you are on the same network as one of our products and enter its IP address, a browser will load an interface with relevant values & controls. webIP is the IP string passed from a prior screen and is coming in fine (replacing with google URL still didn't work). This block is inside viewDidLoad in a vanilla enter image description hereViewController:
let deviceURL = NSURL(string: "\(webIP)")
let deviceURLRequest = NSURLRequest(URL: deviceURL!)
deviceWebView.loadRequest(deviceURLRequest)
deviceWebView.reload()
self.reloadInputViews()
I have made sure that there are no UI elements blocking it. Any help is appreciated!!

check whether "App Transport Security Settings" entry is available in plist file?
If not then add "App Transport Security Settings" into your plist file as shown

Related

iOS WKWebView Handle File Download

I am facing the following problem:
In a web interface, file downloads are triggered with an anchor tag, like this:
<a href="/bla/blabla" download>..</a>
While Safari browser can handle this request and open a dialogue to handle the file, WKWebView treats this just as an ordinary link and does nothing with it. I want to be able to get the file handler dialogue that is normally there when using Safari.
Right now there are 2 problems and I do not see an opening there yet:
I can not detect a click on the element as it is treated just as a normal link. And I can not rely on the URL parameters to detect if it is a file since that is not constantly true.
Even if the URL is defined as a one leading to a file, I can not pass it to Safari since it does not share session info and cookies with my app's WKWebView.
Therefore, I would like to know if there is any opening in handling files in iOS WKWebView. Thank you.

Custom URL scheme without confirmation prompt (Swift)

I've found two options to open my app from a Safari web page: a custom URL scheme created in my app project's Info.plist or Apple's Universal Linking. Obviously the custom URL scheme is the easiest one to set up, but the problem I'm having with this is that Safari shows a confirmation window asking "Open myapp?" first and the user has to tap OK before the app actually opens. I want my app to open automatically as the scheme is opened, and I'm being told the only way to do this is through Universal Linking (please correct me if this is not true). If this is true, however, I would like to know if it's possible in any way to put the required apple-app-site-association file on a http:// domain instead of https://? According the official Apple documentation the format of a correct Universal Link starts explicitly with https:// but my domain name can't be loaded on https:// without redirecting a few times and that messes up the web services I've written to execute other tasks in my app. The two main questions I'm left with after this issue:
1) Is it really impossible to work around the confirmation prompt using a custom URL scheme (myscheme://)? If it's not impossible, how can I do this?
2) If I have to use Apple Universal Linking, can I use a http:// domain? If so, how do I do it? Right now if I load up the universal link, it just shows the dictionary inside the apple-app-site-association file, which I'm pretty sure is not supposed to happen. I'm told it's supposed to send a NSUserActivity object to my app delegate. How can I accomplish this with a http:// link?
It is not possible to trigger a custom URI scheme without showing an alert to the user. This used to be possible in iOS 8, but iOS 9 started showing the alert for all apps. And iOS 10.3 has extended that even to the App Store itself. You cannot bypass this. Universal Links were created to replace URI schemes for this behavior, so you do need to use them instead.
From your description, I believe you may be misunderstanding how Universal Links work. To answer the literal questions you asked first, no the Universal Link URL itself does not need to be on the https:// protocol, and yes, the apple-app-site-association must be served over https:// without redirects.
However, it sounds like you're trying to serve the content of the apple-app-site-association file for every Universal Link. That is not the correct implementation — the AASA file is hosted only at https://example.com/apple-app-site-association, and iOS automatically retrieves it when the app is installed. After that, any URL on example.com that matches the criteria in the AASA file will be eligible for Universal Links.
All of that said, you really don't want to built out this system on your own. I suggest looking into Firebase Dynamic Links or Branch.io (full disclosure: I'm on the Branch team).
Is it really impossible to work around the confirmation prompt using a custom URL scheme (myscheme://)? If it's not impossible, how can I do this?
That is possible with some hacky tricks and BAD user experience. It requires user to press "add to home screen" button, so I don't recommend this solution in most cases.
set your app scheme like myapp
create the following html file and put it into the web
window.onload = function() {
if (("standalone" in window.navigator) && window.navigator.standalone) {
window.location.href = 'myapp://open'
}
}
open the html file with safari and "add to home screen"
open the home screen icon and your native app will launch
The point is the meta tag.
<meta name="apple-mobile-web-app-capable" content="yes" />
Without this, safari will launch and confirmation prompt will appear.

Google Map APIs not working after adding bundle identifier - iOS

I Google developer console I created an iOS key as below:
I want to restrict this key to one app only, so I "Edit allowed iOS application" add my bundle Id to it. My bundle Id is easily found in General tab of my project target as following:
I don't know if it is case-sensitive or not, but I copy exactly the identifier from there to add to the key. As you can see, it cannot be mistaken. I also followed Google's instruction, one bundle Identifier per line (I only input one line):
Accept requests from an iOS application with one of the bundle
identifiers listed below (Optional) One bundle identifier per line.
Example: com.example.MyApp
Or if you leave this blank, requests will be accepted from any iOS
application. Be sure to add bundle identifiers before using this key
in production.
This screen show that I enabled all necessary services, to be sure:
The problem with me is that, whenever I added a bundle identifier to the key, my app stops working. But then when I deleted it (now "Any application allowed" as in the picture), everything goes back to work fine.
Could anyone please tell me what could possible cause this?
UPDATE: To clarify more: When I add my bundle ID to the key in Developer Console, now I can still use nearby search in my app. But Autocomplete search and Google URL shortener have stopped working..
whatever request that is getting 403 should be sent with additional header X-Ios-Bundle-Identifier, where your bundle id should be set. This seems undocumented, I only found it through jumping between links, see this...
The reason Autocomplete stops working when you add an iOS Bundle ID is that Google Places API Web Service is specifically not designed for using on iOS. As a gentle hint, I suggest you poke around Google Places API for iOS after Google I/O happens later this week. =)
I also ran into this issue and solved it by following #zhywu's answer above
The Swift 5 code that leverages URLSession/URLSessionDataTask looks like this:
if var urlComponents = URLComponents(string: "https://www.googleapis.com/...") {
...
guard let url = urlComponents.url else { return }
var request = URLRequest(url: url)
request.setValue(Bundle.main.bundleIdentifier ?? "", forHTTPHeaderField: "X-Ios-Bundle-Identifier")
dataTask = defaultSession.dataTask(with: request) { ... }
...
}

webview ip address

I have set up a webview on an iOS7 app.
I can successfully load a webpage as long as it is formatted correctly (including the http://)
ultimately I am hoping to connect to an ip address - similar to the web interface on a router for instance, however the webview doesn't seem to like the format.
Is there a way I can reformat the address in such a way that it will be processed by the webview?
Thanks,
As the comments to your original post mention, using http://127.0.0.1, adding the http:// to the beginning is valid and it does work. I just tested it.
As mentioned befor, you have to use http://. But you'll get a blank view because in iOS http requests are by default "deactivated".
To "activate" the http:// request, you have to go into your info-plist and add
"App Transport Security Settings" and inside of the setting you add "Allows Arbitrary Loads" and change the value from NO to YES.

Browser extension overriding browser functionality / url

Is it possible to create a browser extension which can change where the user is taken?
I.E. If the user puts in a certain prefix or symbol the browser will not attempt to go to the address supposedly determined by the rest of the string or search Google, etc. for the rest of the string?
E.G. YT:sdfs232 would resolve to http://www.youtube.com/watch?v=sdfs232. I'm not specifically looking to do that, it's just an example.
You don't need a new extension or Greasemonkey to do this. Firefox has had this capability for a long time.
Just use a bookmark keyword search.
For example, create a new bookmark:
Press CtrlShiftB to open the bookmark library.
Right-click wherever you want it, and select New Bookmark....
Fill in the Name: Youtube.
Fill in the Location: http://www.youtube.com/watch?v=%s
Note the %s.
Fill in the Keyword: YT.
Fill in the Description: Handy direct shortcut to a video ID.
Give it tags, if you wish.
Click the Add button.
Now you have a handy flexible shortcut.
Test this one by entering YT dQw4w9WgXcQ into the address bar.
See the article for more information.
What your looking for is called a URL Scheme. http, ftp, ssl are all URL Schemes and you can define your own on any platform you want.
This is possible, and is used quite a lot by for example by IPhone apps to launch another iphone app from a browser window when the user clicks on a link. Thats how the iphone jumps from safari to itunes app.
More details here including most common schemes http://en.wikipedia.org/wiki/URI_scheme
This link gives basic info on registering a scheme on windows
http://msdn.microsoft.com/en-us/library/ie/aa767914(v=vs.85).aspx
Ususally they are used to open a seperate application though rather than simply a differnt url, but you could do what you want with a plugin.

Resources