Using browser location inside of SFSafariViewController - ios

I have a webpage that uses location data from the browser that I want to open up inside an ios application.
If I open this page up inside a UIWebview I will see the page ask for location and after I respond the page finishes loading.
However, when I try to open this page up inside of a SFSafariViewController I do not get prompted for location which prevents the page from loading. I definitely want to use SFSafariViewController but I first need to fix this problem.
I've been unable to find any information about using location with SFSafariViewController. Does anyone know how to get this working?

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.

WKWebView ask twice for location permission

I have a simple iOS Swift App
let url = URL(string: "https://www.mycustompage.com")!
webView.load(URLRequest(url: url))
In Info.plist I allowed all privacy-location permissions.
On https://www.mycustompage.com there is a HTML button which locates the user.
Now I have the problem that my app asks twice for the location permissions.
Once for the app and once for the WKWebView.
How can I disable the request for the WebView!?
Thanks
I'm guessing that this is because your webpage is asking for location and safari is basically another app running inside your viewcontroller. One way to bypass this is to simply not ask for the user location in your webpage. instead ask for the user location in the app, then inject then location into your webview with javascript using evaluateJavaScript(_:completionHandler:). Obviously you need to wait until you have both the location and for the page to be full loaded before you make the javascript call.

inAppBrowser Ios hide location URL

I have a scenario where I have to load an external URL within an App. I also want to come back to the App from the external browser.
`var ref = cordova.InAppBrowser.open('http://apache.org', '_blank', 'location=yes');`
I tried this and this is giving a DONE button, which brings me back to the App. However this shows the URL of the external page. I dont want the user to see the external URL. Is there any solution to this? Please help!

iOS: Open a registered open URL from within the same app

I am running into a situation which I am not sure is possible from technical/design point of view. Please advise.
Here is what I need:
I have an open URL registered for my native iOS app. I expect a request ID to be passed along with it and once hit I open that request.
From within my native iOS app, I need to open a web page in the webview. This page has few buttons in it.
A tap on the button in the webview should open the request inside my app. So, I want to trigger the registered open URL in step #1.
Web page data is dynamic and will change on the fly.
Is this a feasible design. Shall I consider something else.
Any advise/pointers will be appreciated.
This should be possible. Here's a though:
1: Implement the UIWebview delegate method shouldStartLoadWithRequest.
2: when you intercept that your webview is attempting to access the url yourapp://blah-blah-blah you can return NO instead dip into your appdelegate can manually call the function handleOpenURL.
I've seen something similar in the past with supporting oAuth (I believe it was with instagram) within one of our apps. We basically loaded up the login page in a UIWebview and then when we detected the the post login redirect we parsed the oAuth token from the url and called it good.
Good luck

Invoking Safari on iOS without opening a new website

The situation is like this:
User opens app from a website using a custom urlscheme
User does stuff in the app
User clicks button in the app to return to the website in Safari.
I have tried opening a new tab containing a javascript:window.close() but this does not work on iOS 6.1.
So my question is: Is there a way to open Safari to view the website the user left from? Either with a working new tab that closes itself or a different route?
When you open the app with your custom url scheme, pass the actual page url as an argument.
mycustomUrlScheme://mydomain.com?objectid=1234&callback_url=encoded_url
In your app, handle the url for the content info and keep the page url to open it afterwards. It will make safari open a new tab. But that should be a good start.
As far as i understand you can do it.
user opens mobile safari for example http://www.example.com
user clicks a link that is appscheme://open and the application become active
user taps a button to open safari for example http://www.example.com?q=test
for the third step you can use [[UIApplication sharedApplication]openURL:url]

Resources