I have an iOS 9 only app which I am developing with a UITableViewController
and a list of videos by a company. Some of the videos are hosted on YouTube. In the didSelectRowAtIndexPath
, I implement the use of SFSafariViewController
in the following way:
SFSafariViewController *safariVC = [[SFSafariViewController alloc] initWithURL:[NSURL URLWithString:@"https://www.youtube.com/watch?v=YQHsXMglC9A"]entersReaderIfAvailable:NO];
safariVC.delegate = self;
[self presentViewController:safariVC animated:YES completion:nil];
Please note, the video in that link is not the video I am using for my app - it's simply an example.
When I click that without the YouTube.app installed on my device, it opens up in SFSafariViewController
. If I have YouTube.app installed, it prompts me to open the link in there:
I understand why this is happening, because of the work in iOS 9, but how can I prevent it? It'll be pretty annoying for my users to have to go to YouTube to watch the video and then come back to the app (even if it's via the back link at the top).
How can I prevent this from happening within the app, to say use the SFSafariViewController within the app rather than the YouTube app?
Update
This behaviour does not happen with the Twitter or Facebook native apps, so the question is, is this a YouTube native app issue (something I can't do anything about) or is there a way for me to prevent the opening? With SFSafariViewController, Apple's aim would have been to make it easier; there must be a way to prevent apps from prompting and loading in the native app.
Any guidance on this would be appreciated.