Website wrapped in iOS App - Catching hyperlink click events - ios

I have a iOS app that wraps a website. When the user clicks a link in the wrapped website, I want to trap the event in my app and be able to get information about the link that was clicked. Is this something that can be done in Swift?
I'm relatively new to iOS app development and I'm working on an app that has been around for a while.

The short answer is "Yes". There are a couple of views that you can use in iOS to display web content. One such view is WKWebView.
If you look at the documentation at that link, close to the bottom of the page you will find a header for "Managing Navigation Through your Web Content".
What you do is create a WKNavigationDelegate that you attach to your WKWebView. That delegate is notified when the user wants to navigate through the web content (for example, when they click on a link) and lets your application code participate in the navigation process. It can allow navigation, deny navigation, find out when it starts and stop, things of that nature.

Related

iOS how to launch another app as a redirection

An app is currently outdated and to avoid the users to use its incorrect results, we decided to suspend this app until we have the algorithm updated.
We have tried the following:
Titanium.Platform.openURL("http://example.net");
This will open the web browser to a URL of our selection. However, in iOS there is a little "go back" link in the top left hand corner, which will lead the user back to the broken app. We want to avoid this. Basically, we want the app to be inactive all the time - whenever the user attempt to activate it, the designated page behind the URL should be shown.
How can we do this?
Why not just temporarily replace the main page of you app with a full screen web view showing the desired URL? The user stays in your app but still can only access the web page you direct them to.

iOS 9 Universal links Forward button breaks deep linking forever until I erase phone settings

Before anyone marks this question as a duplicate please read the extra section at the bottom that sites differences between this question and other similar questions out there
I'm utilizing Universal Links for my deep linking needs. Two example use cases are:
1.) Safari/Chrome Browser on iPhone with my app installed: When click on a link on my web site on their iPhone I'm deep linking them into my app if installed on their phone.
2.) With my app installed, running my app but using an in-app-UIWebView. My app also has an in-app UIWebView, when you tap a button it deep links them somewhere in the application.
After you deep link into the app, there are two buttons in the navigation bar. A Back button (top left) and a Forward button (top right).
My problem
If the user presses the forward button (top right) it forwards them to my web page and then will forever break my deep linking so that any time in the future when the user clicks on that link to deep link it always goes to my web page instead of deep linking into the app (which was the original intention). How can I prevent this? My concern here is that my app has close buttons in the top right corner and if the user is trying to hit hte close button they could accidentally hit the forward button and forever break deep linking. I've tried clearing my browsers caches, I've tried deleting and re-installing my app. But nothing will "fix" deep linking after it's been permanently disabled by the forward button. The only way I can get it working again is by doing a complete device reset and Erasing all Content and Settings.
Here is an image of the back and forward buttons after deep linking into the application.
Difference between my question and similar questions on SO:
Similar SO question But here they are saying that the user can long-press on the "universal link" and and action sheet pops up asking you to "open in ". I've tried this for above case 1.) and my app isn't showing up in the options. See attached screenshot below. And this doesn't work at all for above case 2.). How do you get a Universal link to work with an iOS WebViewController? Do I have to use the SafariViewController? I don't want to use SafariViewController in my app for this case because I don't want to have that top navigation bar that SafariViewController has.
You're absolutely right: the forward button is horrible UI/UX. It's one of the big flaws with Universal Links identified in this blog post. There is no way to disable the forward button, and once it's triggered, you're screwed.
The easiest way to re-enable Universal Linking behavior after it is turned off is to long-press on the link. But that doesn't work if your link is being disabled by the system based on some other criteria (more details below). Your best bet at getting a clean shot is to paste the Universal Link URL into the stock Notes app and try long-pressing it from there.
To answer a few of your other questions:
Universal Links do work within UIWebView (per Apple's docs). A SafariViewController is not necessary.
Universal Links are disabled at the system level in certain situations. There's a list here, but this the main one that comes to mind as potentially applicable in this situation:
Universal Links will not work with a user driven element click on the same domain. Example: if there is a Universal Link on google.com pointing to a different Universal Link on google.com, it will not open the app.
Your second example image is from Chrome. Universal Links should work (conditionally) in Chrome, but is the link pointing at the same domain as the page you've already loaded? If so, that's why you aren't seeing the Open in [app] option.
You cannot disable the button to open the website, but you can create a path in the other direction: Use a smart banner on the website, and when users tap "Open" (or the localized equivalent), they will be taken back to your app, and this will also reset the default to opening universal links in your app instead of Safari.

What is this iOS view called?

When you click on a url from a native app such as the Twitter or Facebook app, a new panel comes up to display the page. When you X out the panel, you are still in the app at the location from where you launched the url. How is this done as opposed to launching the url in an instance of Safari ?
You can use either WKWebView or SFSafariViewController
SFSafariViewController is now widely used to view websites and it looks just like Safari.app (the user can access his saved passwords/cards, and he can use reader view), the problem is that you don't have any control over it.
WKWebView is a replacement for UIWebView and you will have a better control over it but you'll have to add your own navigation and refresh buttons and title bar.
UIWebView. Here is a link to apples developer reference
https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIWebView_Class/

Navigating to XAML page from WebView Windows Store application

I am developing an application, where I need to open a full-screen WebView over my existing XAML page.
Now I've added a AppBar over this WebView. The requirement is that, appBar button click should navigate me to different application Page.
e.g. WebView is opened on MainPage.xaml and on clicking the AppBar button added on this webView I have to navigate to SeconsPage.XAML
I am not able to do this now and seeing an exception thrown by COntrol_webview,exe
Can I do such navigation? If Yes, pleas help me to find out what I am I missing?
Thanks in advance!!
go for a native app - it saves you a lot of trouble. Filip Skakun already described the first crazy thing about the webview (with the webviewbrush).
if not, you can use the script notification to communicate back and forth between your webapp and your store app. here's a good link: http://blogs.msdn.com/b/wsdevsol/archive/2012/10/18/nine-things-you-need-to-know-about-webview.aspx

Web iPad app to be downloaded / short cut added to home screen from page - is that possible?

I am developing a web iPad app using Sencha Touch framework.
As it is a JS and Html5 framework It allows me to use cashing and work offline.
If I use the "+" button on iPad's Safari I can ad the icon/ shortcut to the home screen and make it behave as a native app (work without safari's address bar).
I was wandering would it be possible to create a button on the web page that would have the same functionality as the "+" button - so it allows users to add a web app shortcut to their ipad's home screens directly from the web page.
Is it possible? Can JS deal with it using apple's API?
Sorry, but this isn't possible. (JavaScript has no access to any special Apple API's - merely some additional events for touch handlers, etc.)
If it was, you can imagine that it would be trivial for any web site to automate this process (fake the user pressing the in-page "add" button) and hence add itself to the user's home screen without their permission.

Resources