iOS in-App browser - ios

Hey so I am building an iOS RSS Reader News app. Some long RSS articles end with a "Read more" link. After clicking "Read more", Safari opens up. I want it to - instead of having Safari open that link - open it inside the app.
Note: I need this to function permamently with every link in the app and without me having to manually change what links will be opened inside the app.

Create a WebViewController, just a regular ViewController with a webView with the size of the screen. So then you just
let webViewController = WebViewController()
webViewController.title = yourRSSItem.title
webViewController.request = NSURLRequest(URL: NSURL(string: yourRSSItem.url)!)
self.navigationController?.pushViewController(webViewController, animated: true) //you can present it as well

Related

Redirect in Safari as soon as you open iOS Swift app

I am developing a simple iOS app with Swift, I would need to know if there is a method to direct Safari to a URL as soon as the app opens, without button clicks.
in the ViewWillAppear methods you can open an URL calling this methods:
if let link = URL(string: "https://yoursite.com") {
UIApplication.shared.open(link)
}

Instantly open Web Inspector for iOS WebView

I'm developing an iOS app with WebView.
I need to debug is so that's what I do:
Open WebView on iOS
Go to desktop Safari -> Develop -> iPhone ->
The problem is some script takes place the moment WebView opens. So when I open Web Inspector all I see is just a blank page.
Is there any way to pause page processing before Web Inspector is opened?
For such cases, I would place a UIButton somewhere in the layout, and request the url, only when the button is pressed. That is you will have a WKWebView initiated and available in your screen and you only navigate to the url path on the tap event of the UIButton.
This is just for debugging purposes.

How do I open a single URL with no tabs shown with Objective-C, but with an OK button?

I'm trying to open a webpage in order to let users register in my app, but when doing so using openURL
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"http://example.com"]];
A full window of safari is opened, and my URL added to the open tabs.
Is it there any way I can open this single URL, with no tabs or URL bar, but still with navigation controls and a OK button to close the window?
I'm trying to do something similar to how Chrome Custom Tabs work on Android
You can try SFSafariViewController (swift syntax):
let safari = SFSafariViewController(url: url)
self.present(safari, animated: false, completion: nil)
Just import SafariServices for it.

Prevent UIWebView Pop Out to Safari, But Still Load Page

I'm working on an iOS application that uses a lot of UIWebViews. Is there are way to prevent the UIWebView from popping out to Safari (iFrame code) but still load the page?
In other words return YES in webView:shouldStartLoadWithRequest:navigationType: but not let the web page pop out to Safari.
EDIT:
The web view side has processes that need to be executed, which is why I need to return YES. But the processes also inadvertently cause the application to launch the URL in Safari. I'm looking for a way to intercept that, and choose whether or not to launch the URL in Safari.
Apple introduced a Safari View Controller on iOS 9. Safari View Controller is a pre-built browser that has all the bells and whistles of Mobile Safari, but can be presented without leaving your app.
First we need to import Safari Services
#import <SafariServices/SafariServices.h>
For Objective C:-
NSString *yourUrl = #"http://yourURL";
SFSafariViewController *svc= [[SFSafariViewController alloc] initWithURL:[NSURL URLWithString: yourUrl]];
[self presentViewController:svc animated:YES completion:nil];
For Swift:-
let svc = SFSafariViewController(URL: NSURL(string: self.urlString)!)
self.presentViewController(svc, animated: true, completion: nil)

Launching Containing App from UIWebView in Custom Keyboard

Since you can only go the normal route for launching a containing app from a Today extension, and not a Custom Keyboard, I've been trying to do the hacky version of launching a UIWebView and launching the containing app through its URL scheme. Mostly been getting help from this post: launch containing app from iOS8 Custom Keyboard, but I'm not allowed to comment on answers since I'm new to stack overflow.
Anyways, doing it now, the UIWebView is popping up but is just showing a blank white square and not launching the URL scheme. Already tried accessing the URL scheme from Safari, and I know that launches the app, so not sure why its not doing anything. Code I have now in the method following when the right key is pushed is:
let urlkey = NSURL(string: "MYAPP://")
let webAppView = UIWebView(frame: CGRectMake(0, 0, 100, 100))
let request = NSURLRequest(URL: urlkey!)
webAppView.loadRequest(request)
self.view.addSubview(webAppView)
Any ideas for why nothing in the view is loading, or other ways to go about launching a containing app from a custom keyboard appreciated. Using XCode 6.3 and Swift.
It is not possible to launch another app through keyboard-extension.
Other extensions like today-widget-extension can use like below.
NSURL *pjURL = [NSURL URLWithString:#"hostingapp://home"];
[self.extensionContext openURL:pjURL completionHandler:nil];
//https://stackoverflow.com/questions/24019820/today-app-extension-widget-tap-to-open-containing-app
but, nothing happens in the keyboard-extension.
//I guess...
If you get success to implement launching app in the keyboard, the keyboard will not be accepted by Apple.
updated 15/09/14 :
openURL not work in Action Extension
I found some people are trying that, so check this.
Some said their app accepted by apple.(I don't know it's true)

Resources